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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 Test changing the visibility of an <iframe mozbrowser> changes the visibility
michael@0 5 (and thus the priority) of any <iframe mozbrowser>s it contains.
michael@0 6 -->
michael@0 7 <head>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 </head>
michael@0 12 <body>
michael@0 13
michael@0 14 <script type="application/javascript;version=1.7">
michael@0 15 "use strict";
michael@0 16
michael@0 17 SimpleTest.waitForExplicitFinish();
michael@0 18 browserElementTestHelpers.setEnabledPref(true);
michael@0 19 browserElementTestHelpers.addPermission();
michael@0 20 browserElementTestHelpers.enableProcessPriorityManager();
michael@0 21
michael@0 22 // Give our origin permission to open browsers, and remove it when the test is complete.
michael@0 23 var principal = SpecialPowers.wrap(document).nodePrincipal;
michael@0 24 SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
michael@0 25 appId: principal.appId,
michael@0 26 isInBrowserElement: true });
michael@0 27
michael@0 28 addEventListener('unload', function() {
michael@0 29 var principal = SpecialPowers.wrap(document).nodePrincipal;
michael@0 30 SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
michael@0 31 appId: principal.appId,
michael@0 32 isInBrowserElement: true });
michael@0 33 });
michael@0 34
michael@0 35 function runTest() {
michael@0 36 // Set up the following hierarchy of frames:
michael@0 37 //
michael@0 38 // <iframe mozbrowser remote=false src='file_NestedFramesOuter.html'>
michael@0 39 // <iframe mozbrowser remote=true src='file_empty.html'>
michael@0 40 //
michael@0 41 // When we change the visibility of the outer iframe, it should change the
michael@0 42 // priority of the inner one.
michael@0 43
michael@0 44 var iframe = document.createElement('iframe');
michael@0 45 iframe.setAttribute('mozbrowser', true);
michael@0 46 iframe.setAttribute('remote', false);
michael@0 47 iframe.src = 'file_NestedFramesOuter.html#' + browserElementTestHelpers.emptyPage1;
michael@0 48
michael@0 49 // Note that this is the process corresponding to the /inner/ iframe. The
michael@0 50 // outer iframe runs in-process (because it has remote=false).
michael@0 51 var childID = null;
michael@0 52 Promise.all(
michael@0 53 [expectOnlyOneProcessCreated().then(function(child) {
michael@0 54 childID = child;
michael@0 55 return expectPriorityChange(childID, 'FOREGROUND');
michael@0 56 }),
michael@0 57 expectMozbrowserEvent(iframe, 'loadend')]
michael@0 58 ).then(function() {
michael@0 59 // Send the outer iframe into the background. This should change the
michael@0 60 // priority of the inner frame's process to BACKGROUND.
michael@0 61 var p = expectPriorityChange(childID, 'BACKGROUND');
michael@0 62 iframe.setVisible(false);
michael@0 63 return p;
michael@0 64 }).then(function() {
michael@0 65 var p = expectPriorityChange(childID, 'FOREGROUND');
michael@0 66 iframe.setVisible(true);
michael@0 67 return p;
michael@0 68 }).then(SimpleTest.finish);
michael@0 69
michael@0 70 document.body.appendChild(iframe);
michael@0 71 }
michael@0 72
michael@0 73 addEventListener('testready', runTest);
michael@0 74
michael@0 75 </script>
michael@0 76 </body>
michael@0 77 </html>

mercurial