|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Bug 742944 - Do window.open from inside <iframe mozbrowser>. But then |
|
5 // reject the call. This shouldn't cause problems (crashes, leaks). |
|
6 // |
|
7 // This is the same as OpenWindowRejected, except we "reject" the popup by not |
|
8 // adding the iframe element to our DOM, instead of by not calling |
|
9 // preventDefault() on the event. |
|
10 |
|
11 "use strict"; |
|
12 SimpleTest.waitForExplicitFinish(); |
|
13 browserElementTestHelpers.setEnabledPref(true); |
|
14 browserElementTestHelpers.addPermission(); |
|
15 |
|
16 function runTest() { |
|
17 var iframe = document.createElement('iframe'); |
|
18 SpecialPowers.wrap(iframe).mozbrowser = true; |
|
19 |
|
20 iframe.addEventListener('mozbrowseropenwindow', function(e) { |
|
21 ok(e.detail.url.indexOf('does_not_exist.html') != -1, |
|
22 'Opened URL; got ' + e.detail.url); |
|
23 is(e.detail.name, ''); |
|
24 is(e.detail.features, ''); |
|
25 |
|
26 // Call preventDefault, but don't add the iframe to the DOM. This still |
|
27 // amounts to rejecting the popup. |
|
28 e.preventDefault(); |
|
29 }); |
|
30 |
|
31 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { |
|
32 var msg = e.detail.message; |
|
33 if (msg.indexOf('success:') == 0) { |
|
34 ok(true, msg); |
|
35 } |
|
36 else if (msg == 'finish') { |
|
37 SimpleTest.finish(); |
|
38 } |
|
39 else { |
|
40 ok(false, msg); |
|
41 } |
|
42 }); |
|
43 |
|
44 iframe.src = 'file_browserElement_OpenWindowRejected.html'; |
|
45 } |
|
46 |
|
47 addEventListener('testready', runTest); |