dom/browser-element/mochitest/browserElement_VisibilityChange.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

     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);

mercurial