dom/browser-element/mochitest/priority/test_NestedFrames.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_NestedFrames.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +Test changing the visibility of an <iframe mozbrowser> changes the visibility
     1.8 +(and thus the priority) of any <iframe mozbrowser>s it contains.
     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 +// Give our origin permission to open browsers, and remove it when the test is complete.
    1.26 +var principal = SpecialPowers.wrap(document).nodePrincipal;
    1.27 +SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
    1.28 +                                               appId: principal.appId,
    1.29 +                                               isInBrowserElement: true });
    1.30 +
    1.31 +addEventListener('unload', function() {
    1.32 +  var principal = SpecialPowers.wrap(document).nodePrincipal;
    1.33 +  SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
    1.34 +                                              appId: principal.appId,
    1.35 +                                              isInBrowserElement: true });
    1.36 +});
    1.37 +
    1.38 +function runTest() {
    1.39 +  // Set up the following hierarchy of frames:
    1.40 +  //
    1.41 +  //   <iframe mozbrowser remote=false src='file_NestedFramesOuter.html'>
    1.42 +  //     <iframe mozbrowser remote=true src='file_empty.html'>
    1.43 +  //
    1.44 +  // When we change the visibility of the outer iframe, it should change the
    1.45 +  // priority of the inner one.
    1.46 +
    1.47 +  var iframe = document.createElement('iframe');
    1.48 +  iframe.setAttribute('mozbrowser', true);
    1.49 +  iframe.setAttribute('remote', false);
    1.50 +  iframe.src = 'file_NestedFramesOuter.html#' + browserElementTestHelpers.emptyPage1;
    1.51 +
    1.52 +  // Note that this is the process corresponding to the /inner/ iframe.  The
    1.53 +  // outer iframe runs in-process (because it has remote=false).
    1.54 +  var childID = null;
    1.55 +  Promise.all(
    1.56 +    [expectOnlyOneProcessCreated().then(function(child) {
    1.57 +       childID = child;
    1.58 +       return expectPriorityChange(childID, 'FOREGROUND');
    1.59 +     }),
    1.60 +     expectMozbrowserEvent(iframe, 'loadend')]
    1.61 +  ).then(function() {
    1.62 +    // Send the outer iframe into the background.  This should change the
    1.63 +    // priority of the inner frame's process to BACKGROUND.
    1.64 +    var p = expectPriorityChange(childID, 'BACKGROUND');
    1.65 +    iframe.setVisible(false);
    1.66 +    return p;
    1.67 +  }).then(function() {
    1.68 +    var p = expectPriorityChange(childID, 'FOREGROUND');
    1.69 +    iframe.setVisible(true);
    1.70 +    return p;
    1.71 +  }).then(SimpleTest.finish);
    1.72 +
    1.73 +  document.body.appendChild(iframe);
    1.74 +}
    1.75 +
    1.76 +addEventListener('testready', runTest);
    1.77 +
    1.78 +</script>
    1.79 +</body>
    1.80 +</html>

mercurial