Bug 1282713 - Merge local/remote test cases of bug 1069772 and bug 1271240. r=smaug

--HG--
rename : dom/xul/test/file_bug1069772_local.xul => dom/xul/test/file_bug1069772.xul
rename : dom/xul/test/file_bug1271240_local.xul => dom/xul/test/file_bug1271240.xul
rename : dom/xul/test/test_bug1069772_local.xul => dom/xul/test/test_bug1069772.xul
rename : dom/xul/test/test_bug1271240_local.xul => dom/xul/test/test_bug1271240.xul
This commit is contained in:
Samael Wang 2016-07-05 14:39:16 +08:00
Родитель 427f588be2
Коммит d38fc6b22a
9 изменённых файлов: 34 добавлений и 281 удалений

Просмотреть файл

@ -9,10 +9,8 @@ support-files =
window_bug583948.xul
window_bug757137.xul
1061864.html
file_bug1271240_local.xul
file_bug1271240_remote.xul
file_bug1069772_local.xul
file_bug1069772_remote.xul
file_bug1271240.xul
file_bug1069772.xul
[test_bug199692.xul]
[test_bug233643.xul]
@ -36,9 +34,7 @@ support-files =
[test_bug1061864_2.xul]
[test_bug1070049_throw_from_script.xul]
[test_import_xul_to_content.xul]
[test_bug1271240_local.xul]
[test_bug1271240_remote.xul]
skip-if = !e10s
[test_bug1069772_local.xul]
[test_bug1069772_remote.xul]
skip-if = !e10s
[test_bug1271240.xul]
skip-if = os == "android"
[test_bug1069772.xul]
skip-if = os == "android"

Просмотреть файл

@ -41,6 +41,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1069772
.then(browser => verifyBrowser(browser, false, false))
.then(browser => verifyVisibility(browser, 'visible'))
// test the transition:
// prerender => visible => hidden => visible
// on a remote browser
.then(() => createPrerenderedBrowser(true))
.then(browser => verifyBrowser(browser, true, true))
.then(browser => verifyVisibility(browser, 'prerender'))
.then(browser => makePrerenderedBrowserActive(browser))
.then(browser => verifyBrowser(browser, false, true))
.then(browser => verifyVisibility(browser, 'visible'))
.then(browser => hideBrowser(browser))
.then(browser => verifyBrowser(browser, false, true))
.then(browser => verifyVisibility(browser, 'hidden'))
.then(browser => showBrowser(browser))
.then(browser => verifyBrowser(browser, false, true))
.then(browser => verifyVisibility(browser, 'visible'))
// finish test
.then(() => {
window.close();

Просмотреть файл

@ -1,127 +0,0 @@
<?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=1069772
-->
<window title="Mozilla Bug 1069772"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="run();">
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
const {interfaces: Ci, classes: Cc, results: Cr, utils: Cu} = Components;
Cu.import("resource://testing-common/ContentTask.jsm");
Cu.import("resource://testing-common/BrowserTestUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
ContentTask.setTestScope(window.opener.wrappedJSObject);
let imports = ['SimpleTest', 'ok', 'is'];
for (let name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}
/** Test for Bug 1069772 **/
function run() {
// test the transition:
// prerender => visible => hidden => visible
// on a remote browser
createPrerenderedBrowser(true)
.then(browser => verifyBrowser(browser, true, true))
.then(browser => verifyVisibility(browser, 'prerender'))
.then(browser => makePrerenderedBrowserActive(browser))
.then(browser => verifyBrowser(browser, false, true))
.then(browser => verifyVisibility(browser, 'visible'))
.then(browser => hideBrowser(browser))
.then(browser => verifyBrowser(browser, false, true))
.then(browser => verifyVisibility(browser, 'hidden'))
.then(browser => showBrowser(browser))
.then(browser => verifyBrowser(browser, false, true))
.then(browser => verifyVisibility(browser, 'visible'))
// finish test
.then(() => {
window.close();
SimpleTest.finish();
});
}
function createPrerenderedBrowser(remote) {
let browser = document.createElement('browser');
browser.setAttribute('type', 'content');
browser.setAttribute('prerendered', true);
browser.setAttribute('remote', remote);
browser.setAttribute('src', 'data:text/html;charset=UTF-8,<html><body>' +
'<iframe id="iframe" src="data:text/html;charset=UTF-8,Hello Frame!">' +
'</iframe></body></html>');
// wait for 'load' and 'pageshow'
let promises = [];
promises.push(BrowserTestUtils.browserLoaded(browser));
promises.push(new Promise(resolve =>
Services.mm.addMessageListener('test:pageshow', resolve)));
Services.mm.loadFrameScript('data:,' +
'addEventListener("pageshow", ' +
'() => sendAsyncMessage("test:pageshow", null), false);',
true);
document.getElementById('stack').appendChild(browser);
return Promise.all(promises).then(() => browser);
}
function verifyBrowser(browser, prerendered, remote) {
let 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 verifyVisibility(browser, visibility) {
return ContentTask.spawn(browser, visibility, (v) => {
let iframe = content.document.getElementById('iframe');
is(content.document.visibilityState, v, 'check doc.visibilityState');
is(content.document.hidden, v != 'visible', 'check doc.hidden');
is(iframe.contentDocument.visibilityState, v, 'check iframe doc.visibilityState');
is(iframe.contentDocument.hidden, v != 'visible', 'check iframe doc.hidden');
}).then(() => browser);
}
function makePrerenderedBrowserActive(browser) {
let promise = waitForVisibilityChange(browser);
browser.setAttribute('prerendered', false);
browser.makePrerenderedBrowserActive();
return promise.then(() => browser);
}
function hideBrowser(browser) {
let promise = waitForVisibilityChange(browser);
browser.docShellIsActive = false;
return promise.then(() => browser);
}
function showBrowser(browser) {
let promise = waitForVisibilityChange(browser);
browser.docShellIsActive = true;
return promise.then(() => browser);
}
function waitForVisibilityChange(browser) {
return ContentTask.spawn(browser, null, () => {
return new Promise(resolve => {
let iframe = content.document.getElementById('iframe');
iframe.contentDocument.addEventListener('visibilitychange', function listener() {
iframe.contentDocument.removeEventListener('visibilitychange', listener);
resolve();
});
});
});
}
]]>
</script>
<stack id="stack" flex="1" />
</window>

Просмотреть файл

@ -32,6 +32,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1271240
.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', '*');

Просмотреть файл

@ -1,72 +0,0 @@
<?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 remote, non-prerendered browser
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>

Просмотреть файл

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1069772
/** Test for Bug 1069772 **/
SimpleTest.waitForExplicitFinish();
function loadTest() {
window.open("file_bug1069772_local.xul", "", "width=360,height=240,chrome");
window.open("file_bug1069772.xul", "", "width=360,height=240,chrome");
}
]]>

Просмотреть файл

@ -1,32 +0,0 @@
<?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=1069772
-->
<window title="Mozilla Bug 1069772"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="loadTest();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069772"
target="_blank">Mozilla Bug 1069772</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 1069772 **/
SimpleTest.waitForExplicitFinish();
function loadTest() {
window.open("file_bug1069772_remote.xul", "", "width=360,height=240,chrome");
}
]]>
</script>
</window>

Просмотреть файл

@ -30,7 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1271240
});
function loadTest() {
window.open("file_bug1271240_local.xul", "", "chrome");
window.open("file_bug1271240.xul", "", "chrome");
}
]]>

Просмотреть файл

@ -1,38 +0,0 @@
<?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="loadTest();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1271240"
target="_blank">Mozilla Bug 1271240</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 1271240 **/
SimpleTest.waitForExplicitFinish();
window.addEventListener('message', (event) => {
if (event.data == 'finish') {
SimpleTest.finish();
}
});
function loadTest() {
window.open("file_bug1271240_remote.xul", "", "chrome");
}
]]>
</script>
</window>