dom/browser-element/mochitest/priority/test_NestedFrames.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 Test changing the visibility of an <iframe mozbrowser> changes the visibility
     5 (and thus the priority) of any <iframe mozbrowser>s it contains.
     6 -->
     7 <head>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    14 <script type="application/javascript;version=1.7">
    15 "use strict";
    17 SimpleTest.waitForExplicitFinish();
    18 browserElementTestHelpers.setEnabledPref(true);
    19 browserElementTestHelpers.addPermission();
    20 browserElementTestHelpers.enableProcessPriorityManager();
    22 // Give our origin permission to open browsers, and remove it when the test is complete.
    23 var principal = SpecialPowers.wrap(document).nodePrincipal;
    24 SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
    25                                                appId: principal.appId,
    26                                                isInBrowserElement: true });
    28 addEventListener('unload', function() {
    29   var principal = SpecialPowers.wrap(document).nodePrincipal;
    30   SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
    31                                               appId: principal.appId,
    32                                               isInBrowserElement: true });
    33 });
    35 function runTest() {
    36   // Set up the following hierarchy of frames:
    37   //
    38   //   <iframe mozbrowser remote=false src='file_NestedFramesOuter.html'>
    39   //     <iframe mozbrowser remote=true src='file_empty.html'>
    40   //
    41   // When we change the visibility of the outer iframe, it should change the
    42   // priority of the inner one.
    44   var iframe = document.createElement('iframe');
    45   iframe.setAttribute('mozbrowser', true);
    46   iframe.setAttribute('remote', false);
    47   iframe.src = 'file_NestedFramesOuter.html#' + browserElementTestHelpers.emptyPage1;
    49   // Note that this is the process corresponding to the /inner/ iframe.  The
    50   // outer iframe runs in-process (because it has remote=false).
    51   var childID = null;
    52   Promise.all(
    53     [expectOnlyOneProcessCreated().then(function(child) {
    54        childID = child;
    55        return expectPriorityChange(childID, 'FOREGROUND');
    56      }),
    57      expectMozbrowserEvent(iframe, 'loadend')]
    58   ).then(function() {
    59     // Send the outer iframe into the background.  This should change the
    60     // priority of the inner frame's process to BACKGROUND.
    61     var p = expectPriorityChange(childID, 'BACKGROUND');
    62     iframe.setVisible(false);
    63     return p;
    64   }).then(function() {
    65     var p = expectPriorityChange(childID, 'FOREGROUND');
    66     iframe.setVisible(true);
    67     return p;
    68   }).then(SimpleTest.finish);
    70   document.body.appendChild(iframe);
    71 }
    73 addEventListener('testready', runTest);
    75 </script>
    76 </body>
    77 </html>

mercurial