1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/browserElement_OpenWindowRejected2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* Any copyright is dedicated to the public domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Bug 742944 - Do window.open from inside <iframe mozbrowser>. But then 1.8 +// reject the call. This shouldn't cause problems (crashes, leaks). 1.9 +// 1.10 +// This is the same as OpenWindowRejected, except we "reject" the popup by not 1.11 +// adding the iframe element to our DOM, instead of by not calling 1.12 +// preventDefault() on the event. 1.13 + 1.14 +"use strict"; 1.15 +SimpleTest.waitForExplicitFinish(); 1.16 +browserElementTestHelpers.setEnabledPref(true); 1.17 +browserElementTestHelpers.addPermission(); 1.18 + 1.19 +function runTest() { 1.20 + var iframe = document.createElement('iframe'); 1.21 + SpecialPowers.wrap(iframe).mozbrowser = true; 1.22 + 1.23 + iframe.addEventListener('mozbrowseropenwindow', function(e) { 1.24 + ok(e.detail.url.indexOf('does_not_exist.html') != -1, 1.25 + 'Opened URL; got ' + e.detail.url); 1.26 + is(e.detail.name, ''); 1.27 + is(e.detail.features, ''); 1.28 + 1.29 + // Call preventDefault, but don't add the iframe to the DOM. This still 1.30 + // amounts to rejecting the popup. 1.31 + e.preventDefault(); 1.32 + }); 1.33 + 1.34 + iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { 1.35 + var msg = e.detail.message; 1.36 + if (msg.indexOf('success:') == 0) { 1.37 + ok(true, msg); 1.38 + } 1.39 + else if (msg == 'finish') { 1.40 + SimpleTest.finish(); 1.41 + } 1.42 + else { 1.43 + ok(false, msg); 1.44 + } 1.45 + }); 1.46 + 1.47 + iframe.src = 'file_browserElement_OpenWindowRejected.html'; 1.48 +} 1.49 + 1.50 +addEventListener('testready', runTest);