From d309e30f04aa520923b92ae1aa7d5ef5fb9cbcc6 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 3 Oct 2012 21:59:41 -0400 Subject: [PATCH] Backout 99caa1f41fe1 (bug 797515) and a04b83c53297 (bug 789392) for M2 orange. --- dom/base/nsGlobalWindow.cpp | 7 +- dom/browser-element/mochitest/Makefile.in | 4 -- .../mochitest/browserElement_CloseApp.js | 66 ------------------- .../file_browserElement_CloseApp.html | 12 ---- .../test_browserElement_inproc_CloseApp.html | 13 ---- .../test_browserElement_oop_CloseApp.html | 13 ---- dom/ipc/ContentParent.cpp | 6 +- testing/mochitest/android.json | 1 - 8 files changed, 4 insertions(+), 118 deletions(-) delete mode 100644 dom/browser-element/mochitest/browserElement_CloseApp.js delete mode 100644 dom/browser-element/mochitest/file_browserElement_CloseApp.html delete mode 100644 dom/browser-element/mochitest/test_browserElement_inproc_CloseApp.html delete mode 100644 dom/browser-element/mochitest/test_browserElement_oop_CloseApp.html diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index c2d8d51b2cb..13df49e27e8 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6548,10 +6548,9 @@ nsGlobalWindow::Close() return NS_OK; } - // Don't allow scripts from content to close non-app windows that were not - // opened by script. - if (!mDocShell->GetIsApp() && - !mHadOriginalOpener && !nsContentUtils::IsCallerTrustedForWrite()) { + // Don't allow scripts from content to close windows + // that were not opened by script + if (!mHadOriginalOpener && !nsContentUtils::IsCallerTrustedForWrite()) { bool allowClose = Preferences::GetBool("dom.allow_scripts_to_close_windows", true); if (!allowClose) { diff --git a/dom/browser-element/mochitest/Makefile.in b/dom/browser-element/mochitest/Makefile.in index 500b91aa8bf..9872ee6ee2f 100644 --- a/dom/browser-element/mochitest/Makefile.in +++ b/dom/browser-element/mochitest/Makefile.in @@ -93,9 +93,6 @@ MOCHITEST_FILES = \ browserElement_CloseFromOpener.js \ test_browserElement_inproc_CloseFromOpener.html \ file_browserElement_CloseFromOpener.html \ - browserElement_CloseApp.js \ - test_browserElement_inproc_CloseApp.html \ - file_browserElement_CloseApp.html \ browserElement_OpenWindow.js \ test_browserElement_inproc_OpenWindow.html \ file_browserElement_Open1.html \ @@ -184,7 +181,6 @@ MOCHITEST_FILES += \ test_browserElement_oop_PromptConfirm.html \ test_browserElement_oop_Close.html \ test_browserElement_oop_CloseFromOpener.html \ - test_browserElement_oop_CloseApp.html \ test_browserElement_oop_OpenWindow.html \ test_browserElement_oop_OpenWindowInFrame.html \ test_browserElement_oop_OpenWindowRejected.html \ diff --git a/dom/browser-element/mochitest/browserElement_CloseApp.js b/dom/browser-element/mochitest/browserElement_CloseApp.js deleted file mode 100644 index becc2756360..00000000000 --- a/dom/browser-element/mochitest/browserElement_CloseApp.js +++ /dev/null @@ -1,66 +0,0 @@ -/* Any copyright is dedicated to the public domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Bug 789392 - Test that apps frames can trigger mozbrowserclose by calling -// window.close(), but browser frames cannot. -"use strict"; - -SimpleTest.waitForExplicitFinish(); - -function runTest() { - browserElementTestHelpers.setEnabledPref(true); - browserElementTestHelpers.addPermission(); - - // Our app frame and browser frame load the same content. That content calls - // window.close() and then alert(). We should get a mozbrowserclose event on - // the app frame before the mozbrowsershowmodalprompt, but not on the browser - // frame. - - var appFrame = document.createElement('iframe'); - appFrame.mozbrowser = true; - appFrame.setAttribute('mozapp', 'http://example.org/manifest.webapp'); - - var browserFrame = document.createElement('iframe'); - browserFrame.mozbrowser = true; - - var gotAppFrameClose = false; - appFrame.addEventListener('mozbrowserclose', function() { - ok(true, "Got close from app frame."); - gotAppFrameClose = true; - }); - - var gotAppFrameAlert = false; - appFrame.addEventListener('mozbrowsershowmodalprompt', function() { - ok(gotAppFrameClose, "Should have gotten app frame close by now."); - ok(!gotAppFrameAlert, "Just one alert from the app frame."); - gotAppFrameAlert = true; - if (gotBrowserFrameAlert && gotAppFrameAlert) { - SimpleTest.finish(); - } - }); - - browserFrame.addEventListener('mozbrowserclose', function() { - ok(false, "Got close from browser frame."); - }); - - var gotBrowserFrameAlert = false; - browserFrame.addEventListener('mozbrowsershowmodalprompt', function() { - ok(!gotBrowserFrameAlert, "Just one browser frame alert."); - gotBrowserFrameAlert = true; - if (gotBrowserFrameAlert && gotAppFrameAlert) { - SimpleTest.finish(); - } - }); - - document.body.appendChild(appFrame); - document.body.appendChild(browserFrame); - - appFrame.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_CloseApp.html'; - browserFrame.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_CloseApp.html'; -} - -// The test harness sets dom.allow_scripts_to_close_windows to true (as of -// writing, anyway). But that means that browser tabs can close themselves, -// which is what we want to test /can't/ happen! For the purposes of this -// test (and normal browser operation), this pref should be false. -SpecialPowers.pushPrefEnv({'set': [['dom.allow_scripts_to_close_windows', false]]}, runTest); diff --git a/dom/browser-element/mochitest/file_browserElement_CloseApp.html b/dom/browser-element/mochitest/file_browserElement_CloseApp.html deleted file mode 100644 index 091183aa6fc..00000000000 --- a/dom/browser-element/mochitest/file_browserElement_CloseApp.html +++ /dev/null @@ -1,12 +0,0 @@ - - - -file_browserElement_CloseApp.html - - - - - diff --git a/dom/browser-element/mochitest/test_browserElement_inproc_CloseApp.html b/dom/browser-element/mochitest/test_browserElement_inproc_CloseApp.html deleted file mode 100644 index 67acc9dbbb8..00000000000 --- a/dom/browser-element/mochitest/test_browserElement_inproc_CloseApp.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Test for Bug 789392 - - - - - - - - \ No newline at end of file diff --git a/dom/browser-element/mochitest/test_browserElement_oop_CloseApp.html b/dom/browser-element/mochitest/test_browserElement_oop_CloseApp.html deleted file mode 100644 index 67acc9dbbb8..00000000000 --- a/dom/browser-element/mochitest/test_browserElement_oop_CloseApp.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Test for Bug 789392 - - - - - - - - \ No newline at end of file diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index da9989ef6da..13c4415cfcf 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -774,12 +774,8 @@ ContentParent::~ContentParent() MOZ_ASSERT(!gNonAppContentParents || !gNonAppContentParents->Contains(this)); } else { - // In general, we expect gAppContentParents->Get(mAppManifestURL) to be - // NULL. But it could be that we created another ContentParent for this - // app after we did this->ActorDestroy(), so the right check is that - // gAppContentParent->Get(mAppManifestURL) != this. MOZ_ASSERT(!gAppContentParents || - gAppContentParents->Get(mAppManifestURL) != this); + !gAppContentParents->Get(mAppManifestURL)); } } diff --git a/testing/mochitest/android.json b/testing/mochitest/android.json index 91d5f82f0ae..f6d1cd33a0b 100644 --- a/testing/mochitest/android.json +++ b/testing/mochitest/android.json @@ -130,7 +130,6 @@ "dom/browser-element/mochitest/test_browserElement_inproc_AppFramePermission.html": "", "dom/browser-element/mochitest/test_browserElement_inproc_AppWindowNamespace.html": "TIMED_OUT, bug 783509", "dom/browser-element/mochitest/test_browserElement_inproc_SecurityChange.html": "TIMED_OUT, bug 766586", - "dom/browser-element/mochitest/test_browserElement_inproc_CloseApp.html": "FAILS, bug 796982", "dom/devicestorage": "bug 781789 & bug 782275", "dom/imptests/editing/conformancetest/test_event.html": "", "dom/imptests/editing/conformancetest/test_runtest.html": "",