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
78
79
80
81
82
|
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1271240
-->
<window title="Mozilla Bug 1271240"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="run();">
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
function ok(cond, msg) {
opener.wrappedJSObject.ok(cond, msg);
}
function is(actual, expected, msg) {
opener.wrappedJSObject.is(actual, expected, msg);
}
/** Test for Bug 1271240 **/
function run() {
// test non-remote, non-prerendered browser
createBrowser(false, false)
.then(browser => verifyBrowser(browser, false, false))
// test non-remote, prerendered browser
.then(() => createBrowser(true, false))
.then(browser => verifyBrowser(browser, true, false))
.then(browser => makePrerenderedBrowserActive(browser))
.then(browser => verifyBrowser(browser, false, false))
// test remote, non-prerendered browser
.then(() => createBrowser(false, true))
.then(browser => verifyBrowser(browser, false, true))
// test remote, prerendered browser
.then(() => createBrowser(true, true))
.then(browser => verifyBrowser(browser, true, true))
.then(browser => makePrerenderedBrowserActive(browser))
.then(browser => verifyBrowser(browser, false, true))
// finish test
.then(() => {
opener.postMessage('finish', '*');
window.close();
});
}
function createBrowser(prerendered, remote) {
return new Promise(resolve => {
var browser = document.createElement('browser');
browser.setAttribute('type', 'content');
browser.setAttribute('prerendered', prerendered);
browser.setAttribute('remote', remote);
document.documentElement.appendChild(browser);
browser.loadURI('example.com');
resolve(browser);
});
}
function verifyBrowser(browser, prerendered, remote) {
var docShellOrTabParent = remote ?
browser.frameLoader.tabParent : browser.frameLoader.docShell;
ok(docShellOrTabParent, 'docShellOrTabParent should not be null');
is(docShellOrTabParent.isPrerendered, prerendered,
'isPrerendered should be ' + prerendered);
return browser;
}
function makePrerenderedBrowserActive(browser) {
browser.makePrerenderedBrowserActive();
return browser;
}
]]>
</script>
<!-- <browser type="content-primary" flex="1" id="content" />
<browser type="content-primary" flex="1" id="content-remote" remote="true" /> -->
</window>
|