diff --git a/caps/tests/mochitest/test_principal_extendedorigin_appid_appstatus.html b/caps/tests/mochitest/test_principal_extendedorigin_appid_appstatus.html index 92d49a231ede..ad50157e8080 100644 --- a/caps/tests/mochitest/test_principal_extendedorigin_appid_appstatus.html +++ b/caps/tests/mochitest/test_principal_extendedorigin_appid_appstatus.html @@ -364,6 +364,7 @@ function checkIFrame(aFrame, data) { checkedCount++; if (checkedCount == checksTodo) { SpecialPowers.removePermission("browser", "http://example.org"); + SpecialPowers.removePermission("embed-apps", "http://example.org"); SimpleTest.finish(); } else { gTestRunner.next(); @@ -389,6 +390,7 @@ function runTest() { }; iframe.addChild = function() { SpecialPowers.addPermission("browser", true, iframe.contentDocument); + SpecialPowers.addPermission("embed-apps", true, iframe.contentDocument); var childFrame = document.createElement('iframe'); diff --git a/content/base/test/test_child_process_shutdown_message.html b/content/base/test/test_child_process_shutdown_message.html index eb80b5727b94..40d5c7f6bea2 100644 --- a/content/base/test/test_child_process_shutdown_message.html +++ b/content/base/test/test_child_process_shutdown_message.html @@ -111,6 +111,7 @@ function setUp() { SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true); SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", true); SpecialPowers.addPermission("browser", true, window.document); + SpecialPowers.addPermission("embed-apps", true, window.document); runNextTest(); } diff --git a/content/base/test/test_messagemanager_assertpermission.html b/content/base/test/test_messagemanager_assertpermission.html index 022b5fed2f14..9a00da1a2a7f 100644 --- a/content/base/test/test_messagemanager_assertpermission.html +++ b/content/base/test/test_messagemanager_assertpermission.html @@ -32,6 +32,7 @@ function setUp() { SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true); SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", true); SpecialPowers.addPermission("browser", true, window.document); + SpecialPowers.addPermission("embed-apps", true, window.document); let appId = gAppsService.getAppLocalIdByManifestURL(APP_MANIFEST); SpecialPowers.addPermission("foobar", true, { url: APP_URL, diff --git a/dom/browser-element/mochitest/Makefile.in b/dom/browser-element/mochitest/Makefile.in index 95d0d4021f9d..9872ee6ee2fd 100644 --- a/dom/browser-element/mochitest/Makefile.in +++ b/dom/browser-element/mochitest/Makefile.in @@ -115,13 +115,13 @@ MOCHITEST_FILES = \ file_browserElement_SecurityChange.html \ browserElement_BackForward.js \ test_browserElement_inproc_BackForward.html \ - file_bug741717.sjs \ + file_bug741717.sjs \ browserElement_Reload.js \ - file_bug709759.sjs \ + file_bug709759.sjs \ browserElement_Stop.js \ - test_browserElement_inproc_Stop.html \ - browserElement_ContextmenuEvents.js \ - test_browserElement_inproc_ContextmenuEvents.html \ + test_browserElement_inproc_Stop.html \ + browserElement_ContextmenuEvents.js \ + test_browserElement_inproc_ContextmenuEvents.html \ browserElement_SendEvent.js \ test_browserElement_inproc_SendEvent.html \ browserElement_ScrollEvent.js \ @@ -133,6 +133,9 @@ MOCHITEST_FILES = \ test_browserElement_inproc_RemoveBrowserElement.html \ browserElement_DOMRequestError.js \ test_browserElement_inproc_DOMRequestError.html \ + file_browserElement_AppFramePermission.html \ + browserElement_AppFramePermission.js \ + test_browserElement_inproc_AppFramePermission.html \ $(NULL) # Disabled due to https://bugzilla.mozilla.org/show_bug.cgi?id=774100 @@ -187,12 +190,13 @@ MOCHITEST_FILES += \ test_browserElement_oop_BackForward.html \ test_browserElement_oop_Reload.html \ test_browserElement_oop_Stop.html \ - test_browserElement_oop_ContextmenuEvents.html \ + test_browserElement_oop_ContextmenuEvents.html \ test_browserElement_oop_SendEvent.html \ test_browserElement_oop_ScrollEvent.html \ test_browserElement_oop_Auth.html \ test_browserElement_oop_RemoveBrowserElement.html \ test_browserElement_oop_DOMRequestError.html \ + test_browserElement_oop_AppFramePermission.html \ $(NULL) endif #} endif #} diff --git a/dom/browser-element/mochitest/browserElement_AppFramePermission.js b/dom/browser-element/mochitest/browserElement_AppFramePermission.js new file mode 100644 index 000000000000..c9ea2d65b95b --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_AppFramePermission.js @@ -0,0 +1,52 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Bug 777384 - Test mozapp permission. +"use strict"; + +SimpleTest.waitForExplicitFinish(); + +function makeAllAppsLaunchable() { + var Webapps = {}; + SpecialPowers.wrap(Components).utils.import("resource://gre/modules/Webapps.jsm", Webapps); + var appRegistry = SpecialPowers.wrap(Webapps.DOMApplicationRegistry); + + var originalValue = appRegistry.allAppsLaunchable; + appRegistry.allAppsLaunchable = true; + + // Clean up after ourselves once tests are done so the test page is unloaded. + window.addEventListener("unload", function restoreAllAppsLaunchable(event) { + if (event.target == window.document) { + window.removeEventListener("unload", restoreAllAppsLaunchable, false); + appRegistry.allAppsLaunchable = originalValue; + } + }, false); +} +makeAllAppsLaunchable(); + +function testAppElement(expectAnApp, callback) { + var iframe = document.createElement('iframe'); + iframe.mozbrowser = true; + iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp'); + iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { + is(e.detail.message == 'app', expectAnApp, e.detail.message); + SimpleTest.executeSoon(callback); + }); + document.body.appendChild(iframe); + iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html'; +} + +function runTest() { + browserElementTestHelpers.setEnabledPref(true); + browserElementTestHelpers.addPermission(); + + SpecialPowers.addPermission("embed-apps", true, document); + testAppElement(true, function() { + SpecialPowers.removePermission("embed-apps", document); + testAppElement(false, function() { + SimpleTest.finish(); + }); + }); +} + +runTest(); diff --git a/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js b/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js index 35e2df1b99f8..42ac3746ea09 100644 --- a/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js +++ b/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js @@ -9,6 +9,8 @@ SimpleTest.waitForExplicitFinish(); function runTest() { browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); + // Permission to embed an app. + SpecialPowers.addPermission("embed-apps", true, document); var iframe1 = document.createElement('iframe'); iframe1.mozbrowser = true; @@ -29,6 +31,7 @@ function runTest() { iframe2.addEventListener('mozbrowseropenwindow', function(e) { ok(true, "Got second mozbrowseropenwindow event."); + SpecialPowers.removePermission("embed-apps", document); SimpleTest.finish(); }); diff --git a/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html b/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html new file mode 100644 index 000000000000..32dd3b89171d --- /dev/null +++ b/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html @@ -0,0 +1,17 @@ + + + + + + + diff --git a/dom/browser-element/mochitest/test_browserElement_inproc_AppFramePermission.html b/dom/browser-element/mochitest/test_browserElement_inproc_AppFramePermission.html new file mode 100644 index 000000000000..eff2d5751f84 --- /dev/null +++ b/dom/browser-element/mochitest/test_browserElement_inproc_AppFramePermission.html @@ -0,0 +1,13 @@ + + + + Test for Bug 777384 + + + + + + + + diff --git a/dom/browser-element/mochitest/test_browserElement_oop_AppFramePermission.html b/dom/browser-element/mochitest/test_browserElement_oop_AppFramePermission.html new file mode 100644 index 000000000000..eff2d5751f84 --- /dev/null +++ b/dom/browser-element/mochitest/test_browserElement_oop_AppFramePermission.html @@ -0,0 +1,13 @@ + + + + Test for Bug 777384 + + + + + + + + diff --git a/dom/tests/mochitest/localstorage/test_appIsolation.html b/dom/tests/mochitest/localstorage/test_appIsolation.html index 8f31eb44af2c..a6b839e1de3a 100644 --- a/dom/tests/mochitest/localstorage/test_appIsolation.html +++ b/dom/tests/mochitest/localstorage/test_appIsolation.html @@ -25,6 +25,7 @@ try { SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true); SpecialPowers.addPermission("browser", true, window.document); +SpecialPowers.addPermission("embed-apps", true, window.document); var gData = [ // APP 1 @@ -107,6 +108,7 @@ function runTest() localStorage.clear(); SpecialPowers.removePermission("browser", window.document); + SpecialPowers.removePermission("embed-apps", window.document); if (previousPrefs.mozBrowserFramesEnabled !== undefined) { SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', previousPrefs.mozBrowserFramesEnabled); diff --git a/dom/tests/mochitest/webapps/file_bug_779982.js b/dom/tests/mochitest/webapps/file_bug_779982.js index 0091a656fa71..cef1fa57fc5e 100644 --- a/dom/tests/mochitest/webapps/file_bug_779982.js +++ b/dom/tests/mochitest/webapps/file_bug_779982.js @@ -34,6 +34,7 @@ try { SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true); SpecialPowers.addPermission("browser", true, window.document); +SpecialPowers.addPermission("embed-apps", true, window.document); var gData = [ // APP 1 @@ -105,6 +106,7 @@ function runTest() { } SpecialPowers.removePermission("browser", window.document); + SpecialPowers.removePermission("embed-apps", window.document); SimpleTest.finish(); } else { diff --git a/testing/mochitest/android.json b/testing/mochitest/android.json index bdbb5462d12c..f6d1cd33a0b2 100644 --- a/testing/mochitest/android.json +++ b/testing/mochitest/android.json @@ -127,6 +127,7 @@ "docshell/test/test_bug637644.html": "", "docshell/test/test_bug668513.html": "RANDOM", "dom/browser-element/mochitest/test_browserElement_oop_SecurityChange.html": "TIMED_OUT, bug 766586", + "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/devicestorage": "bug 781789 & bug 782275",