diff --git a/source/gui/ObjectBases/IGUIObject.cpp b/source/gui/ObjectBases/IGUIObject.cpp index 8653452d5d..24cbfc9022 100644 --- a/source/gui/ObjectBases/IGUIObject.cpp +++ b/source/gui/ObjectBases/IGUIObject.cpp @@ -315,6 +315,7 @@ void IGUIObject::RegisterScriptHandler(const CStr& eventName, const CStr& Code, JS::CompileOptions options(rq.cx); options.setFileAndLine(CodeName.c_str(), 0); options.setIsRunOnce(false); + options.setForceStrictMode(); JS::SourceText src; ENSURE(src.init(rq.cx, Code.c_str(), Code.length(), JS::SourceOwnership::Borrowed)); diff --git a/source/scriptinterface/ScriptContext.cpp b/source/scriptinterface/ScriptContext.cpp index c0c814e03d..8274e76cc6 100644 --- a/source/scriptinterface/ScriptContext.cpp +++ b/source/scriptinterface/ScriptContext.cpp @@ -127,8 +127,6 @@ ScriptContext::ScriptContext(int contextSize, int heapGrowthBytesGCTrigger): JS_SetGlobalJitCompilerOption(m_cx, JSJITCOMPILER_SPECTRE_STRING_MITIGATIONS, 0); JS_SetGlobalJitCompilerOption(m_cx, JSJITCOMPILER_SPECTRE_OBJECT_MITIGATIONS, 0); - JS::ContextOptionsRef(m_cx).setStrictMode(true); - ScriptEngine::GetSingleton().RegisterContext(m_cx); JS::SetJobQueue(m_cx, m_JobQueue.get()); diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index aa93a2fd8d..1d62a8a78b 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -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 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 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 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 src; ENSURE(src.init(rq.cx, code, strlen(code), JS::SourceOwnership::Borrowed)); if (JS::Evaluate(rq.cx, opts, src, rval))