Bug 1045646 - Part 4: Replace AutoPushJSContext in nsHTTPIndex::OnStartRequest. r=bholley

This commit is contained in:
Bob Owen 2014-08-01 10:53:10 +01:00
parent 5c01bd6fa7
commit 50615f100f

View File

@ -25,8 +25,6 @@
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "rdf.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsIXPConnect.h"
@ -51,7 +49,6 @@
#include "nsIDocument.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsCxPusher.h"
using namespace mozilla;
@ -224,14 +221,14 @@ nsHTTPIndex::OnStartRequest(nsIRequest *request, nsISupports* aContext)
if (mBindToGlobalObject && mRequestor) {
mBindToGlobalObject = false;
// Now get the content viewer container's script object.
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(mRequestor));
NS_ENSURE_TRUE(scriptGlobal, NS_ERROR_FAILURE);
nsCOMPtr<nsIGlobalObject> globalObject = do_GetInterface(mRequestor);
NS_ENSURE_TRUE(globalObject, NS_ERROR_FAILURE);
nsIScriptContext *context = scriptGlobal->GetContext();
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
// We might run script via JS_SetProperty, so we need an AutoEntryScript.
// This is Gecko specific and not in any spec.
dom::AutoEntryScript aes(globalObject);
JSContext* cx = aes.cx();
AutoPushJSContext cx(context->GetNativeContext());
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
// Using XPConnect, wrap the HTTP index object...