mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 865745 - Stop depending on mCx during frame script execution. r=smaug
This commit is contained in:
parent
c37d044ace
commit
b1e77d43cc
@ -995,7 +995,7 @@ nsFrameScriptExecutor::Shutdown()
|
|||||||
void
|
void
|
||||||
nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
|
nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
|
||||||
{
|
{
|
||||||
if (!mGlobal || !mCx || !sCachedScripts) {
|
if (!mGlobal || !sCachedScripts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1006,11 +1006,11 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (holder) {
|
if (holder) {
|
||||||
nsCxPusher pusher;
|
AutoSafeJSContext cx;
|
||||||
pusher.Push(mCx);
|
JS::Rooted<JSObject*> global(cx, mGlobal->GetJSObject());
|
||||||
JS::Rooted<JSObject*> global(mCx, mGlobal->GetJSObject());
|
|
||||||
if (global) {
|
if (global) {
|
||||||
(void) JS_ExecuteScript(mCx, global, holder->mScript, nullptr);
|
JSAutoCompartment ac(cx, global);
|
||||||
|
(void) JS_ExecuteScript(cx, global, holder->mScript, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1059,18 +1059,17 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dataString.IsEmpty()) {
|
if (!dataString.IsEmpty()) {
|
||||||
nsCxPusher pusher;
|
AutoSafeJSContext cx;
|
||||||
pusher.Push(mCx);
|
JS::Rooted<JSObject*> global(cx, mGlobal->GetJSObject());
|
||||||
JS::Rooted<JSObject*> global(mCx, mGlobal->GetJSObject());
|
|
||||||
if (global) {
|
if (global) {
|
||||||
JSAutoCompartment ac(mCx, global);
|
JSAutoCompartment ac(cx, global);
|
||||||
JS::CompileOptions options(mCx);
|
JS::CompileOptions options(cx);
|
||||||
options.setNoScriptRval(true)
|
options.setNoScriptRval(true)
|
||||||
.setFileAndLine(url.get(), 1)
|
.setFileAndLine(url.get(), 1)
|
||||||
.setPrincipals(nsJSPrincipals::get(mPrincipal));
|
.setPrincipals(nsJSPrincipals::get(mPrincipal));
|
||||||
JS::RootedObject empty(mCx, nullptr);
|
JS::RootedObject empty(cx, nullptr);
|
||||||
JS::Rooted<JSScript*> script(mCx,
|
JS::Rooted<JSScript*> script(cx,
|
||||||
JS::Compile(mCx, empty, options, dataString.get(),
|
JS::Compile(cx, empty, options, dataString.get(),
|
||||||
dataString.Length()));
|
dataString.Length()));
|
||||||
|
|
||||||
if (script) {
|
if (script) {
|
||||||
@ -1081,11 +1080,11 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
|
|||||||
nsFrameJSScriptExecutorHolder* holder =
|
nsFrameJSScriptExecutorHolder* holder =
|
||||||
new nsFrameJSScriptExecutorHolder(script);
|
new nsFrameJSScriptExecutorHolder(script);
|
||||||
// Root the object also for caching.
|
// Root the object also for caching.
|
||||||
JS_AddNamedScriptRoot(mCx, &(holder->mScript),
|
JS_AddNamedScriptRoot(cx, &(holder->mScript),
|
||||||
"Cached message manager script");
|
"Cached message manager script");
|
||||||
sCachedScripts->Put(aURL, holder);
|
sCachedScripts->Put(aURL, holder);
|
||||||
} else if (aBehavior == EXECUTE_IF_CANT_CACHE) {
|
} else if (aBehavior == EXECUTE_IF_CANT_CACHE) {
|
||||||
(void) JS_ExecuteScript(mCx, global, script, nullptr);
|
(void) JS_ExecuteScript(cx, global, script, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user