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 @@ + + + +