|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Bug 804446 - Test that window.open(javascript:..) works with <iframe mozbrowser>. |
|
5 |
|
6 "use strict"; |
|
7 SimpleTest.waitForExplicitFinish(); |
|
8 browserElementTestHelpers.setEnabledPref(true); |
|
9 browserElementTestHelpers.addPermission(); |
|
10 |
|
11 function runTest() { |
|
12 var iframeJS = document.createElement('iframe'); |
|
13 SpecialPowers.wrap(iframeJS).mozbrowser = true; |
|
14 |
|
15 iframeJS.addEventListener('mozbrowserloadstart', function(e) { |
|
16 ok(false, "This should not happen!"); |
|
17 }); |
|
18 |
|
19 iframeJS.addEventListener('mozbrowserloadend', function(e) { |
|
20 ok(false, "This should not happen!"); |
|
21 }); |
|
22 |
|
23 iframeJS.src = 'javascript:alert("Foo");'; |
|
24 document.body.appendChild(iframeJS); |
|
25 |
|
26 var iframe = document.createElement('iframe'); |
|
27 SpecialPowers.wrap(iframe).mozbrowser = true; |
|
28 |
|
29 var gotPopup = false; |
|
30 iframe.addEventListener('mozbrowseropenwindow', function(e) { |
|
31 is(gotPopup, false, 'Should get just one popup.'); |
|
32 gotPopup = true; |
|
33 |
|
34 document.body.appendChild(e.detail.frameElement); |
|
35 }); |
|
36 |
|
37 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { |
|
38 ok(gotPopup, 'Got mozbrowseropenwindow event before showmodalprompt event.'); |
|
39 if (e.detail.message.indexOf("success") == 0) { |
|
40 ok(true, e.detail.message); |
|
41 SimpleTest.finish(); |
|
42 } |
|
43 else { |
|
44 ok(false, "Got invalid message: " + e.detail.message); |
|
45 } |
|
46 }); |
|
47 |
|
48 iframe.src = 'file_browserElement_FrameWrongURI.html'; |
|
49 document.body.appendChild(iframe); |
|
50 } |
|
51 |
|
52 addEventListener('testready', runTest); |