зеркало из https://github.com/mozilla/pjs.git
91365. r=dougt, sr=hyatt. nsIScriptGlobalObject->GetContext() can legitimately return NS_OK *and* a nsnull outparam. Various callsites were not respecting the nsnull out param and this patch gracefully handles those cases.
This commit is contained in:
Родитель
db62985b1a
Коммит
c4f90087de
|
@ -1084,6 +1084,8 @@ nsXBLBinding::InstallProperties()
|
||||||
rv = global->GetContext(getter_AddRefs(context));
|
rv = global->GetContext(getter_AddRefs(context));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (!context) return NS_OK;
|
||||||
|
|
||||||
// Init our class and insert it into the prototype chain.
|
// Init our class and insert it into the prototype chain.
|
||||||
nsAutoString className;
|
nsAutoString className;
|
||||||
nsCAutoString classStr;
|
nsCAutoString classStr;
|
||||||
|
@ -1779,6 +1781,8 @@ nsXBLBinding::AddScriptEventListener(nsIContent* aElement, nsIAtom* aName,
|
||||||
rv = global->GetContext(getter_AddRefs(context));
|
rv = global->GetContext(getter_AddRefs(context));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (!context) return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIEventListenerManager> manager;
|
nsCOMPtr<nsIEventListenerManager> manager;
|
||||||
rv = receiver->GetListenerManager(getter_AddRefs(manager));
|
rv = receiver->GetListenerManager(getter_AddRefs(manager));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
|
@ -384,6 +384,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver,
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptContext> boundContext;
|
nsCOMPtr<nsIScriptContext> boundContext;
|
||||||
boundGlobal->GetContext(getter_AddRefs(boundContext));
|
boundGlobal->GetContext(getter_AddRefs(boundContext));
|
||||||
|
if (!boundContext) return NS_OK;
|
||||||
|
|
||||||
JSObject* scriptObject = nsnull;
|
JSObject* scriptObject = nsnull;
|
||||||
|
|
||||||
|
|
|
@ -1857,6 +1857,8 @@ nsXULElement::AddScriptEventListener(nsIAtom* aName,
|
||||||
|
|
||||||
rv = global->GetContext(getter_AddRefs(context));
|
rv = global->GetContext(getter_AddRefs(context));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (!context) return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> root;
|
nsCOMPtr<nsIContent> root;
|
||||||
|
|
|
@ -813,7 +813,7 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
|
||||||
nsCOMPtr<nsIScriptGlobalObject> global;
|
nsCOMPtr<nsIScriptGlobalObject> global;
|
||||||
document->GetScriptGlobalObject(getter_AddRefs(global));
|
document->GetScriptGlobalObject(getter_AddRefs(global));
|
||||||
if (global) {
|
if (global) {
|
||||||
if (NS_OK == global->GetContext(getter_AddRefs(context))) {
|
if ((NS_OK == global->GetContext(getter_AddRefs(context))) && context) {
|
||||||
// Get the DOM window
|
// Get the DOM window
|
||||||
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(global);
|
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(global);
|
||||||
if (domWindow != nsnull) {
|
if (domWindow != nsnull) {
|
||||||
|
|
|
@ -5173,6 +5173,8 @@ nsXULDocument::ExecuteScript(JSObject* aScriptObject)
|
||||||
rv = mScriptGlobalObject->GetContext(getter_AddRefs(context));
|
rv = mScriptGlobalObject->GetContext(getter_AddRefs(context));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (! context) return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
rv = context->ExecuteScript(aScriptObject, nsnull, nsnull, nsnull);
|
rv = context->ExecuteScript(aScriptObject, nsnull, nsnull, nsnull);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,8 @@ nsresult nsJSThunk::EvaluateScript()
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
if (!scriptContext) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// Get principal of code for execution
|
// Get principal of code for execution
|
||||||
nsCOMPtr<nsISupports> owner;
|
nsCOMPtr<nsISupports> owner;
|
||||||
rv = mChannel->GetOwner(getter_AddRefs(owner));
|
rv = mChannel->GetOwner(getter_AddRefs(owner));
|
||||||
|
|
|
@ -882,8 +882,10 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext)
|
||||||
nsCOMPtr<nsIScriptContext> context;
|
nsCOMPtr<nsIScriptContext> context;
|
||||||
|
|
||||||
if (global->GetContext(getter_AddRefs(context)) == NS_OK) {
|
if (global->GetContext(getter_AddRefs(context)) == NS_OK) {
|
||||||
*outContext = (JSContext*) context->GetNativeContext();
|
if (context) {
|
||||||
rv = NS_OK;
|
*outContext = (JSContext*) context->GetNativeContext();
|
||||||
|
rv = NS_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -882,8 +882,10 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext)
|
||||||
nsCOMPtr<nsIScriptContext> context;
|
nsCOMPtr<nsIScriptContext> context;
|
||||||
|
|
||||||
if (global->GetContext(getter_AddRefs(context)) == NS_OK) {
|
if (global->GetContext(getter_AddRefs(context)) == NS_OK) {
|
||||||
*outContext = (JSContext*) context->GetNativeContext();
|
if (context) {
|
||||||
rv = NS_OK;
|
*outContext = (JSContext*) context->GetNativeContext();
|
||||||
|
rv = NS_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1593,7 +1593,7 @@ static void ShowConsole(nsBrowserWindow* aWindow)
|
||||||
nsIScriptContext *context = nsnull;
|
nsIScriptContext *context = nsnull;
|
||||||
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(aWindow->mDocShell));
|
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(aWindow->mDocShell));
|
||||||
if (scriptGlobal) {
|
if (scriptGlobal) {
|
||||||
if (NS_OK == scriptGlobal->GetContext(&context)) {
|
if ((NS_OK == scriptGlobal->GetContext(&context)) && context) {
|
||||||
|
|
||||||
// create the console
|
// create the console
|
||||||
gConsole = JSConsole::CreateConsole();
|
gConsole = JSConsole::CreateConsole();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче