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

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

mercurial