Bug 834732 - Make nsDocShell::AddState push the JSContext if it grabs one, and remove push in nsStructuredCloneContainer. r=mrbkap

This gets rid of one of the last consumers of REQUIRE_SCRIPT_CONTEXT.
This commit is contained in:
Bobby Holley 2013-02-13 00:22:26 +01:00
parent d22b4ea8a8
commit f71f3899d1
2 changed files with 3 additions and 3 deletions

View File

@ -10203,8 +10203,10 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
scContainer = new nsStructuredCloneContainer();
JSContext *cx = aCx;
nsCxPusher pusher;
if (!cx) {
cx = nsContentUtils::GetContextFromDocument(document);
pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT);
}
rv = scContainer->InitFromVariant(aData, cx);

View File

@ -50,13 +50,11 @@ nsStructuredCloneContainer::InitFromVariant(nsIVariant *aData, JSContext *aCx)
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
// Make sure that we serialize in the right context.
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
JSAutoRequest ar(aCx);
JSAutoCompartment ac(aCx, JS_GetGlobalObject(aCx));
JS_WrapValue(aCx, &jsData);
nsCxPusher cxPusher;
cxPusher.Push(aCx, nsCxPusher::REQUIRE_SCRIPT_CONTEXT);
uint64_t* jsBytes = nullptr;
bool success = JS_WriteStructuredClone(aCx, jsData, &jsBytes, &mSize,
nullptr, nullptr, JSVAL_VOID);