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-26 11:04:10 -08:00
parent c6da4f2657
commit 6c8aaf6e25
2 changed files with 3 additions and 3 deletions

View File

@ -10199,8 +10199,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);