dom/browser-element/mochitest/priority/test_MultipleFrames.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 that when we remove one of a process's frames from the DOM, the process's
     5 priority is recomputed.
     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 function runTest() {
    23   var iframe = document.createElement('iframe');
    24   iframe.setAttribute('mozbrowser', true);
    25   iframe.src = 'file_MultipleFrames.html';
    27   var childID = null;
    28   var iframe2;
    29   expectProcessCreated().then(function(chid) {
    30     childID = chid;
    31     return expectPriorityChange(childID, 'FOREGROUND');
    32   }).then(function() {
    33     return expectMozbrowserEvent(iframe, 'openwindow');
    34   }).then(function(e) {
    35     iframe2 = e.detail.frameElement;
    36     document.body.appendChild(iframe2);
    37     return expectMozbrowserEvent(iframe2, 'loadend');
    38   }).then(function() {
    39     // At this point, the child process has been set to FOREGROUND, and the popup
    40     // opened by file_MultipleFrames has finished loading.
    41     //
    42     // Now setVisible(false) the popup frame and remove the popup frame from the
    43     // DOM.  This should cause the process to take on BACKGROUND priority.
    44     var p = expectPriorityChange(childID, 'BACKGROUND');
    45     iframe.setVisible(false);
    46     document.body.removeChild(iframe2);
    47     return p;
    48   }).then(SimpleTest.finish);
    50   document.body.appendChild(iframe);
    51 }
    53 addEventListener('testready', runTest);
    54 </script>
    55 </body>
    56 </html>

mercurial