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 // Test that the onmozbrowservisibilitychange event works.
5 'use strict';
7 SimpleTest.waitForExplicitFinish();
8 browserElementTestHelpers.setEnabledPref(true);
9 browserElementTestHelpers.addPermission();
11 var iframe1 = null;
12 function runTest() {
13 iframe1 = document.createElement('iframe');
14 SpecialPowers.wrap(iframe1).mozbrowser = true;
15 document.body.appendChild(iframe1);
17 iframe1.src = 'data:text/html,<html><head><title>Title</title></head><body></body></html>';
18 checkVisibilityFalse();
19 }
21 function checkVisibilityFalse() {
22 iframe1.addEventListener('mozbrowservisibilitychange', function onvisibilitychange(e) {
23 iframe1.removeEventListener(e.type, onvisibilitychange);
25 is(e.detail.visible, false, 'Visibility should be false');
26 checkVisibilityTrue();
27 });
29 iframe1.setVisible(false);
30 }
32 function checkVisibilityTrue() {
33 iframe1.addEventListener('mozbrowservisibilitychange', function onvisibilitychange(e) {
34 iframe1.removeEventListener(e.type, onvisibilitychange);
36 is(e.detail.visible, true, 'Visibility should be true');
37 SimpleTest.finish();
38 });
40 iframe1.setVisible(true);
41 }
43 addEventListener('testready', runTest);