michael@0: /* Any copyright is dedicated to the public domain.
michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0:
michael@0: // Test that the onmozbrowservisibilitychange event works.
michael@0: 'use strict';
michael@0:
michael@0: SimpleTest.waitForExplicitFinish();
michael@0: browserElementTestHelpers.setEnabledPref(true);
michael@0: browserElementTestHelpers.addPermission();
michael@0:
michael@0: var iframe1 = null;
michael@0: function runTest() {
michael@0: iframe1 = document.createElement('iframe');
michael@0: SpecialPowers.wrap(iframe1).mozbrowser = true;
michael@0: document.body.appendChild(iframe1);
michael@0:
michael@0: iframe1.src = 'data:text/html,
Title';
michael@0: checkVisibilityFalse();
michael@0: }
michael@0:
michael@0: function checkVisibilityFalse() {
michael@0: iframe1.addEventListener('mozbrowservisibilitychange', function onvisibilitychange(e) {
michael@0: iframe1.removeEventListener(e.type, onvisibilitychange);
michael@0:
michael@0: is(e.detail.visible, false, 'Visibility should be false');
michael@0: checkVisibilityTrue();
michael@0: });
michael@0:
michael@0: iframe1.setVisible(false);
michael@0: }
michael@0:
michael@0: function checkVisibilityTrue() {
michael@0: iframe1.addEventListener('mozbrowservisibilitychange', function onvisibilitychange(e) {
michael@0: iframe1.removeEventListener(e.type, onvisibilitychange);
michael@0:
michael@0: is(e.detail.visible, true, 'Visibility should be true');
michael@0: SimpleTest.finish();
michael@0: });
michael@0:
michael@0: iframe1.setVisible(true);
michael@0: }
michael@0:
michael@0: addEventListener('testready', runTest);