1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/browserElement_AppFramePermission.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +/* Any copyright is dedicated to the public domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Bug 777384 - Test mozapp permission. 1.8 +"use strict"; 1.9 + 1.10 +SimpleTest.waitForExplicitFinish(); 1.11 +browserElementTestHelpers.setEnabledPref(true); 1.12 +browserElementTestHelpers.addPermission(); 1.13 + 1.14 +SpecialPowers.setAllAppsLaunchable(true); 1.15 + 1.16 +function testAppElement(expectAnApp, callback) { 1.17 + var iframe = document.createElement('iframe'); 1.18 + SpecialPowers.wrap(iframe).mozbrowser = true; 1.19 + iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp'); 1.20 + iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { 1.21 + is(e.detail.message == 'app', expectAnApp, e.detail.message); 1.22 + SimpleTest.executeSoon(callback); 1.23 + }); 1.24 + document.body.appendChild(iframe); 1.25 + iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html'; 1.26 +} 1.27 + 1.28 +function runTest() { 1.29 + SpecialPowers.addPermission("embed-apps", true, document); 1.30 + testAppElement(true, function() { 1.31 + SpecialPowers.removePermission("embed-apps", document); 1.32 + testAppElement(false, function() { 1.33 + SimpleTest.finish(); 1.34 + }); 1.35 + }); 1.36 +} 1.37 + 1.38 +addEventListener('testready', runTest);