зеркало из 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));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!context) return NS_OK;
|
||||
|
||||
// Init our class and insert it into the prototype chain.
|
||||
nsAutoString className;
|
||||
nsCAutoString classStr;
|
||||
|
@ -1779,6 +1781,8 @@ nsXBLBinding::AddScriptEventListener(nsIContent* aElement, nsIAtom* aName,
|
|||
rv = global->GetContext(getter_AddRefs(context));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!context) return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
rv = receiver->GetListenerManager(getter_AddRefs(manager));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
|
|
@ -384,6 +384,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver,
|
|||
|
||||
nsCOMPtr<nsIScriptContext> boundContext;
|
||||
boundGlobal->GetContext(getter_AddRefs(boundContext));
|
||||
if (!boundContext) return NS_OK;
|
||||
|
||||
JSObject* scriptObject = nsnull;
|
||||
|
||||
|
|
|
@ -1857,6 +1857,8 @@ nsXULElement::AddScriptEventListener(nsIAtom* aName,
|
|||
|
||||
rv = global->GetContext(getter_AddRefs(context));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!context) return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> root;
|
||||
|
|
|
@ -813,7 +813,7 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
|
|||
nsCOMPtr<nsIScriptGlobalObject> global;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(global));
|
||||
if (global) {
|
||||
if (NS_OK == global->GetContext(getter_AddRefs(context))) {
|
||||
if ((NS_OK == global->GetContext(getter_AddRefs(context))) && context) {
|
||||
// Get the DOM window
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(global);
|
||||
if (domWindow != nsnull) {
|
||||
|
|
|
@ -5173,6 +5173,8 @@ nsXULDocument::ExecuteScript(JSObject* aScriptObject)
|
|||
rv = mScriptGlobalObject->GetContext(getter_AddRefs(context));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (! context) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = context->ExecuteScript(aScriptObject, nsnull, nsnull, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -155,6 +155,8 @@ nsresult nsJSThunk::EvaluateScript()
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!scriptContext) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get principal of code for execution
|
||||
nsCOMPtr<nsISupports> owner;
|
||||
rv = mChannel->GetOwner(getter_AddRefs(owner));
|
||||
|
|
|
@ -882,8 +882,10 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext)
|
|||
nsCOMPtr<nsIScriptContext> context;
|
||||
|
||||
if (global->GetContext(getter_AddRefs(context)) == NS_OK) {
|
||||
*outContext = (JSContext*) context->GetNativeContext();
|
||||
rv = NS_OK;
|
||||
if (context) {
|
||||
*outContext = (JSContext*) context->GetNativeContext();
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -882,8 +882,10 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext)
|
|||
nsCOMPtr<nsIScriptContext> context;
|
||||
|
||||
if (global->GetContext(getter_AddRefs(context)) == NS_OK) {
|
||||
*outContext = (JSContext*) context->GetNativeContext();
|
||||
rv = NS_OK;
|
||||
if (context) {
|
||||
*outContext = (JSContext*) context->GetNativeContext();
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1593,7 +1593,7 @@ static void ShowConsole(nsBrowserWindow* aWindow)
|
|||
nsIScriptContext *context = nsnull;
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(aWindow->mDocShell));
|
||||
if (scriptGlobal) {
|
||||
if (NS_OK == scriptGlobal->GetContext(&context)) {
|
||||
if ((NS_OK == scriptGlobal->GetContext(&context)) && context) {
|
||||
|
||||
// create the console
|
||||
gConsole = JSConsole::CreateConsole();
|
||||
|
|
Загрузка…
Ссылка в новой задаче