|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Test that the onmozbrowservisibilitychange event works. |
|
5 'use strict'; |
|
6 |
|
7 SimpleTest.waitForExplicitFinish(); |
|
8 browserElementTestHelpers.setEnabledPref(true); |
|
9 browserElementTestHelpers.addPermission(); |
|
10 |
|
11 var iframe1 = null; |
|
12 function runTest() { |
|
13 iframe1 = document.createElement('iframe'); |
|
14 SpecialPowers.wrap(iframe1).mozbrowser = true; |
|
15 document.body.appendChild(iframe1); |
|
16 |
|
17 iframe1.src = 'data:text/html,<html><head><title>Title</title></head><body></body></html>'; |
|
18 checkVisibilityFalse(); |
|
19 } |
|
20 |
|
21 function checkVisibilityFalse() { |
|
22 iframe1.addEventListener('mozbrowservisibilitychange', function onvisibilitychange(e) { |
|
23 iframe1.removeEventListener(e.type, onvisibilitychange); |
|
24 |
|
25 is(e.detail.visible, false, 'Visibility should be false'); |
|
26 checkVisibilityTrue(); |
|
27 }); |
|
28 |
|
29 iframe1.setVisible(false); |
|
30 } |
|
31 |
|
32 function checkVisibilityTrue() { |
|
33 iframe1.addEventListener('mozbrowservisibilitychange', function onvisibilitychange(e) { |
|
34 iframe1.removeEventListener(e.type, onvisibilitychange); |
|
35 |
|
36 is(e.detail.visible, true, 'Visibility should be true'); |
|
37 SimpleTest.finish(); |
|
38 }); |
|
39 |
|
40 iframe1.setVisible(true); |
|
41 } |
|
42 |
|
43 addEventListener('testready', runTest); |