michael@0: /* Any copyright is dedicated to the public domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Bug 777384 - Test mozapp permission. michael@0: "use strict"; michael@0: michael@0: SimpleTest.waitForExplicitFinish(); michael@0: browserElementTestHelpers.setEnabledPref(true); michael@0: browserElementTestHelpers.addPermission(); michael@0: michael@0: SpecialPowers.setAllAppsLaunchable(true); michael@0: michael@0: function testAppElement(expectAnApp, callback) { michael@0: var iframe = document.createElement('iframe'); michael@0: SpecialPowers.wrap(iframe).mozbrowser = true; michael@0: iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp'); michael@0: iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { michael@0: is(e.detail.message == 'app', expectAnApp, e.detail.message); michael@0: SimpleTest.executeSoon(callback); michael@0: }); michael@0: document.body.appendChild(iframe); michael@0: iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html'; michael@0: } michael@0: michael@0: function runTest() { michael@0: SpecialPowers.addPermission("embed-apps", true, document); michael@0: testAppElement(true, function() { michael@0: SpecialPowers.removePermission("embed-apps", document); michael@0: testAppElement(false, function() { michael@0: SimpleTest.finish(); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: addEventListener('testready', runTest);