dom/browser-element/mochitest/browserElement_SetVisibleFrames2.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* Any copyright is dedicated to the public domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 // Bug 762939 - Test that setting a <iframe mozbrowser> to invisible / visible
michael@0 5 // inside an invisible <iframe mozbrowser> doesn't trigger any events.
michael@0 6
michael@0 7 "use strict";
michael@0 8
michael@0 9 SimpleTest.waitForExplicitFinish();
michael@0 10 browserElementTestHelpers.setEnabledPref(true);
michael@0 11 browserElementTestHelpers.addPermission();
michael@0 12
michael@0 13 function runTest() {
michael@0 14 var principal = SpecialPowers.wrap(document).nodePrincipal;
michael@0 15 SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
michael@0 16 appId: principal.appId,
michael@0 17 isInBrowserElement: true });
michael@0 18
michael@0 19 var iframe = document.createElement('iframe');
michael@0 20 SpecialPowers.wrap(iframe).mozbrowser = true;
michael@0 21
michael@0 22 // We need remote = false here until bug 761935 is fixed; see
michael@0 23 // SetVisibleFrames.js for an explanation.
michael@0 24 iframe.remote = false;
michael@0 25
michael@0 26 iframe.addEventListener('mozbrowserloadend', function loadEnd(e) {
michael@0 27 iframe.removeEventListener('mozbrowserloadend', loadEnd);
michael@0 28 iframe.setVisible(false);
michael@0 29 iframe.src = 'file_browserElement_SetVisibleFrames2_Outer.html';
michael@0 30 });
michael@0 31
michael@0 32 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
michael@0 33 if (e.detail.message == 'parent:finish') {
michael@0 34 ok(true, "Got parent:finish");
michael@0 35
michael@0 36 // Give any extra events a chance to fire, then end the test.
michael@0 37 SimpleTest.executeSoon(function() {
michael@0 38 SimpleTest.executeSoon(function() {
michael@0 39 SimpleTest.executeSoon(function() {
michael@0 40 SimpleTest.executeSoon(function() {
michael@0 41 SimpleTest.executeSoon(function() {
michael@0 42 finish();
michael@0 43 });
michael@0 44 });
michael@0 45 });
michael@0 46 });
michael@0 47 });
michael@0 48 }
michael@0 49 else {
michael@0 50 ok(false, "Got unexpected message: " + e.detail.message);
michael@0 51 }
michael@0 52 });
michael@0 53
michael@0 54 document.body.appendChild(iframe);
michael@0 55 }
michael@0 56
michael@0 57 function finish() {
michael@0 58 var principal = SpecialPowers.wrap(document).nodePrincipal;
michael@0 59 SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
michael@0 60 appId: principal.appId,
michael@0 61 isInBrowserElement: true });
michael@0 62
michael@0 63 SimpleTest.finish();
michael@0 64 }
michael@0 65
michael@0 66 addEventListener('testready', runTest);

mercurial