dom/browser-element/mochitest/priority/test_BackgroundLRU.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_BackgroundLRU.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +Test that calling setVisible('false') on two iframes causes the former one's priority with background LRU to
     1.8 +change.
     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 +SpecialPowers.addPermission("embed-apps", true, document);
    1.25 +
    1.26 +function runTest() {
    1.27 +  var iframe1 = document.createElement('iframe');
    1.28 +  iframe1.setAttribute('mozbrowser', true);
    1.29 +  iframe1.src = 'file_MultipleFrames.html';
    1.30 +
    1.31 +  var iframe2 = null;
    1.32 +  var childID = null;
    1.33 +
    1.34 +  expectProcessCreated().then(function(chid) {
    1.35 +    childID = chid;
    1.36 +    return expectPriorityChange(childID, 'FOREGROUND');
    1.37 +  }).then(function() {
    1.38 +    return expectMozbrowserEvent(iframe1, 'openwindow');
    1.39 +  }).then(function() {
    1.40 +    var p = expectPriorityChange(childID, 'BACKGROUND');
    1.41 +    iframe1.setVisible(false);
    1.42 +    return p;
    1.43 +  }).then(function() {
    1.44 +    iframe2 = document.createElement('iframe');
    1.45 +    iframe2.setAttribute('mozbrowser', true);
    1.46 +    iframe2.setAttribute('mozapp', 'http://example.org/manifest.webapp');
    1.47 +    iframe2.src = browserElementTestHelpers.emptyPage1;
    1.48 +
    1.49 +    document.body.appendChild(iframe2);
    1.50 +
    1.51 +    // At this point, we should have iframe1 in background already.
    1.52 +    // We wait until another one is set to background, too.
    1.53 +    // Once there are two in background, the first one (LRU order)
    1.54 +    // should have 'backgroundLRU' equals 1
    1.55 +    var p = expectPriorityWithBackgroundLRUSet(childID, '1');
    1.56 +    iframe2.setVisible(false);
    1.57 +    document.body.removeChild(iframe2);
    1.58 +
    1.59 +    return p;
    1.60 +
    1.61 +  }).then(SimpleTest.finish);
    1.62 +
    1.63 +  document.body.appendChild(iframe1);
    1.64 +}
    1.65 +
    1.66 +addEventListener('testready', runTest);
    1.67 +
    1.68 +</script>
    1.69 +</body>
    1.70 +</html>

mercurial