1
0
forked from mirrors/0ad

Use js compiler option for strict-mode

The context option enabling strict mode was removed in sm-117 [1]
requiring to use the compiler option for the same purpose instead.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1621603

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser
2025-03-29 14:34:43 +01:00
parent 2ed912ae88
commit 933f49722e
3 changed files with 5 additions and 2 deletions
@@ -626,6 +626,7 @@ bool ScriptInterface::LoadScript(const VfsPath& filename, const std::string& cod
// TODO: it would probably be better to not implicitly introduce JS scopes.
options.setFileAndLine(filenameStr.c_str(), 0);
options.setIsRunOnce(false);
options.setForceStrictMode();
JS::SourceText<mozilla::Utf8Unit> src;
ENSURE(src.init(rq.cx, code.c_str(), code.length(), JS::SourceOwnership::Borrowed));
@@ -655,6 +656,7 @@ bool ScriptInterface::LoadGlobalScript(const VfsPath& filename, const std::strin
JS::RootedValue rval(rq.cx);
JS::CompileOptions opts(rq.cx);
opts.setFileAndLine(filenameStr.c_str(), 1);
opts.setForceStrictMode();
JS::SourceText<mozilla::Utf8Unit> src;
ENSURE(src.init(rq.cx, code.c_str(), code.length(), JS::SourceOwnership::Borrowed));
@@ -695,6 +697,7 @@ bool ScriptInterface::Eval(const char* code) const
JS::CompileOptions opts(rq.cx);
opts.setFileAndLine("(eval)", 1);
opts.setForceStrictMode();
JS::SourceText<mozilla::Utf8Unit> src;
ENSURE(src.init(rq.cx, code, strlen(code), JS::SourceOwnership::Borrowed));
if (JS::Evaluate(rq.cx, opts, src, &rval))
@@ -710,6 +713,7 @@ bool ScriptInterface::Eval(const char* code, JS::MutableHandleValue rval) const
JS::CompileOptions opts(rq.cx);
opts.setFileAndLine("(eval)", 1);
opts.setForceStrictMode();
JS::SourceText<mozilla::Utf8Unit> src;
ENSURE(src.init(rq.cx, code, strlen(code), JS::SourceOwnership::Borrowed));
if (JS::Evaluate(rq.cx, opts, src, rval))