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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/browser-element/mochitest/priority/test_MultipleFrames.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +Test that when we remove one of a process's frames from the DOM, the process's
     1.8 +priority is recomputed.
     1.9 +-->
    1.10 +<head>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body>
    1.16 +
    1.17 +<script type="application/javascript;version=1.7">
    1.18 +"use strict";
    1.19 +
    1.20 +SimpleTest.waitForExplicitFinish();
    1.21 +browserElementTestHelpers.setEnabledPref(true);
    1.22 +browserElementTestHelpers.addPermission();
    1.23 +browserElementTestHelpers.enableProcessPriorityManager();
    1.24 +
    1.25 +function runTest() {
    1.26 +  var iframe = document.createElement('iframe');
    1.27 +  iframe.setAttribute('mozbrowser', true);
    1.28 +  iframe.src = 'file_MultipleFrames.html';
    1.29 +
    1.30 +  var childID = null;
    1.31 +  var iframe2;
    1.32 +  expectProcessCreated().then(function(chid) {
    1.33 +    childID = chid;
    1.34 +    return expectPriorityChange(childID, 'FOREGROUND');
    1.35 +  }).then(function() {
    1.36 +    return expectMozbrowserEvent(iframe, 'openwindow');
    1.37 +  }).then(function(e) {
    1.38 +    iframe2 = e.detail.frameElement;
    1.39 +    document.body.appendChild(iframe2);
    1.40 +    return expectMozbrowserEvent(iframe2, 'loadend');
    1.41 +  }).then(function() {
    1.42 +    // At this point, the child process has been set to FOREGROUND, and the popup
    1.43 +    // opened by file_MultipleFrames has finished loading.
    1.44 +    //
    1.45 +    // Now setVisible(false) the popup frame and remove the popup frame from the
    1.46 +    // DOM.  This should cause the process to take on BACKGROUND priority.
    1.47 +    var p = expectPriorityChange(childID, 'BACKGROUND');
    1.48 +    iframe.setVisible(false);
    1.49 +    document.body.removeChild(iframe2);
    1.50 +    return p;
    1.51 +  }).then(SimpleTest.finish);
    1.52 +
    1.53 +  document.body.appendChild(iframe);
    1.54 +}
    1.55 +
    1.56 +addEventListener('testready', runTest);
    1.57 +</script>
    1.58 +</body>
    1.59 +</html>

mercurial