Bug 1586750, don't compile event handlers on unloaded windows r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D48983

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Olli Pettay 2019-10-28 21:08:50 +00:00
Родитель f7b811213d
Коммит 574f798fb3
4 изменённых файлов: 12 добавлений и 16 удалений

Просмотреть файл

@ -1474,6 +1474,8 @@ nsresult nsGlobalWindowOuter::EnsureScriptEnvironment() {
return NS_OK;
}
NS_ENSURE_STATE(!mCleanedUp);
NS_ASSERTION(!GetCurrentInnerWindowInternal(),
"No cached wrapper, but we have an inner window?");
NS_ASSERTION(!mContext, "Will overwrite mContext!");

Просмотреть файл

@ -1717,29 +1717,25 @@ already_AddRefed<nsIScriptGlobalObject>
EventListenerManager::GetScriptGlobalAndDocument(Document** aDoc) {
nsCOMPtr<nsINode> node(do_QueryInterface(mTarget));
nsCOMPtr<Document> doc;
nsCOMPtr<nsIScriptGlobalObject> global;
nsCOMPtr<nsPIDOMWindowInner> win;
if (node) {
// Try to get context from doc
// XXX sXBL/XBL2 issue -- do we really want the owner here? What
// if that's the XBL document?
doc = node->OwnerDoc();
if (doc->IsLoadedAsData()) {
return nullptr;
}
// We want to allow compiling an event handler even in an unloaded
// document, so use GetScopeObject here, not GetScriptHandlingObject.
global = do_QueryInterface(doc->GetScopeObject());
} else {
if (nsCOMPtr<nsPIDOMWindowInner> win = GetTargetAsInnerWindow()) {
doc = win->GetExtantDoc();
global = do_QueryInterface(win);
} else {
global = do_QueryInterface(mTarget);
}
win = do_QueryInterface(doc->GetScopeObject());
} else if ((win = GetTargetAsInnerWindow())) {
doc = win->GetExtantDoc();
}
if (!win || !win->IsCurrentInnerWindow()) {
return nullptr;
}
doc.forget(aDoc);
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(win);
return global.forget();
}

Просмотреть файл

@ -123,7 +123,6 @@ skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
[test_bug741666.html]
[test_deviceSensor.html]
[test_bug812744.html]
skip-if = fission && debug # Failed assertion: No cached wrapper, but we have an inner window?: '!GetCurrentInnerWindowInternal()', file /builds/worker/workspace/build/src/dom/base/nsGlobalWindowOuter.cpp, line 1474
[test_bug822898.html]
[test_bug855741.html]
[test_bug864040.html]

Просмотреть файл

@ -26,8 +26,7 @@ addLoadEvent(function() {
var el = f.contentDocument.documentElement;
f.onload = function() {
el.setAttribute("onmouseleave", "(void 0)");
is(el.onmouseleave.toString(), "function onmouseleave(event) {\n(void 0)\n}",
"Should have a function here");
is(el.onmouseleave, null, "Should not have a function here");
SimpleTest.finish();
};
f.src = "http://www.example.com/"