|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Bug 780351 - Test that mozapp divides the window name namespace. |
|
5 "use strict"; |
|
6 |
|
7 SimpleTest.waitForExplicitFinish(); |
|
8 browserElementTestHelpers.setEnabledPref(true); |
|
9 browserElementTestHelpers.addPermission(); |
|
10 // Permission to embed an app. |
|
11 SpecialPowers.addPermission("embed-apps", true, document); |
|
12 |
|
13 function runTest() { |
|
14 |
|
15 var iframe1 = document.createElement('iframe'); |
|
16 SpecialPowers.wrap(iframe1).mozbrowser = true; |
|
17 iframe1.setAttribute('mozapp', 'http://example.org/manifest.webapp'); |
|
18 |
|
19 // Two mozapp frames for different apps with the same code both do the same |
|
20 // window.open("foo", "bar") call. We should get two mozbrowseropenwindow |
|
21 // events. |
|
22 |
|
23 iframe1.addEventListener('mozbrowseropenwindow', function(e) { |
|
24 ok(true, "Got first mozbrowseropenwindow event."); |
|
25 document.body.appendChild(e.detail.frameElement); |
|
26 |
|
27 SimpleTest.executeSoon(function() { |
|
28 var iframe2 = document.createElement('iframe'); |
|
29 SpecialPowers.wrap(iframe2).mozbrowser = true; |
|
30 iframe2.setAttribute('mozapp', 'http://example.com/manifest.webapp'); |
|
31 |
|
32 iframe2.addEventListener('mozbrowseropenwindow', function(e) { |
|
33 ok(true, "Got second mozbrowseropenwindow event."); |
|
34 SpecialPowers.removePermission("embed-apps", document); |
|
35 |
|
36 // We're not going to open this, but we don't want the platform to either |
|
37 e.preventDefault(); |
|
38 SimpleTest.finish(); |
|
39 }); |
|
40 |
|
41 document.body.appendChild(iframe2); |
|
42 iframe2.src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html'; |
|
43 }); |
|
44 }); |
|
45 |
|
46 document.body.appendChild(iframe1); |
|
47 iframe1.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html'; |
|
48 } |
|
49 |
|
50 addEventListener('testready', runTest); |