1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/browserElement_SetVisibleFrames2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* Any copyright is dedicated to the public domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Bug 762939 - Test that setting a <iframe mozbrowser> to invisible / visible 1.8 +// inside an invisible <iframe mozbrowser> doesn't trigger any events. 1.9 + 1.10 +"use strict"; 1.11 + 1.12 +SimpleTest.waitForExplicitFinish(); 1.13 +browserElementTestHelpers.setEnabledPref(true); 1.14 +browserElementTestHelpers.addPermission(); 1.15 + 1.16 +function runTest() { 1.17 + var principal = SpecialPowers.wrap(document).nodePrincipal; 1.18 + SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec, 1.19 + appId: principal.appId, 1.20 + isInBrowserElement: true }); 1.21 + 1.22 + var iframe = document.createElement('iframe'); 1.23 + SpecialPowers.wrap(iframe).mozbrowser = true; 1.24 + 1.25 + // We need remote = false here until bug 761935 is fixed; see 1.26 + // SetVisibleFrames.js for an explanation. 1.27 + iframe.remote = false; 1.28 + 1.29 + iframe.addEventListener('mozbrowserloadend', function loadEnd(e) { 1.30 + iframe.removeEventListener('mozbrowserloadend', loadEnd); 1.31 + iframe.setVisible(false); 1.32 + iframe.src = 'file_browserElement_SetVisibleFrames2_Outer.html'; 1.33 + }); 1.34 + 1.35 + iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { 1.36 + if (e.detail.message == 'parent:finish') { 1.37 + ok(true, "Got parent:finish"); 1.38 + 1.39 + // Give any extra events a chance to fire, then end the test. 1.40 + SimpleTest.executeSoon(function() { 1.41 + SimpleTest.executeSoon(function() { 1.42 + SimpleTest.executeSoon(function() { 1.43 + SimpleTest.executeSoon(function() { 1.44 + SimpleTest.executeSoon(function() { 1.45 + finish(); 1.46 + }); 1.47 + }); 1.48 + }); 1.49 + }); 1.50 + }); 1.51 + } 1.52 + else { 1.53 + ok(false, "Got unexpected message: " + e.detail.message); 1.54 + } 1.55 + }); 1.56 + 1.57 + document.body.appendChild(iframe); 1.58 +} 1.59 + 1.60 +function finish() { 1.61 + var principal = SpecialPowers.wrap(document).nodePrincipal; 1.62 + SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec, 1.63 + appId: principal.appId, 1.64 + isInBrowserElement: true }); 1.65 + 1.66 + SimpleTest.finish(); 1.67 +} 1.68 + 1.69 +addEventListener('testready', runTest);