[d148f3]: dom / browser-element / mochitest / priority / test_NestedFrames.html  Maximize  Restore  History

Download this file

78 lines (67 with data), 2.9 kB

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

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks