|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Bug 777384 - Test mozapp permission. |
|
5 "use strict"; |
|
6 |
|
7 SimpleTest.waitForExplicitFinish(); |
|
8 browserElementTestHelpers.setEnabledPref(true); |
|
9 browserElementTestHelpers.addPermission(); |
|
10 |
|
11 SpecialPowers.setAllAppsLaunchable(true); |
|
12 |
|
13 function testAppElement(expectAnApp, callback) { |
|
14 var iframe = document.createElement('iframe'); |
|
15 SpecialPowers.wrap(iframe).mozbrowser = true; |
|
16 iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp'); |
|
17 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { |
|
18 is(e.detail.message == 'app', expectAnApp, e.detail.message); |
|
19 SimpleTest.executeSoon(callback); |
|
20 }); |
|
21 document.body.appendChild(iframe); |
|
22 iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html'; |
|
23 } |
|
24 |
|
25 function runTest() { |
|
26 SpecialPowers.addPermission("embed-apps", true, document); |
|
27 testAppElement(true, function() { |
|
28 SpecialPowers.removePermission("embed-apps", document); |
|
29 testAppElement(false, function() { |
|
30 SimpleTest.finish(); |
|
31 }); |
|
32 }); |
|
33 } |
|
34 |
|
35 addEventListener('testready', runTest); |