Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 /* Any copyright is dedicated to the public domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Bug 742944 - Do window.open from inside <iframe mozbrowser>. But then
5 // reject the call. This shouldn't cause problems (crashes, leaks).
7 "use strict";
8 SimpleTest.waitForExplicitFinish();
9 browserElementTestHelpers.setEnabledPref(true);
10 browserElementTestHelpers.addPermission();
12 function runTest() {
13 var iframe = document.createElement('iframe');
14 SpecialPowers.wrap(iframe).mozbrowser = true;
16 iframe.addEventListener('mozbrowseropenwindow', function(e) {
17 ok(e.detail.url.indexOf('does_not_exist.html') != -1,
18 'Opened URL; got ' + e.detail.url);
19 is(e.detail.name, '');
20 is(e.detail.features, '');
22 // Don't add e.detail.frameElement to the DOM, so the window.open is
23 // effectively blocked.
24 e.preventDefault();
25 });
27 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
28 var msg = e.detail.message;
29 if (msg.indexOf('success:') == 0) {
30 ok(true, msg);
31 }
32 else if (msg == 'finish') {
33 SimpleTest.finish();
34 }
35 else {
36 ok(false, msg);
37 }
38 });
40 iframe.src = 'file_browserElement_OpenWindowRejected.html';
41 document.body.appendChild(iframe);
42 }
44 addEventListener('testready', runTest);