Bug 636251 - Use JSOPTION_NO_SCRIPT_RVAL in nsFrameMessageManager.cpp, r=jorendorff

This commit is contained in:
Michael Wu 2011-03-25 14:31:14 -07:00
parent f1fd210898
commit 6651b13d4e

View File

@ -627,10 +627,9 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
JSObject* global = nsnull; JSObject* global = nsnull;
mGlobal->GetJSObject(&global); mGlobal->GetJSObject(&global);
if (global) { if (global) {
jsval val;
JS_ExecuteScript(mCx, global, JS_ExecuteScript(mCx, global,
(JSScript*)JS_GetPrivate(mCx, holder->mObject), (JSScript*)JS_GetPrivate(mCx, holder->mObject),
&val); nsnull);
} }
} }
JSContext* unused; JSContext* unused;
@ -682,12 +681,18 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
JSPrincipals* jsprin = nsnull; JSPrincipals* jsprin = nsnull;
mPrincipal->GetJSPrincipals(mCx, &jsprin); mPrincipal->GetJSPrincipals(mCx, &jsprin);
nsContentUtils::XPConnect()->FlagSystemFilenamePrefix(url.get(), PR_TRUE); nsContentUtils::XPConnect()->FlagSystemFilenamePrefix(url.get(), PR_TRUE);
uint32 oldopts = JS_GetOptions(mCx);
JS_SetOptions(mCx, oldopts | JSOPTION_NO_SCRIPT_RVAL);
JSScript* script = JSScript* script =
JS_CompileUCScriptForPrincipals(mCx, nsnull, jsprin, JS_CompileUCScriptForPrincipals(mCx, nsnull, jsprin,
(jschar*)dataString.get(), (jschar*)dataString.get(),
dataString.Length(), dataString.Length(),
url.get(), 1); url.get(), 1);
JS_SetOptions(mCx, oldopts);
if (script) { if (script) {
JSObject* scriptObj = JS_NewScriptObject(mCx, script); JSObject* scriptObj = JS_NewScriptObject(mCx, script);
JS_AddObjectRoot(mCx, &scriptObj); JS_AddObjectRoot(mCx, &scriptObj);
@ -702,9 +707,8 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
"Cached message manager script"); "Cached message manager script");
sCachedScripts->Put(aURL, holder); sCachedScripts->Put(aURL, holder);
} }
jsval val;
JS_ExecuteScript(mCx, global, JS_ExecuteScript(mCx, global,
(JSScript*)JS_GetPrivate(mCx, scriptObj), &val); (JSScript*)JS_GetPrivate(mCx, scriptObj), nsnull);
JS_RemoveObjectRoot(mCx, &scriptObj); JS_RemoveObjectRoot(mCx, &scriptObj);
} }
//XXX Argh, JSPrincipals are manually refcounted! //XXX Argh, JSPrincipals are manually refcounted!