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

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 Test that calling setVisible('false') on two iframes causes the former one's priority with background LRU to
     5 change.
     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();
    21 SpecialPowers.addPermission("embed-apps", true, document);
    23 function runTest() {
    24   var iframe1 = document.createElement('iframe');
    25   iframe1.setAttribute('mozbrowser', true);
    26   iframe1.src = 'file_MultipleFrames.html';
    28   var iframe2 = null;
    29   var childID = null;
    31   expectProcessCreated().then(function(chid) {
    32     childID = chid;
    33     return expectPriorityChange(childID, 'FOREGROUND');
    34   }).then(function() {
    35     return expectMozbrowserEvent(iframe1, 'openwindow');
    36   }).then(function() {
    37     var p = expectPriorityChange(childID, 'BACKGROUND');
    38     iframe1.setVisible(false);
    39     return p;
    40   }).then(function() {
    41     iframe2 = document.createElement('iframe');
    42     iframe2.setAttribute('mozbrowser', true);
    43     iframe2.setAttribute('mozapp', 'http://example.org/manifest.webapp');
    44     iframe2.src = browserElementTestHelpers.emptyPage1;
    46     document.body.appendChild(iframe2);
    48     // At this point, we should have iframe1 in background already.
    49     // We wait until another one is set to background, too.
    50     // Once there are two in background, the first one (LRU order)
    51     // should have 'backgroundLRU' equals 1
    52     var p = expectPriorityWithBackgroundLRUSet(childID, '1');
    53     iframe2.setVisible(false);
    54     document.body.removeChild(iframe2);
    56     return p;
    58   }).then(SimpleTest.finish);
    60   document.body.appendChild(iframe1);
    61 }
    63 addEventListener('testready', runTest);
    65 </script>
    66 </body>
    67 </html>

mercurial