Bug 1586793 - [Fission] iframe.contentWindow may be null when it shouldn't be, r=peterv

The other cases when ClearWindowProxy is called seem to be fine.
It is the Unlink case which was causing null .contentWindow with test_mozfiledataurl.html

Fixes bug 1580391 and backs out bug 1581004

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Olli Pettay 2019-10-17 14:56:54 +00:00
Родитель e3675b23cb
Коммит 49bb4a7105
3 изменённых файлов: 24 добавлений и 3 удалений

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

@ -307,6 +307,10 @@ class BrowsingContext : public nsWrapperCache, public BrowsingContextBase {
// Return the window proxy object that corresponds to this browsing context.
inline JSObject* GetWindowProxy() const { return mWindowProxy; }
inline JSObject* GetUnbarrieredWindowProxy() const {
return mWindowProxy.unbarrieredGet();
}
// Set the window proxy object that corresponds to this browsing context.
void SetWindowProxy(JS::Handle<JSObject*> aWindowProxy) {
mWindowProxy = aWindowProxy;

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

@ -1216,8 +1216,15 @@ nsGlobalWindowOuter::~nsGlobalWindowOuter() {
JSObject* proxy = GetWrapperMaybeDead();
if (proxy) {
if (mBrowsingContext) {
mBrowsingContext->ClearWindowProxy();
if (mBrowsingContext && mBrowsingContext->GetUnbarrieredWindowProxy()) {
nsGlobalWindowOuter* outer = nsOuterWindowProxy::GetOuterWindow(
mBrowsingContext->GetUnbarrieredWindowProxy());
// Check that the current WindowProxy object corresponds to this
// nsGlobalWindowOuter, because we don't want to clear the WindowProxy if
// we've replaced it with a cross-process WindowProxy.
if (outer == this) {
mBrowsingContext->ClearWindowProxy();
}
}
js::SetProxyReservedSlot(proxy, OUTER_WINDOW_SLOT,
js::PrivateValue(nullptr));
@ -1433,7 +1440,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowOuter)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocShell)
if (tmp->mBrowsingContext) {
tmp->mBrowsingContext->ClearWindowProxy();
if (tmp->mBrowsingContext->GetUnbarrieredWindowProxy()) {
nsGlobalWindowOuter* outer = nsOuterWindowProxy::GetOuterWindow(
tmp->mBrowsingContext->GetUnbarrieredWindowProxy());
// Check that the current WindowProxy object corresponds to this
// nsGlobalWindowOuter, because we don't want to clear the WindowProxy if
// we've replaced it with a cross-process WindowProxy.
if (outer == tmp) {
tmp->mBrowsingContext->ClearWindowProxy();
}
}
tmp->mBrowsingContext = nullptr;
}

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

@ -58,6 +58,7 @@ function start() {
};
SimpleTest.waitForExplicitFinish();
SimpleTest.expectAssertions(0, 3);
function* runTest([imgFile, audioFile, docFile, xhrFile]) {
inner = document.getElementById('inner');