Bug 1017030 - Part 3: Replace AutoPushJSContext in PostMessageRunnable::Run. r=bholley

This commit is contained in:
Bob Owen 2014-06-11 17:22:00 +01:00
parent f165ac189f
commit 8d321d76c0

View File

@ -13,6 +13,7 @@
#include "nsContentUtils.h"
#include "nsGlobalWindow.h"
#include "nsPresContext.h"
#include "ScriptSettings.h"
#include "nsIDocument.h"
#include "nsIDOMFile.h"
@ -271,14 +272,14 @@ PostMessageRunnable::Run()
{
MOZ_ASSERT(mPort);
// Get the JSContext for the target window
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(mPort->GetOwner());
NS_ENSURE_STATE(sgo);
nsCOMPtr<nsIScriptContext> scriptContext = sgo->GetContext();
AutoPushJSContext cx(scriptContext ? scriptContext->GetNativeContext()
: nsContentUtils::GetSafeJSContext());
nsCOMPtr<nsIGlobalObject> globalObject = do_QueryInterface(mPort->GetOwner());
if (NS_WARN_IF(!globalObject)) {
return NS_ERROR_UNEXPECTED;
}
MOZ_ASSERT(cx);
AutoJSAPI jsapi;
JSContext* cx = jsapi.cx();
JSAutoCompartment ac(cx, globalObject->GetGlobalJSObject());
// Deserialize the structured clone data
JS::Rooted<JS::Value> messageData(cx);