Skip to content

Commit

Permalink
Fix EmbedLiteAppService to use nsPIDOMWindow
Browse files Browse the repository at this point in the history
This also fixes entering and leaving from secure JS context.
  • Loading branch information
rainemak committed Dec 19, 2016
1 parent e8fa989 commit b274d7e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions embedding/embedlite/modules/EmbedLiteAppService.cpp
Expand Up @@ -122,17 +122,18 @@ NS_IMETHODIMP
EmbedLiteAppService::GetIDByWindow(nsIDOMWindow* aWin, uint32_t* aId)
{
dom::AutoJSAPI jsapiChromeGuard;
nsCOMPtr<nsIDOMWindow> window;
nsCOMPtr<nsIWebNavigation> navNav(do_GetInterface(aWin));
nsCOMPtr<nsIDocShellTreeItem> navItem(do_QueryInterface(navNav));
NS_ENSURE_TRUE(navItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
navItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin(do_GetInterface(rootItem));
NS_ENSURE_TRUE(rootWin, NS_ERROR_FAILURE);
rootWin->GetTop(getter_AddRefs(window));

nsCOMPtr<nsPIDOMWindow> pwindow(do_QueryInterface(rootWin));
nsCOMPtr<nsPIDOMWindow> outerWindow = pwindow->GetTop();
mozilla::dom::AutoNoJSAPI nojsapi;
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window);
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(outerWindow);
uint64_t OuterWindowID = 0;
utils->GetOuterWindowID(&OuterWindowID);
*aId = mIDMap[OuterWindowID];
Expand Down Expand Up @@ -232,7 +233,7 @@ NS_IMETHODIMP EmbedLiteAppService::EnterSecureJSContext()
MOZ_CRASH();
}

if (!xpc::PushJSContextNoScriptContext(nullptr)) {
if (!xpc::PushNullJSContext()) {
MOZ_CRASH();
}

Expand All @@ -247,8 +248,7 @@ NS_IMETHODIMP EmbedLiteAppService::LeaveSecureJSContext()
return NS_ERROR_FAILURE;
}

DebugOnly<JSContext*> stackTop;
xpc::PopJSContextNoScriptContext();
xpc::PopNullJSContext();
mPushedSomething--;
return NS_OK;
}
Expand Down

0 comments on commit b274d7e

Please sign in to comment.