зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1763598 - Fixes for docshell/test/chrome tests with session history in the parent. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D143160
This commit is contained in:
Родитель
926498605f
Коммит
f568cf2298
|
@ -38,17 +38,10 @@ BROWSER_CHROME_MANIFESTS += [
|
|||
]
|
||||
|
||||
TEST_HARNESS_FILES.testing.mochitest.tests.docshell.test.chrome += [
|
||||
"test/chrome/112564_nocache.html",
|
||||
"test/chrome/112564_nocache.html^headers^",
|
||||
"test/chrome/215405_nocache.html",
|
||||
"test/chrome/215405_nocache.html^headers^",
|
||||
"test/chrome/215405_nostore.html",
|
||||
"test/chrome/215405_nostore.html^headers^",
|
||||
"test/chrome/582176_dummy.html",
|
||||
"test/chrome/582176_xml.xml",
|
||||
"test/chrome/582176_xslt.xsl",
|
||||
"test/chrome/92598_nostore.html",
|
||||
"test/chrome/92598_nostore.html^headers^",
|
||||
"test/chrome/allowContentRetargeting.sjs",
|
||||
"test/chrome/blue.png",
|
||||
"test/chrome/bug89419.sjs",
|
||||
|
|
|
@ -13,74 +13,16 @@
|
|||
onload="onLoad();"
|
||||
title="112564 test">
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
|
||||
const LISTEN_EVENTS = ["load", "unload", "pageshow", "pagehide"];
|
||||
|
||||
var gBrowser;
|
||||
var gTestsIterator;
|
||||
var gExpected = [];
|
||||
|
||||
function ok(condition, message) {
|
||||
window.arguments[0].SimpleTest.ok(condition, message);
|
||||
}
|
||||
|
||||
function is(a, b, message) {
|
||||
window.arguments[0].SimpleTest.is(a, b, message);
|
||||
}
|
||||
|
||||
function finish() {
|
||||
for (let eventType of LISTEN_EVENTS) {
|
||||
gBrowser.removeEventListener(eventType, eventListener, true);
|
||||
}
|
||||
|
||||
// Work around bug 467960
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
let history = gBrowser.browsingContext.sessionHistory;
|
||||
history.purgeHistory(history.count);
|
||||
} else {
|
||||
let history = gBrowser.webNavigation.sessionHistory;
|
||||
history.legacySHistory.purgeHistory(history.count);
|
||||
}
|
||||
|
||||
window.close();
|
||||
window.arguments[0].SimpleTest.finish();
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
gBrowser = document.getElementById("content");
|
||||
for (let eventType of LISTEN_EVENTS) {
|
||||
gBrowser.addEventListener(eventType, eventListener, true);
|
||||
}
|
||||
|
||||
gTestsIterator = testsIterator();
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function eventListener(event) {
|
||||
ok(gExpected.length >= 1, "Unexpected event " + event.type);
|
||||
if (gExpected.length == 0) {
|
||||
// in case of unexpected event, try to continue anyway
|
||||
setTimeout(nextTest, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
var exp = gExpected.shift();
|
||||
is(event.type, exp.type, "Invalid event received");
|
||||
if (typeof(exp.persisted) != "undefined") {
|
||||
is(event.persisted, exp.persisted, "Invalid persisted state");
|
||||
}
|
||||
if (exp.title) {
|
||||
ok(event.originalTarget instanceof HTMLDocument,
|
||||
"originalTarget not a HTMLDocument");
|
||||
is(event.originalTarget.title, exp.title, "titles don't match");
|
||||
}
|
||||
|
||||
if (gExpected.length == 0) {
|
||||
setTimeout(nextTest, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
gTestsIterator.next();
|
||||
}
|
||||
|
@ -89,33 +31,56 @@
|
|||
// Load a secure page with a no-cache header, followed by a simple page.
|
||||
// no-cache should not interfere with the bfcache in the way no-store
|
||||
// does.
|
||||
var test1DocURI = "https://example.com:443/tests/docshell/test/chrome/112564_nocache.html";
|
||||
var test1DocURI = "https://example.com:443/chrome/docshell/test/chrome/112564_nocache.html";
|
||||
|
||||
gExpected = [{type: "pagehide", persisted: true},
|
||||
{type: "load", title: "test1"},
|
||||
{type: "pageshow", title: "test1", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test1DocURI);
|
||||
doPageNavigation({
|
||||
uri: test1DocURI,
|
||||
eventsToListenFor: ["load", "pageshow"],
|
||||
expectedEvents: [ { type: "load",
|
||||
title: "test1" },
|
||||
{ type: "pageshow",
|
||||
title: "test1",
|
||||
persisted: false } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
var test2Doc = "data:text/html,<html><head><title>test2</title></head>" +
|
||||
"<body>test2</body></html>";
|
||||
var test2DocURI = "data:text/html,<html><head><title>test2</title></head>" +
|
||||
"<body>test2</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test1", persisted: true},
|
||||
{type: "load", title: "test2"},
|
||||
{type: "pageshow", title: "test2", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test2Doc);
|
||||
doPageNavigation({
|
||||
uri: test2DocURI,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
title: "test1",
|
||||
persisted: true },
|
||||
{ type: "load",
|
||||
title: "test2" },
|
||||
{ type: "pageshow",
|
||||
title: "test2",
|
||||
persisted: false } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
// Now go back in history. First page has been cached.
|
||||
// Check persisted property to confirm
|
||||
gExpected = [{type: "pagehide", title: "test2", persisted: true},
|
||||
{type: "pageshow", title: "test1", persisted: true}];
|
||||
gBrowser.goBack();
|
||||
doPageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
title: "test2",
|
||||
persisted: true },
|
||||
{ type: "pageshow",
|
||||
title: "test1",
|
||||
persisted: true } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
finish();
|
||||
}
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -38,16 +38,23 @@
|
|||
function finish() {
|
||||
gBrowser.removeEventListener("pageshow", eventListener, true);
|
||||
// Work around bug 467960
|
||||
let historyPurged;
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
let history = gBrowser.browsingContext.sessionHistory;
|
||||
history.purgeHistory(history.count);
|
||||
historyPurged = Promise.resolve();
|
||||
} else {
|
||||
let history = gBrowser.webNavigation.sessionHistory;
|
||||
history.legacySHistory.purgeHistory(history.count);
|
||||
historyPurged = SpecialPowers.spawn(gBrowser, [], () => {
|
||||
let history = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory
|
||||
.legacySHistory;
|
||||
history.purgeHistory(history.count);
|
||||
});
|
||||
}
|
||||
|
||||
window.close();
|
||||
window.arguments[0].SimpleTest.finish();
|
||||
historyPurged.then(_ => {
|
||||
window.close();
|
||||
window.arguments[0].SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
function onLoad(e) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="setTimeout(nextTest, 0);"
|
||||
onload="setTimeout(runTest, 0);"
|
||||
title="bug 298622 test">
|
||||
|
||||
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
|
||||
|
@ -14,37 +14,25 @@
|
|||
// Global variable that holds a reference to the find bar.
|
||||
var gFindBar;
|
||||
|
||||
// Define the generator-iterator for the tests.
|
||||
var tests = testIterator();
|
||||
|
||||
////
|
||||
// Execute the next test in the generator function.
|
||||
//
|
||||
function nextTest() {
|
||||
tests.next();
|
||||
}
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 298622:
|
||||
// Test for bug 298622:
|
||||
// Find should work correctly on a page loaded from the
|
||||
// bfcache.
|
||||
//
|
||||
function* testIterator()
|
||||
async function runTest()
|
||||
{
|
||||
// Make sure bfcache is on.
|
||||
enableBFCache(true);
|
||||
|
||||
// Load a test page which contains some text to be found.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
uri: "data:text/html,<html><head><title>test1</title></head>" +
|
||||
"<body>find this!</body></html>",
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
// Load a second, dummy page, verifying that the original
|
||||
// page gets stored in the bfcache.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
uri: getHttpUrl("generic.html"),
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -52,13 +40,12 @@
|
|||
persisted: true },
|
||||
{ type: "pageshow",
|
||||
title: "generic page" } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
// Make sure we unsuppress painting before continuing
|
||||
SimpleTest.executeSoon(nextTest);
|
||||
yield undefined;
|
||||
await new Promise(resolve => {
|
||||
SimpleTest.executeSoon(resolve);
|
||||
});
|
||||
|
||||
// Search for some text that's on the second page (but not on
|
||||
// the first page), and verify that it can be found.
|
||||
|
@ -67,8 +54,9 @@
|
|||
ok(!gFindBar.hidden, "failed to open findbar");
|
||||
gFindBar._findField.value = "A generic page";
|
||||
gFindBar._find();
|
||||
SimpleTest.executeSoon(nextTest);
|
||||
yield undefined;
|
||||
await new Promise(resolve => {
|
||||
SimpleTest.executeSoon(resolve);
|
||||
});
|
||||
|
||||
// Make sure Find bar's internal status is not 'notfound'
|
||||
isnot(gFindBar._findField.getAttribute("status"), "notfound",
|
||||
|
@ -77,30 +65,29 @@
|
|||
|
||||
// Make sure the key events above have time to be processed
|
||||
// before continuing
|
||||
waitForTrue(function() {
|
||||
return (
|
||||
TestWindow.getWindow().getSelection().toString().toLowerCase() ==
|
||||
"a generic page");
|
||||
}, nextTest, 20);
|
||||
yield undefined;
|
||||
await promiseTrue(() =>
|
||||
SpecialPowers.spawn(document.getElementById("content"), [], function() {
|
||||
return content.document.getSelection().toString().toLowerCase() == "a generic page";
|
||||
}), 20
|
||||
);
|
||||
|
||||
is(gFindBar._findField.value, "A generic page",
|
||||
"expected text not present in find input field");
|
||||
is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
|
||||
is(await SpecialPowers.spawn(document.getElementById("content"), [], async function() {
|
||||
return content.document.getSelection().toString().toLowerCase();
|
||||
}),
|
||||
"a generic page",
|
||||
"find failed on second page loaded");
|
||||
|
||||
// Go back to the original page and verify it's loaded from the
|
||||
// bfcache.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow"],
|
||||
expectedEvents: [ { type: "pageshow",
|
||||
title: "test1",
|
||||
persisted: true } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
// Search for some text that's on the original page (but not
|
||||
// the dummy page loaded above), and verify that it can
|
||||
|
@ -110,8 +97,9 @@
|
|||
ok(!gFindBar.hidden, "failed to open findbar");
|
||||
gFindBar._findField.value = "find this";
|
||||
gFindBar._find();
|
||||
SimpleTest.executeSoon(nextTest);
|
||||
yield undefined;
|
||||
await new Promise(resolve => {
|
||||
SimpleTest.executeSoon(resolve);
|
||||
});
|
||||
|
||||
// Make sure Find bar's internal status is not 'notfound'
|
||||
isnot(gFindBar._findField.getAttribute("status"), "notfound",
|
||||
|
@ -120,14 +108,15 @@
|
|||
|
||||
// Make sure the key events above have time to be processed
|
||||
// before continuing
|
||||
waitForTrue(function() {
|
||||
return (
|
||||
TestWindow.getWindow().getSelection().toString().toLowerCase() ==
|
||||
"find this");
|
||||
}, nextTest, 20);
|
||||
yield undefined;
|
||||
await promiseTrue(() =>
|
||||
SpecialPowers.spawn(document.getElementById("content"), [], function() {
|
||||
return content.document.getSelection().toString().toLowerCase() == "find this";
|
||||
}), 20
|
||||
);
|
||||
|
||||
is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
|
||||
is(await SpecialPowers.spawn(document.getElementById("content"), [], async function() {
|
||||
return content.document.getSelection().toString().toLowerCase();
|
||||
}),
|
||||
"find this",
|
||||
"find failed on page loaded from bfcache");
|
||||
|
||||
|
@ -141,6 +130,6 @@
|
|||
<command id="cmd_find"
|
||||
oncommand="document.getElementById('FindToolbar').onFindCommand();"/>
|
||||
</commandset>
|
||||
<browser type="content" primary="true" flex="1" id="content" messagemanagergroup="test" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" messagemanagergroup="test" remote="true" />
|
||||
<findbar id="FindToolbar" browserid="content"/>
|
||||
</window>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="setTimeout(nextTest, 0);"
|
||||
onload="setTimeout(runTest, 0);"
|
||||
title="bug 301397 test">
|
||||
|
||||
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
|
||||
|
@ -13,51 +13,35 @@
|
|||
<script type="application/javascript"><![CDATA[
|
||||
Services.prefs.setBoolPref("browser.navigation.requireUserInteraction", false);
|
||||
|
||||
// Define the generator-iterator for the tests.
|
||||
var tests = testIterator();
|
||||
|
||||
////
|
||||
// Execute the next test in the generator function.
|
||||
//
|
||||
function nextTest() {
|
||||
tests.next();
|
||||
}
|
||||
|
||||
////
|
||||
// Return the document element with the specified id.
|
||||
//
|
||||
function $(id) { return TestWindow.getDocument().getElementById(id); }
|
||||
|
||||
////
|
||||
// Verifies that the given string exists in the innerHTML of the iframe
|
||||
// content.
|
||||
//
|
||||
function verifyIframeInnerHtml(string) {
|
||||
var iframeInnerHtml = $("iframe").contentDocument.body.innerHTML;
|
||||
async function verifyIframeInnerHtml(string) {
|
||||
var iframeInnerHtml = await SpecialPowers.spawn(document.getElementById("content"), [string], (string) =>
|
||||
content.document.getElementById("iframe").contentDocument.body.innerHTML);
|
||||
ok(iframeInnerHtml.includes(string),
|
||||
"iframe contains wrong document: " + iframeInnerHtml);
|
||||
"iframe contains wrong document: " + iframeInnerHtml);
|
||||
}
|
||||
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 301397:
|
||||
// Generator function for test steps for bug 301397:
|
||||
// The correct page should be displayed in an iframe when
|
||||
// navigating back and forwards, when the parent page
|
||||
// occupies multiple spots in the session history.
|
||||
//
|
||||
function* testIterator()
|
||||
async function runTest()
|
||||
{
|
||||
// Make sure the bfcache is enabled.
|
||||
enableBFCache(8);
|
||||
|
||||
// Load a dummy page.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
uri: getHttpUrl("generic.html"),
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
|
||||
// Load a page containing an iframe.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
uri: getHttpUrl("bug301397_1.html"),
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -69,14 +53,12 @@
|
|||
{ type: "pageshow",
|
||||
title: "iframe parent",
|
||||
persisted: false } ], // false on initial load
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
|
||||
// Click a link in the iframe to cause the iframe to navigate
|
||||
// to a new page, and wait until the related pagehide/pageshow
|
||||
// events have occurred.
|
||||
waitForPageEvents({
|
||||
let waitForLinkNavigation = promisePageEvents({
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
title: "iframe content #1",
|
||||
|
@ -84,20 +66,22 @@
|
|||
{ type: "pageshow",
|
||||
title: "iframe content #2",
|
||||
persisted: false } ], // false on initial load
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
var link = $("iframe").contentDocument.getElementById("link");
|
||||
var event = $("iframe").contentDocument.createEvent("MouseEvents");
|
||||
event.initMouseEvent("click", true, true, $("iframe").contentWindow,
|
||||
SpecialPowers.spawn(document.getElementById("content"), [], function() {
|
||||
let iframe = content.document.getElementById("iframe");
|
||||
let link = iframe.contentDocument.getElementById("link");
|
||||
let event = iframe.contentDocument.createEvent("MouseEvents");
|
||||
event.initMouseEvent("click", true, true, iframe.contentWindow,
|
||||
0, 0, 0, 0, 0,
|
||||
false, false, false, false,
|
||||
0, null);
|
||||
link.dispatchEvent(event);
|
||||
yield undefined;
|
||||
|
||||
link.dispatchEvent(event);
|
||||
});
|
||||
await waitForLinkNavigation;
|
||||
|
||||
// Load another dummy page. Verify that both the outgoing parent and
|
||||
// iframe pages are stored in the bfcache.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
uri: getHttpUrl("bug301397_4.html"),
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -109,14 +93,12 @@
|
|||
{ type: "pageshow",
|
||||
title: "dummy page, no iframe",
|
||||
persisted: false } ], // false on initial load
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
// Go back. The iframe should show the second page loaded in it.
|
||||
|
||||
// Go back. The iframe should show the second page loaded in it.
|
||||
// Both the parent and the iframe pages should be loaded from
|
||||
// the bfcache.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -128,14 +110,12 @@
|
|||
{ type: "pageshow",
|
||||
persisted: true,
|
||||
title: "iframe parent" } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
|
||||
verifyIframeInnerHtml("You made it");
|
||||
|
||||
// Go gack again. The iframe should show the first page loaded in it.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -146,16 +126,14 @@
|
|||
// false since this page was never stored
|
||||
// in the bfcache in the first place
|
||||
persisted: false } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
|
||||
verifyIframeInnerHtml("go to next page");
|
||||
|
||||
// Go back to the generic page. Now go forward to the last page,
|
||||
// again verifying that the iframe shows the first and second
|
||||
// pages in order.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -167,11 +145,9 @@
|
|||
{ type: "pageshow",
|
||||
title: "generic page",
|
||||
persisted: true } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
forward: true,
|
||||
eventsToListenFor: ["pageshow"],
|
||||
expectedEvents: [ {type: "pageshow",
|
||||
|
@ -180,13 +156,11 @@
|
|||
{type: "pageshow",
|
||||
title: "iframe parent",
|
||||
persisted: true} ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
verifyIframeInnerHtml("go to next page");
|
||||
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
forward: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -197,13 +171,11 @@
|
|||
// false because the page wasn't stored in
|
||||
// bfcache last time it was unloaded
|
||||
persisted: false } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
verifyIframeInnerHtml("You made it");
|
||||
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
forward: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -215,13 +187,11 @@
|
|||
{ type: "pageshow",
|
||||
title: "dummy page, no iframe",
|
||||
persisted: true } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
// Go back once more, and again verify that the iframe shows the
|
||||
// second page loaded in it.
|
||||
doPageNavigation({
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -233,10 +203,8 @@
|
|||
{ type: "pageshow",
|
||||
persisted: true,
|
||||
title: "iframe parent" } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
|
||||
verifyIframeInnerHtml("You made it");
|
||||
|
||||
Services.prefs.clearUserPref("browser.navigation.requireUserInteraction");
|
||||
|
@ -246,5 +214,5 @@
|
|||
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" messagemanagergroup="test" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" messagemanagergroup="test" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -5,42 +5,28 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="setTimeout(nextTest, 0);"
|
||||
onload="setTimeout(runTests, 0);"
|
||||
title="bug 303267 test">
|
||||
|
||||
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
// Define the generator-iterator for the tests.
|
||||
var tests = testIterator();
|
||||
|
||||
////
|
||||
// Execute the next test in the generator function.
|
||||
//
|
||||
function nextTest() {
|
||||
tests.next();
|
||||
}
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 303267: When a page is
|
||||
// displayed from the bfcache, the script globals should
|
||||
// Bug 303267: When a page is displayed from the bfcache, the script globals should
|
||||
// remain intact from the page's initial load.
|
||||
//
|
||||
function* testIterator()
|
||||
async function runTests()
|
||||
{
|
||||
// Load an initial test page which should be saved in the bfcache.
|
||||
var navData = {
|
||||
uri: getHttpUrl("bug303267.html"),
|
||||
eventsToListenFor: ["pageshow"],
|
||||
expectedEvents: [ {type: "pageshow", title: "bug303267.html"} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
doPageNavigation(navData);
|
||||
yield undefined;
|
||||
|
||||
await promisePageNavigation(navData);
|
||||
|
||||
// Save the HTML of the test page for later comparison.
|
||||
var originalHTML = getInnerHTMLById("div1");
|
||||
var originalHTML = await getInnerHTMLById("div1");
|
||||
|
||||
// Load a second test page. The first test page's pagehide event should
|
||||
// have the .persisted property set to true, indicating that it was
|
||||
|
@ -54,12 +40,10 @@
|
|||
persisted: true},
|
||||
{type: "pageshow",
|
||||
title: "page2"} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
doPageNavigation(navData);
|
||||
yield undefined;
|
||||
|
||||
// Go back. Verify that the pageshow event for the original test page
|
||||
await promisePageNavigation(navData);
|
||||
|
||||
// Go back. Verify that the pageshow event for the original test page
|
||||
// had a .persisted property of true, indicating that it came from the
|
||||
// bfcache.
|
||||
navData = {
|
||||
|
@ -70,15 +54,13 @@
|
|||
{type: "pageshow",
|
||||
title: "bug303267.html",
|
||||
persisted: true} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
doPageNavigation(navData);
|
||||
yield undefined;
|
||||
|
||||
await promisePageNavigation(navData);
|
||||
|
||||
// After going back, if showpagecount() could access a global variable
|
||||
// and change the test div's innerHTML, then we pass. Otherwise, it
|
||||
// threw an exception and the following test will fail.
|
||||
var newHTML = getInnerHTMLById("div1");
|
||||
var newHTML = await getInnerHTMLById("div1");
|
||||
isnot(originalHTML,
|
||||
newHTML, "HTML not updated on pageshow; javascript broken?");
|
||||
|
||||
|
@ -90,10 +72,12 @@
|
|||
// Return the innerHTML of a particular element in the content document.
|
||||
//
|
||||
function getInnerHTMLById(id) {
|
||||
return TestWindow.getDocument().getElementById(id).innerHTML;
|
||||
return SpecialPowers.spawn(TestWindow.getBrowser(), [id], (id) => {
|
||||
return content.document.getElementById(id).innerHTML;
|
||||
});
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -5,17 +5,14 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="setTimeout(nextTest, 0);"
|
||||
onload="setTimeout(runTest, 0);"
|
||||
title="bug 321671 test">
|
||||
|
||||
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
Services.prefs.setBoolPref("browser.navigation.requireUserInteraction", false);
|
||||
|
||||
// Define the generator-iterator for the tests.
|
||||
var tests = testIterator();
|
||||
|
||||
// Maximum number of entries in the bfcache for this session history.
|
||||
// This number is hardcoded in docshell code. In the test, we'll
|
||||
// navigate through enough pages so that we hit one that's been
|
||||
|
@ -24,18 +21,10 @@
|
|||
const MAX_BFCACHE_PAGES = 3;
|
||||
|
||||
////
|
||||
// Execute the next test in the generator function.
|
||||
// Bug 321671: Scroll position should be retained when moving backwards and
|
||||
// forwards through pages when bfcache is enabled.
|
||||
//
|
||||
function nextTest() {
|
||||
tests.next();
|
||||
}
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 321671: Scroll position
|
||||
// should be retained when moving backwards and forwards through pages
|
||||
// when bfcache is enabled.
|
||||
//
|
||||
function* testIterator()
|
||||
async function runTest()
|
||||
{
|
||||
// Variable to hold the scroll positions of the test pages.
|
||||
var scrollPositions = [];
|
||||
|
@ -44,35 +33,41 @@
|
|||
enableBFCache(true);
|
||||
|
||||
// Load enough test pages that so the first one is evicted from the
|
||||
// bfcache, scroll down on each page, and save the
|
||||
// bfcache, scroll down on each page, and save the
|
||||
// current scroll position before continuing. Verify that each
|
||||
// page we're navigating away from is initially put into the bfcache.
|
||||
for (var i = 0; i <= MAX_BFCACHE_PAGES + 1; i++) {
|
||||
doPageNavigation( {
|
||||
uri: "data:text/html,<html><head><title>bug321671 page" + (i + 1) +
|
||||
let eventsToListenFor = ["pageshow"];
|
||||
let expectedEvents = [ { type: "pageshow",
|
||||
title: "bug321671 page" + (i + 1) } ];
|
||||
if (i > 0) {
|
||||
eventsToListenFor.push("pagehide");
|
||||
expectedEvents.unshift({ type: "pagehide",
|
||||
persisted: true,
|
||||
title: "bug321671 page" + i });
|
||||
}
|
||||
await promisePageNavigation( {
|
||||
uri: "data:text/html,<html><head><title>bug321671 page" + (i + 1) +
|
||||
"</title></head>" +
|
||||
"<body><table border='1' width='300' height='1000'>" +
|
||||
"<body><table border='1' width='300' height='1000'>" +
|
||||
"<tbody><tr><td>" +
|
||||
" page " + (i + 1) + ": foobar foobar foobar foobar " +
|
||||
"</td></tr></tbody></table> " +
|
||||
"</body></html>",
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
persisted: true,
|
||||
title: i == 0 ?
|
||||
undefined : "bug321671 page" + i },
|
||||
{ type: "pageshow",
|
||||
title: "bug321671 page" + (i + 1) } ],
|
||||
onNavComplete: nextTest
|
||||
eventsToListenFor,
|
||||
expectedEvents,
|
||||
} );
|
||||
yield undefined;
|
||||
|
||||
is(TestWindow.getWindow().scrollY, 0,
|
||||
let { initialScrollY, scrollY } = await SpecialPowers.spawn(TestWindow.getBrowser(), [i], (i) => {
|
||||
let initialScrollY = content.scrollY;
|
||||
content.scrollByLines(10 + (2 * i));
|
||||
return { initialScrollY, scrollY: content.scrollY };
|
||||
});
|
||||
is(initialScrollY, 0,
|
||||
"Page initially has non-zero scrollY position");
|
||||
TestWindow.getWindow().scrollByLines(10 + (2*i));
|
||||
ok(TestWindow.getWindow().scrollY > 0,
|
||||
ok(scrollY > 0,
|
||||
"Page has zero scrollY position after scrolling");
|
||||
scrollPositions[i] = TestWindow.getWindow().scrollY;
|
||||
scrollPositions[i] = scrollY;
|
||||
}
|
||||
|
||||
// Go back to the first page, one page at a time. For each 'back'
|
||||
|
@ -82,7 +77,7 @@
|
|||
// that we navigate away from are initially
|
||||
// stored in the bfcache.
|
||||
for (i = MAX_BFCACHE_PAGES + 1; i > 0; i--) {
|
||||
doPageNavigation( {
|
||||
await promisePageNavigation( {
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
|
@ -91,12 +86,12 @@
|
|||
{ type: "pageshow",
|
||||
title: "bug321671 page" + i,
|
||||
persisted: i > 1 } ],
|
||||
onNavComplete: nextTest
|
||||
} );
|
||||
yield undefined;
|
||||
|
||||
is(TestWindow.getWindow().scrollY, scrollPositions[i-1],
|
||||
"Scroll position not restored while going back!");
|
||||
|
||||
is(await SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
return content.scrollY;
|
||||
}), scrollPositions[i-1],
|
||||
"Scroll position not restored while going back!");
|
||||
}
|
||||
|
||||
// Traverse history forward now, and verify scroll position is still
|
||||
|
@ -105,29 +100,29 @@
|
|||
// verify that all of the pages get stored in the bfcache when we
|
||||
// navigate away from them.
|
||||
for (i = 1; i <= MAX_BFCACHE_PAGES + 1; i++) {
|
||||
doPageNavigation( {
|
||||
await promisePageNavigation( {
|
||||
forward: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
persisted: true,
|
||||
persisted: true,
|
||||
title: "bug321671 page" + i },
|
||||
{ type: "pageshow",
|
||||
persisted: i < MAX_BFCACHE_PAGES + 1,
|
||||
title: "bug321671 page" + (i + 1) } ],
|
||||
onNavComplete: nextTest
|
||||
} );
|
||||
yield undefined;
|
||||
|
||||
is(TestWindow.getWindow().scrollY, scrollPositions[i],
|
||||
"Scroll position not restored while going forward!");
|
||||
|
||||
is(await SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
return content.scrollY;
|
||||
}), scrollPositions[i],
|
||||
"Scroll position not restored while going forward!");
|
||||
}
|
||||
|
||||
|
||||
Services.prefs.clearUserPref("browser.navigation.requireUserInteraction");
|
||||
// Tell the framework the test is finished.
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -5,30 +5,32 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="setTimeout(nextTest, 0);"
|
||||
onload="setTimeout(runTest, 0);"
|
||||
title="bug 360511 test">
|
||||
|
||||
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
Services.prefs.setBoolPref("browser.navigation.requireUserInteraction", false);
|
||||
|
||||
// Define the generator-iterator for the tests.
|
||||
var tests = testIterator();
|
||||
|
||||
////
|
||||
// Execute the next test in the generator function.
|
||||
//
|
||||
function nextTest() {
|
||||
tests.next();
|
||||
function getScrollY()
|
||||
{
|
||||
return SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
return content.scrollY;
|
||||
});
|
||||
}
|
||||
function getLocation()
|
||||
{
|
||||
return SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
return content.location.href;
|
||||
});
|
||||
}
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 360511:
|
||||
// Fragment uri's in session history should be restored correctly
|
||||
// Bug 360511: Fragment uri's in session history should be restored correctly
|
||||
// upon back navigation.
|
||||
//
|
||||
function* testIterator()
|
||||
async function runTest()
|
||||
{
|
||||
// Case 1: load a page containing a fragment link; the page should be
|
||||
// stored in the bfcache.
|
||||
|
@ -37,91 +39,80 @@
|
|||
for (var i = 1; i < 3; i++)
|
||||
{
|
||||
var url = "bug360511_case" + i + ".html";
|
||||
doPageNavigation( {
|
||||
await promisePageNavigation( {
|
||||
uri: getHttpUrl(url),
|
||||
onNavComplete: nextTest,
|
||||
preventBFCache: i != 1
|
||||
} );
|
||||
yield undefined;
|
||||
|
||||
|
||||
// Store the original url for later comparison.
|
||||
var originalUrl = TestWindow.getBrowser().currentURI.spec;
|
||||
var originalDocLocation = TestWindow.getDocument().location.href;
|
||||
|
||||
var originalDocLocation = await getLocation();
|
||||
|
||||
// Verify we're at the top of the page.
|
||||
is(TestWindow.getWindow().scrollY, 0,
|
||||
"Page initially has a non-zero scrollY property");
|
||||
|
||||
is(await getScrollY(), 0, "Page initially has a non-zero scrollY property");
|
||||
|
||||
// Click the on the fragment link in the browser, and use setTimeout
|
||||
// to give the event a chance to be processed.
|
||||
var event = TestWindow.getDocument().createEvent('MouseEvent');
|
||||
event.initMouseEvent("click", true, true, TestWindow.getWindow(), 0,
|
||||
0, 0, 0, 0,
|
||||
false, false, false, false, 0, null);
|
||||
TestWindow.getDocument().getElementById("link1").dispatchEvent(event);
|
||||
waitForNextPaint(nextTest);
|
||||
yield undefined;
|
||||
await SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
var event = content.document.createEvent('MouseEvent');
|
||||
event.initMouseEvent("click", true, true, content, 0,
|
||||
0, 0, 0, 0,
|
||||
false, false, false, false, 0, null);
|
||||
content.document.getElementById("link1").dispatchEvent(event);
|
||||
});
|
||||
await promiseNextPaint();
|
||||
|
||||
// Verify we're no longer at the top of the page.
|
||||
waitForTrue(function() {
|
||||
return TestWindow.getWindow().scrollY > 0;
|
||||
}, nextTest, 20);
|
||||
yield undefined;
|
||||
|
||||
await promiseTrue(async function() {
|
||||
return await getScrollY() > 0;
|
||||
}, 20);
|
||||
|
||||
// Store the fragment url for later comparison.
|
||||
var fragmentUrl = TestWindow.getBrowser().currentURI.spec;
|
||||
var fragDocLocation = TestWindow.getDocument().location.href;
|
||||
|
||||
let fragDocLocation = await getLocation();
|
||||
|
||||
// Now navigate to any other page
|
||||
var expectedPageTitle = "bug360511 case " + i;
|
||||
doPageNavigation( {
|
||||
await promisePageNavigation( {
|
||||
uri: getHttpUrl("generic.html"),
|
||||
eventsToListenFor: ["pagehide", "pageshow"],
|
||||
expectedEvents: [ {type: "pagehide", title: expectedPageTitle,
|
||||
persisted: i == 1},
|
||||
{type: "pageshow"} ],
|
||||
onNavComplete: nextTest
|
||||
} );
|
||||
yield undefined;
|
||||
|
||||
|
||||
// Go back
|
||||
doPageNavigation( {
|
||||
await promisePageNavigation( {
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow"],
|
||||
expectedEvents: [ {type: "pageshow", title: expectedPageTitle,
|
||||
persisted: i == 1} ],
|
||||
onNavComplete: nextTest
|
||||
} );
|
||||
yield undefined;
|
||||
|
||||
|
||||
// Verify the current url is the fragment url
|
||||
is(TestWindow.getBrowser().currentURI.spec, fragmentUrl,
|
||||
"current url is not the previous fragment url");
|
||||
is(TestWindow.getDocument().location.href, fragDocLocation,
|
||||
"document.location is not the previous fragment url");
|
||||
is(await getLocation(), fragDocLocation,
|
||||
"document.location is not the previous fragment url");
|
||||
|
||||
// Go back again. Since we're just going from a fragment url to
|
||||
// parent url, no pageshow event is fired, so don't wait for any
|
||||
// events. Rather, just wait for the page's scrollY property to
|
||||
// events. Rather, just wait for the page's scrollY property to
|
||||
// change.
|
||||
var originalScrollY = TestWindow.getWindow().scrollY;
|
||||
var originalScrollY = await getScrollY();
|
||||
doPageNavigation( {
|
||||
back: true,
|
||||
eventsToListenFor: []
|
||||
} );
|
||||
waitForTrue(
|
||||
function() {
|
||||
return (TestWindow.getWindow().scrollY != originalScrollY);
|
||||
},
|
||||
function() {
|
||||
setTimeout(nextTest, 0);
|
||||
}, 20);
|
||||
yield undefined;
|
||||
|
||||
await promiseTrue(
|
||||
async function() {
|
||||
return (await getScrollY() != originalScrollY);
|
||||
}, 20);
|
||||
|
||||
// Verify the current url is the original url without fragment
|
||||
is(TestWindow.getBrowser().currentURI.spec, originalUrl,
|
||||
is(TestWindow.getBrowser().currentURI.spec, originalUrl,
|
||||
"current url is not the original url");
|
||||
is(TestWindow.getDocument().location.href, originalDocLocation,
|
||||
is(await getLocation(), originalDocLocation,
|
||||
"document.location is not the original url");
|
||||
}
|
||||
|
||||
|
@ -132,5 +123,5 @@
|
|||
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -10,105 +10,56 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="onLoad();"
|
||||
onload="runTest();"
|
||||
title="364461 test">
|
||||
|
||||
<script src="chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Services.prefs.setBoolPref("browser.navigation.requireUserInteraction", false);
|
||||
const LISTEN_EVENTS = ["load", "unload", "pageshow", "pagehide"];
|
||||
|
||||
var gBrowser;
|
||||
var gTestsIterator;
|
||||
var gExpected = [];
|
||||
|
||||
function ok(condition, message) {
|
||||
window.arguments[0].SimpleTest.ok(condition, message);
|
||||
}
|
||||
function is(a, b, message) {
|
||||
window.arguments[0].SimpleTest.is(a, b, message);
|
||||
}
|
||||
function finish() {
|
||||
for (let eventType of LISTEN_EVENTS) {
|
||||
gBrowser.removeEventListener(eventType, eventListener, true);
|
||||
}
|
||||
|
||||
window.close();
|
||||
window.arguments[0].SimpleTest.finish();
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
async function runTest() {
|
||||
gBrowser = document.getElementById("content");
|
||||
|
||||
for (let eventType of LISTEN_EVENTS) {
|
||||
gBrowser.addEventListener(eventType, eventListener, true);
|
||||
}
|
||||
|
||||
gTestsIterator = testsIterator();
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function eventListener(event) {
|
||||
ok(gExpected.length >= 1, "Unexpected event " + event.type);
|
||||
if (gExpected.length == 0) {
|
||||
// in case of unexpected event, try to continue anyway
|
||||
setTimeout(nextTest, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
var exp = gExpected.shift();
|
||||
is(event.type, exp.type, "Invalid event received");
|
||||
if (typeof(exp.persisted) != "undefined") {
|
||||
is(event.persisted, exp.persisted, "Invalid persisted state");
|
||||
}
|
||||
if (exp.title) {
|
||||
ok(event.originalTarget instanceof HTMLDocument,
|
||||
"originalTarget not a HTMLDocument");
|
||||
is(event.originalTarget.title, exp.title, "titles don't match");
|
||||
}
|
||||
|
||||
if (gExpected.length == 0) {
|
||||
setTimeout(nextTest, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
gTestsIterator.next();
|
||||
}
|
||||
|
||||
function* testsIterator() {
|
||||
// Tests 1 + 2:
|
||||
// Back/forward between two simple documents. Bfcache will be used.
|
||||
|
||||
var test1Doc = "data:text/html,<html><head><title>test1</title></head>" +
|
||||
"<body>test1</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", persisted: true},
|
||||
|
||||
{type: "load", title: "test1"},
|
||||
{type: "pageshow", title: "test1", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test1Doc);
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
uri: test1Doc,
|
||||
eventsToListenFor: ["load", "pageshow"],
|
||||
expectedEvents: [{type: "load", title: "test1"},
|
||||
{type: "pageshow", title: "test1", persisted: false}],
|
||||
});
|
||||
|
||||
var test2Doc = "data:text/html,<html><head><title>test2</title></head>" +
|
||||
"<body>test2</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test1", persisted: true},
|
||||
{type: "load", title: "test2"},
|
||||
{type: "pageshow", title: "test2", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test2Doc);
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
uri: test2Doc,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test1", persisted: true},
|
||||
{type: "load", title: "test2"},
|
||||
{type: "pageshow", title: "test2", persisted: false}],
|
||||
});
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test2", persisted: true},
|
||||
{type: "pageshow", title: "test1", persisted: true}];
|
||||
gBrowser.goBack();
|
||||
yield undefined;
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test1", persisted: true},
|
||||
{type: "pageshow", title: "test2", persisted: true}];
|
||||
gBrowser.goForward();
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test2", persisted: true},
|
||||
{type: "pageshow", title: "test1", persisted: true}],
|
||||
});
|
||||
|
||||
await promisePageNavigation({
|
||||
forward: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test1", persisted: true},
|
||||
{type: "pageshow", title: "test2", persisted: true}],
|
||||
});
|
||||
|
||||
// Tests 3 + 4:
|
||||
// Back/forward between a two-level deep iframed document and a simple
|
||||
|
@ -128,41 +79,49 @@
|
|||
"</iframe>" +
|
||||
"</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test2", persisted: true},
|
||||
{type: "load", title: "test3-nested2"},
|
||||
{type: "pageshow", title: "test3-nested2", persisted: false},
|
||||
{type: "load", title: "test3-nested1"},
|
||||
{type: "pageshow", title: "test3-nested1", persisted: false},
|
||||
{type: "load", title: "test3"},
|
||||
{type: "pageshow", title: "test3", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test3Doc);
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
uri: test3Doc,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test2", persisted: true},
|
||||
{type: "load", title: "test3-nested2"},
|
||||
{type: "pageshow", title: "test3-nested2", persisted: false},
|
||||
{type: "load", title: "test3-nested1"},
|
||||
{type: "pageshow", title: "test3-nested1", persisted: false},
|
||||
{type: "load", title: "test3"},
|
||||
{type: "pageshow", title: "test3", persisted: false}],
|
||||
});
|
||||
|
||||
var test4Doc = "data:text/html,<html><head><title>test4</title></head>" +
|
||||
"<body>test4</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test3", persisted: true},
|
||||
{type: "pagehide", title: "test3-nested1", persisted: true},
|
||||
{type: "pagehide", title: "test3-nested2", persisted: true},
|
||||
{type: "load", title: "test4"},
|
||||
{type: "pageshow", title: "test4", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test4Doc);
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
uri: test4Doc,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test3", persisted: true},
|
||||
{type: "pagehide", title: "test3-nested1", persisted: true},
|
||||
{type: "pagehide", title: "test3-nested2", persisted: true},
|
||||
{type: "load", title: "test4"},
|
||||
{type: "pageshow", title: "test4", persisted: false}],
|
||||
});
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test4", persisted: true},
|
||||
{type: "pageshow", title: "test3-nested2", persisted: true},
|
||||
{type: "pageshow", title: "test3-nested1", persisted: true},
|
||||
{type: "pageshow", title: "test3", persisted: true}];
|
||||
gBrowser.goBack();
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test4", persisted: true},
|
||||
{type: "pageshow", title: "test3-nested2", persisted: true},
|
||||
{type: "pageshow", title: "test3-nested1", persisted: true},
|
||||
{type: "pageshow", title: "test3", persisted: true}],
|
||||
});
|
||||
|
||||
// This is where the two nested pagehide are not dispatched in bug 364461
|
||||
gExpected = [{type: "pagehide", title: "test3", persisted: true},
|
||||
{type: "pagehide", title: "test3-nested1", persisted: true},
|
||||
{type: "pagehide", title: "test3-nested2", persisted: true},
|
||||
{type: "pageshow", title: "test4", persisted: true}];
|
||||
gBrowser.goForward();
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
forward: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test3", persisted: true},
|
||||
{type: "pagehide", title: "test3-nested1", persisted: true},
|
||||
{type: "pagehide", title: "test3-nested2", persisted: true},
|
||||
{type: "pageshow", title: "test4", persisted: true}],
|
||||
});
|
||||
|
||||
// Tests 5 + 6:
|
||||
// Back/forward between a document containing an unload handler and a
|
||||
|
@ -173,33 +132,41 @@
|
|||
"<body onunload='while(false) { /* nop */ }'>" +
|
||||
"test5</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test4", persisted: true},
|
||||
{type: "load", title: "test5"},
|
||||
{type: "pageshow", title: "test5", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test5Doc);
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
uri: test5Doc,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test4", persisted: true},
|
||||
{type: "load", title: "test5"},
|
||||
{type: "pageshow", title: "test5", persisted: false}],
|
||||
});
|
||||
|
||||
var test6Doc = "data:text/html,<html><head><title>test6</title></head>" +
|
||||
"<body>test6</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test5", persisted: false},
|
||||
{type: "unload", title: "test5"},
|
||||
{type: "load", title: "test6"},
|
||||
{type: "pageshow", title: "test6", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test6Doc);
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
uri: test6Doc,
|
||||
eventsToListenFor: ["load", "unload", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test5", persisted: false},
|
||||
{type: "unload", title: "test5"},
|
||||
{type: "load", title: "test6"},
|
||||
{type: "pageshow", title: "test6", persisted: false}],
|
||||
});
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test6", persisted: true},
|
||||
{type: "load", title: "test5"},
|
||||
{type: "pageshow", title: "test5", persisted: false}];
|
||||
gBrowser.goBack();
|
||||
yield undefined;
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test5", persisted: false},
|
||||
{type: "unload", title: "test5"},
|
||||
{type: "pageshow", title: "test6", persisted: true}];
|
||||
gBrowser.goForward();
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test6", persisted: true},
|
||||
{type: "load", title: "test5"},
|
||||
{type: "pageshow", title: "test5", persisted: false}],
|
||||
});
|
||||
|
||||
await promisePageNavigation({
|
||||
forward: true,
|
||||
eventsToListenFor: ["unload", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test5", persisted: false},
|
||||
{type: "unload", title: "test5"},
|
||||
{type: "pageshow", title: "test6", persisted: true}],
|
||||
});
|
||||
|
||||
// Test 7:
|
||||
// Testcase from https://bugzilla.mozilla.org/show_bug.cgi?id=384977#c10
|
||||
|
@ -217,49 +184,63 @@
|
|||
"</iframe>" +
|
||||
"</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test6", persisted: true},
|
||||
{type: "load", title: "test7-nested1"},
|
||||
{type: "pageshow", title: "test7-nested1", persisted: false},
|
||||
{type: "load", title: "test7"},
|
||||
{type: "pageshow", title: "test7", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test7Doc);
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
uri: test7Doc,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test6", persisted: true},
|
||||
{type: "load", title: "test7-nested1"},
|
||||
{type: "pageshow", title: "test7-nested1", persisted: false},
|
||||
{type: "load", title: "test7"},
|
||||
{type: "pageshow", title: "test7", persisted: false}],
|
||||
});
|
||||
|
||||
// Simulates a click on the link inside the iframe
|
||||
function clickIframeLink() {
|
||||
var iframe = gBrowser.contentDocument.getElementsByTagName("iframe")[0];
|
||||
var w = iframe.contentWindow;
|
||||
var d = iframe.contentDocument;
|
||||
SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
var iframe = content.document.getElementsByTagName("iframe")[0];
|
||||
var w = iframe.contentWindow;
|
||||
var d = iframe.contentDocument;
|
||||
|
||||
var evt = d.createEvent("MouseEvents");
|
||||
evt.initMouseEvent("click", true, true, w,
|
||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
d.getElementsByTagName("a")[0].dispatchEvent(evt);
|
||||
var evt = d.createEvent("MouseEvents");
|
||||
evt.initMouseEvent("click", true, true, w,
|
||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
d.getElementsByTagName("a")[0].dispatchEvent(evt);
|
||||
});
|
||||
}
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test7", persisted: true},
|
||||
{type: "pagehide", title: "test7-nested1", persisted: true},
|
||||
{type: "load"},
|
||||
{type: "pageshow", persisted: false}];
|
||||
let clicked = promisePageNavigation({
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test7", persisted: true},
|
||||
{type: "pagehide", title: "test7-nested1", persisted: true},
|
||||
{type: "load"},
|
||||
{type: "pageshow", persisted: false}],
|
||||
waitForEventsOnly: true,
|
||||
});
|
||||
clickIframeLink();
|
||||
yield undefined;
|
||||
|
||||
await clicked;
|
||||
|
||||
is(gBrowser.currentURI.spec, "data:text/plain,aaa",
|
||||
"Navigation is blocked when clicking link");
|
||||
|
||||
gExpected = [{type: "pagehide", persisted: true},
|
||||
{type: "pageshow", title: "test7-nested1", persisted: true},
|
||||
{type: "pageshow", title: "test7", persisted: true}];
|
||||
gBrowser.goBack();
|
||||
yield undefined;
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test7", persisted: true},
|
||||
{type: "pagehide", title: "test7-nested1", persisted: true},
|
||||
{type: "load"},
|
||||
{type: "pageshow", persisted: false}];
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", persisted: true},
|
||||
{type: "pageshow", title: "test7-nested1", persisted: true},
|
||||
{type: "pageshow", title: "test7", persisted: true}],
|
||||
});
|
||||
|
||||
clicked = promisePageNavigation({
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [{type: "pagehide", title: "test7", persisted: true},
|
||||
{type: "pagehide", title: "test7-nested1", persisted: true},
|
||||
{type: "load"},
|
||||
{type: "pageshow", persisted: false}],
|
||||
waitForEventsOnly: true,
|
||||
});
|
||||
clickIframeLink();
|
||||
yield undefined;
|
||||
|
||||
await clicked;
|
||||
|
||||
is(gBrowser.currentURI.spec, "data:text/plain,aaa",
|
||||
"Navigation is blocked when clicking link");
|
||||
|
||||
|
@ -268,5 +249,5 @@
|
|||
}
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -10,163 +10,123 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="onLoad();"
|
||||
onload="runTest();"
|
||||
title="396519 test">
|
||||
|
||||
<script src="chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Services.prefs.setBoolPref("browser.navigation.requireUserInteraction", false);
|
||||
const LISTEN_EVENTS = ["pageshow"];
|
||||
|
||||
var gBrowser;
|
||||
var gTestCount = 0;
|
||||
var gTestsIterator;
|
||||
var gExpected = [];
|
||||
|
||||
function ok(condition, message) {
|
||||
window.arguments[0].SimpleTest.ok(condition, message);
|
||||
}
|
||||
function is(a, b, message) {
|
||||
window.arguments[0].SimpleTest.is(a, b, message);
|
||||
}
|
||||
function finish() {
|
||||
for (let eventType of LISTEN_EVENTS) {
|
||||
gBrowser.removeEventListener(eventType, eventListener, true);
|
||||
}
|
||||
|
||||
window.close();
|
||||
window.arguments[0].SimpleTest.finish();
|
||||
async function navigateAndTest(params, expected) {
|
||||
await promisePageNavigation(params);
|
||||
++gTestCount;
|
||||
await doTest(expected);
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
gBrowser = document.getElementById("content");
|
||||
|
||||
for (let eventType of LISTEN_EVENTS) {
|
||||
gBrowser.addEventListener(eventType, eventListener, true);
|
||||
}
|
||||
|
||||
gTestsIterator = testsIterator();
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function eventListener(event) {
|
||||
// we're in pageshow, but we need to let that finish
|
||||
// content eviction and saving happen during pageshow, so when doTest
|
||||
// runs, we should should be in a testable state
|
||||
setTimeout(doTest, 0);
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
let history;
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
history = gBrowser.browsingContext.sessionHistory;
|
||||
} else {
|
||||
history = gBrowser.webNavigation.sessionHistory.legacySHistory;
|
||||
}
|
||||
|
||||
if (history.count == gExpected.length) {
|
||||
for (let i = 0; i < history.count; i++) {
|
||||
var shEntry = history.getEntryAtIndex(i).
|
||||
QueryInterface(Ci.nsISHEntry);
|
||||
is(shEntry.isInBFCache, gExpected[i], `BFCache for shentry[${i}], test ${gTestCount}`);
|
||||
async function doTest(expected) {
|
||||
function check(testCount, expected) {
|
||||
let history;
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
history = this.browsingContext.sessionHistory;
|
||||
} else {
|
||||
history = this.content.browsingContext.childSessionHistory.legacySHistory;
|
||||
}
|
||||
if (history.count == expected.length) {
|
||||
for (let i = 0; i < history.count; i++) {
|
||||
var shEntry = history.getEntryAtIndex(i).
|
||||
QueryInterface(Ci.nsISHEntry);
|
||||
is(shEntry.isInBFCache, expected[i], `BFCache for shentry[${i}], test ${testCount}`);
|
||||
}
|
||||
|
||||
// Make sure none of the SHEntries share bfcache entries with one
|
||||
// another.
|
||||
for (let i = 0; i < history.count; i++) {
|
||||
for (let j = 0; j < history.count; j++) {
|
||||
if (j == i)
|
||||
continue;
|
||||
// Make sure none of the SHEntries share bfcache entries with one
|
||||
// another.
|
||||
for (let i = 0; i < history.count; i++) {
|
||||
for (let j = 0; j < history.count; j++) {
|
||||
if (j == i)
|
||||
continue;
|
||||
|
||||
let shentry1 = history.getEntryAtIndex(i)
|
||||
.QueryInterface(Ci.nsISHEntry);
|
||||
let shentry2 = history.getEntryAtIndex(j)
|
||||
.QueryInterface(Ci.nsISHEntry);
|
||||
ok(!shentry1.sharesDocumentWith(shentry2),
|
||||
'Test ' + gTestCount + ': shentry[' + i + "] shouldn't " +
|
||||
"share document with shentry[" + j + ']');
|
||||
let shentry1 = history.getEntryAtIndex(i)
|
||||
.QueryInterface(Ci.nsISHEntry);
|
||||
let shentry2 = history.getEntryAtIndex(j)
|
||||
.QueryInterface(Ci.nsISHEntry);
|
||||
ok(!shentry1.sharesDocumentWith(shentry2),
|
||||
'Test ' + testCount + ': shentry[' + i + "] shouldn't " +
|
||||
"share document with shentry[" + j + ']');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
is(history.count, gExpected.length, "Wrong history length in test "+gTestCount);
|
||||
else {
|
||||
is(history.count, expected.length, "Wrong history length in test "+testCount);
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(nextTest, 0);
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
check.call(TestWindow.getBrowser(), gTestCount, expected);
|
||||
} else {
|
||||
await SpecialPowers.spawn(TestWindow.getBrowser(), [gTestCount, expected], check);
|
||||
}
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
gTestsIterator.next();
|
||||
}
|
||||
|
||||
function* testsIterator() {
|
||||
async function runTest() {
|
||||
// Tests 1 + 2:
|
||||
// Back/forward between two simple documents. Bfcache will be used.
|
||||
|
||||
var test1Doc = "data:text/html,<html><head><title>test1</title></head>" +
|
||||
"<body>test1</body></html>";
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [false];
|
||||
BrowserTestUtils.loadURI(gBrowser, test1Doc);
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
uri: test1Doc,
|
||||
}, [false]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [true, false];
|
||||
var test2Doc = test1Doc.replace(/1/,"2");
|
||||
BrowserTestUtils.loadURI(gBrowser, test2Doc);
|
||||
yield undefined;
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [true, true, false];
|
||||
BrowserTestUtils.loadURI(gBrowser, test1Doc);
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
uri: test2Doc,
|
||||
}, [true, false]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [true, true, true, false];
|
||||
BrowserTestUtils.loadURI(gBrowser, test2Doc);
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
uri: test1Doc,
|
||||
}, [true, true, false]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [false, true, true, true, false];
|
||||
BrowserTestUtils.loadURI(gBrowser, test1Doc);
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
uri: test2Doc,
|
||||
}, [true, true, true, false]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [false, false, true, true, true, false];
|
||||
BrowserTestUtils.loadURI(gBrowser, test2Doc);
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
uri: test1Doc,
|
||||
}, [false, true, true, true, false]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [false, false, true, true, false, true];
|
||||
gBrowser.goBack();
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
uri: test2Doc,
|
||||
}, [false, false, true, true, true, false]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [false, false, true, true, true, false];
|
||||
gBrowser.goForward();
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
back: true,
|
||||
}, [false, false, true, true, false, true]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [false, false, true, true, true, false];
|
||||
gBrowser.gotoIndex(1);
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
forward: true,
|
||||
}, [false, false, true, true, true, false]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [false, true, true, true, false, false];
|
||||
gBrowser.goBack();
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
gotoIndex: 1,
|
||||
}, [false, false, true, true, true, false]);
|
||||
|
||||
gTestCount++;
|
||||
gExpected = [false, false, true, true, false, false];
|
||||
gBrowser.gotoIndex(5);
|
||||
yield undefined;
|
||||
await navigateAndTest({
|
||||
back: true,
|
||||
}, [false, true, true, true, false, false]);
|
||||
|
||||
await navigateAndTest({
|
||||
gotoIndex: 5,
|
||||
}, [false, false, true, true, false, false]);
|
||||
|
||||
Services.prefs.clearUserPref("browser.navigation.requireUserInteraction");
|
||||
finish();
|
||||
}
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -46,6 +46,14 @@
|
|||
// of the pages are initially stored in the bfcache when
|
||||
// they're unloaded.
|
||||
for (var i = 0; i <= MAX_BFCACHE_PAGES + 1; i++) {
|
||||
let eventsToListenFor = ["pageshow"];
|
||||
let expectedEvents = [ { type: "pageshow",
|
||||
title: "bug396649 page" + i } ];
|
||||
if (i > 0) {
|
||||
eventsToListenFor.push("pagehide");
|
||||
expectedEvents.unshift({ type: "pagehide",
|
||||
title: "bug396649 page" + (i-1) });
|
||||
}
|
||||
doPageNavigation( {
|
||||
uri: "data:text/html,<!DOCTYPE html><html>" +
|
||||
"<head><title>bug396649 page" + i +
|
||||
|
@ -53,18 +61,13 @@
|
|||
"<body>" +
|
||||
"test page " + i +
|
||||
"</body></html>",
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
title: i == 0 ?
|
||||
undefined : "bug396649 page" + (i-1),
|
||||
persisted: true },
|
||||
{ type: "pageshow",
|
||||
title: "bug396649 page" + i } ],
|
||||
eventsToListenFor,
|
||||
expectedEvents,
|
||||
onNavComplete: nextTest
|
||||
} );
|
||||
yield undefined;
|
||||
}
|
||||
|
||||
|
||||
// Go back to the first page, one page at a time. The first
|
||||
// MAX_BFCACHE_PAGES pages loaded via back should come from the bfcache,
|
||||
// the last should not, since it should have been evicted during the
|
||||
|
@ -112,5 +115,5 @@
|
|||
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -1,77 +1,80 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<window title="Mozilla Bug 449780" onload="doTheTest()"
|
||||
<window title="Mozilla Bug 449780" onload="setTimeout(doTheTest, 0);"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<hbox id="parent">
|
||||
</hbox>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
/* globals SimpleTest, is, isnot */
|
||||
var imports = [ "SimpleTest", "is", "isnot" ];
|
||||
for (var name of imports) {
|
||||
window[name] = window.arguments[0][name];
|
||||
}
|
||||
|
||||
function $(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function addBrowser(parent, id, width, height) {
|
||||
function addBrowser(parent, width, height) {
|
||||
var b =
|
||||
document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "browser");
|
||||
b.setAttribute("type", "content");
|
||||
b.setAttribute("id", id);
|
||||
b.setAttribute("id", "content");
|
||||
b.setAttribute("width", width);
|
||||
b.setAttribute("height", height);
|
||||
$(parent).appendChild(b);
|
||||
b.setAttribute("remote", SpecialPowers.Services.appinfo.sessionHistoryInParent);
|
||||
document.getElementById("parent").appendChild(b);
|
||||
return b;
|
||||
}
|
||||
addBrowser("parent", "f1", 300, 200);
|
||||
addBrowser("parent", "f2", 300, 200);
|
||||
|
||||
let f1 = addBrowser("parent", 300, 200);
|
||||
|
||||
/** Test for Bug 449780 **/
|
||||
var doc1 = "data:text/html,<html><body>This is a test</body></html>";
|
||||
var doc2 = "data:text/html,<html><body>This is a second test</body></html>";
|
||||
|
||||
function getDOM(id) {
|
||||
return $(id).contentDocument.documentElement.innerHTML;
|
||||
}
|
||||
async function doTheTest() {
|
||||
await promisePageNavigation({
|
||||
uri: doc1,
|
||||
});
|
||||
let { origDOM, modifiedDOM } = await SpecialPowers.spawn(f1, [], () => {
|
||||
var origDOM = content.document.documentElement.innerHTML;
|
||||
content.document.body.textContent = "Modified";
|
||||
var modifiedDOM = content.document.documentElement.innerHTML;
|
||||
isnot(origDOM, modifiedDOM, "DOM should be different");
|
||||
return { origDOM, modifiedDOM };
|
||||
});
|
||||
|
||||
var tester = (function*() {
|
||||
var origDOM = getDOM("f1");
|
||||
$("f1").contentDocument.body.textContent = "Modified";
|
||||
var modifiedDOM = getDOM("f1");
|
||||
isnot(origDOM, modifiedDOM, "DOM should be different");
|
||||
$("f1").contentWindow.location.href = doc2;
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
uri: doc2,
|
||||
});
|
||||
|
||||
$("f1").goBack();
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
});
|
||||
|
||||
is(getDOM("f1"), modifiedDOM, "Should have been bfcached");
|
||||
$("f1").goForward();
|
||||
yield undefined;
|
||||
await SpecialPowers.spawn(f1, [modifiedDOM], (modifiedDOM) => {
|
||||
is(content.document.documentElement.innerHTML, modifiedDOM, "Should have been bfcached");
|
||||
});
|
||||
|
||||
// Ignore the notifications during swap
|
||||
$("f1").removeEventListener("pageshow", testDriver);
|
||||
$("f1").swapDocShells($("f2"));
|
||||
$("f2").addEventListener("pageshow", testDriver);
|
||||
$("f2").goBack();
|
||||
yield undefined;
|
||||
await promisePageNavigation({
|
||||
forward: true,
|
||||
});
|
||||
|
||||
is(getDOM("f2"), origDOM, "Should have not have been bfcached");
|
||||
window.close();
|
||||
SimpleTest.finish();
|
||||
})();
|
||||
f1.removeAttribute("id");
|
||||
let f2 = addBrowser("parent", 300, 200);
|
||||
|
||||
function testDriver() {
|
||||
setTimeout(function() { tester.next() }, 0);
|
||||
}
|
||||
// Make sure there's a document or the swap will fail.
|
||||
await promisePageNavigation({
|
||||
uri: "about:blank",
|
||||
});
|
||||
|
||||
function doTheTest() {
|
||||
$("f1").addEventListener("pageshow", testDriver);
|
||||
$("f1").setAttribute("src", doc1);
|
||||
f1.swapDocShells(f2);
|
||||
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
});
|
||||
|
||||
await SpecialPowers.spawn(f2, [origDOM], (origDOM) => {
|
||||
is(content.document.documentElement.innerHTML, origDOM, "Should not have been bfcached");
|
||||
});
|
||||
|
||||
finish();
|
||||
}
|
||||
]]></script>
|
||||
</window>
|
||||
|
|
|
@ -5,80 +5,70 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="nextTestAsync();"
|
||||
onload="runTest();"
|
||||
title="bug 582176 test">
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
// Define the generator-iterator for the tests.
|
||||
var tests = testIterator();
|
||||
|
||||
////
|
||||
// Execute the next test in the generator function.
|
||||
// Bug 582176.
|
||||
//
|
||||
function nextTestAsync() {
|
||||
SimpleTest.executeSoon(tests.next.bind(tests));
|
||||
}
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 582176:
|
||||
// Description goes here.
|
||||
//
|
||||
function* testIterator()
|
||||
async function runTest()
|
||||
{
|
||||
var browser = document.getElementById('content');
|
||||
browser.addEventListener("pageshow", nextTestAsync, true);
|
||||
|
||||
enableBFCache(true);
|
||||
|
||||
var notificationCount = 0;
|
||||
var observer = {
|
||||
observe(aSubject, aTopic, aData) {
|
||||
is(aSubject, browser.contentWindow,
|
||||
"correct subject");
|
||||
is(aTopic, "content-document-global-created",
|
||||
"correct topic");
|
||||
is(aData, "http://mochi.test:8888",
|
||||
"correct data");
|
||||
notificationCount++;
|
||||
}
|
||||
|
||||
let onGlobalCreation = () => {
|
||||
++notificationCount;
|
||||
};
|
||||
|
||||
let os = SpecialPowers.Services.obs;
|
||||
os.addObserver(observer, "content-document-global-created");
|
||||
|
||||
BrowserTestUtils.loadURI(browser, "http://mochi.test:8888/tests/docshell/test/chrome/582176_dummy.html");
|
||||
yield undefined;
|
||||
is(browser.contentWindow.testVar, undefined,
|
||||
await promisePageNavigation({
|
||||
uri: "http://mochi.test:8888/chrome/docshell/test/chrome/582176_dummy.html",
|
||||
onGlobalCreation,
|
||||
});
|
||||
is(await SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
let testVar = content.testVar;
|
||||
content.testVar = 1;
|
||||
return testVar;
|
||||
}), undefined,
|
||||
"variable unexpectedly there already");
|
||||
browser.contentWindow.wrappedJSObject.testVar = 1;
|
||||
is(notificationCount, 1, "Should notify on first navigation");
|
||||
|
||||
BrowserTestUtils.loadURI(browser, "http://mochi.test:8888/tests/docshell/test/chrome/582176_dummy.html?2");
|
||||
yield undefined;
|
||||
is(browser.contentWindow.wrappedJSObject.testVar, undefined,
|
||||
await promisePageNavigation({
|
||||
uri: "http://mochi.test:8888/chrome/docshell/test/chrome/582176_dummy.html?2",
|
||||
onGlobalCreation,
|
||||
});
|
||||
is(await SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
return content.testVar;
|
||||
}), undefined,
|
||||
"variable should no longer be there");
|
||||
is(notificationCount, 2, "Should notify on second navigation");
|
||||
|
||||
browser.goBack();
|
||||
yield undefined;
|
||||
is(browser.contentWindow.wrappedJSObject.testVar, 1,
|
||||
await promisePageNavigation({
|
||||
back: true,
|
||||
});
|
||||
is(await SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
return content.testVar;
|
||||
}), 1,
|
||||
"variable should still be there");
|
||||
is(notificationCount, 2, "Should not notify on back navigation");
|
||||
|
||||
BrowserTestUtils.loadURI(browser, "http://mochi.test:8888/tests/docshell/test/chrome/582176_xml.xml");
|
||||
yield undefined;
|
||||
is(browser.contentDocument.body.textContent, "xslt result",
|
||||
await promisePageNavigation({
|
||||
uri: "http://mochi.test:8888/chrome/docshell/test/chrome/582176_xml.xml",
|
||||
onGlobalCreation,
|
||||
});
|
||||
is(await SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
return content.document.body.textContent;
|
||||
}), "xslt result",
|
||||
"Transform performed successfully");
|
||||
is(notificationCount, 3, "Should notify only once on XSLT navigation");
|
||||
|
||||
os.removeObserver(observer, "content-document-global-created")
|
||||
|
||||
// Tell the framework the test is finished.
|
||||
finish();
|
||||
}
|
||||
|
||||
]]></script>
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="setTimeout(nextTest, 0);"
|
||||
onload="setTimeout(runTest, 0);"
|
||||
title="bug 662200 test">
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" />
|
||||
|
@ -13,31 +13,18 @@
|
|||
<script type="application/javascript"><![CDATA[
|
||||
Services.prefs.setBoolPref("browser.navigation.requireUserInteraction", false);
|
||||
|
||||
// Define the generator-iterator for the tests.
|
||||
var tests = testIterator();
|
||||
|
||||
////
|
||||
// Execute the next test in the generator function.
|
||||
// Bug 662200
|
||||
//
|
||||
function nextTest() {
|
||||
tests.next();
|
||||
}
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 662200:
|
||||
// Description goes here.
|
||||
//
|
||||
function* testIterator()
|
||||
async function runTest()
|
||||
{
|
||||
// Load the first test page
|
||||
var navData = {
|
||||
uri: getHttpUrl("662200a.html"),
|
||||
eventsToListenFor: ["pageshow"],
|
||||
expectedEvents: [ {type: "pageshow", title: "A"} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
doPageNavigation(navData);
|
||||
yield undefined;
|
||||
await promisePageNavigation(navData);
|
||||
|
||||
// Load the second test page.
|
||||
navData = {
|
||||
|
@ -46,15 +33,16 @@
|
|||
title: "A"},
|
||||
{type: "pageshow",
|
||||
title: "B"} ],
|
||||
onNavComplete: nextTest
|
||||
}
|
||||
waitForPageEvents(navData);
|
||||
var link = TestWindow.getDocument().getElementById("link");
|
||||
var event = TestWindow.getDocument().createEvent("MouseEvents");
|
||||
event.initMouseEvent("click", true, true, TestWindow.getWindow(),
|
||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
link.dispatchEvent(event);
|
||||
yield undefined;
|
||||
let clicked = promisePageEvents(navData);
|
||||
SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
var link = content.document.getElementById("link");
|
||||
var event = content.document.createEvent("MouseEvents");
|
||||
event.initMouseEvent("click", true, true, content,
|
||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
link.dispatchEvent(event);
|
||||
});
|
||||
await clicked;
|
||||
|
||||
// Load the third test page.
|
||||
navData = {
|
||||
|
@ -63,15 +51,16 @@
|
|||
title: "B"},
|
||||
{type: "pageshow",
|
||||
title: "C"} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
waitForPageEvents(navData);
|
||||
link = TestWindow.getDocument().getElementById("link");
|
||||
event = TestWindow.getDocument().createEvent("MouseEvents");
|
||||
event.initMouseEvent("click", true, true, TestWindow.getWindow(),
|
||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
link.dispatchEvent(event);
|
||||
yield undefined;
|
||||
clicked = promisePageEvents(navData);
|
||||
SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
var link = content.document.getElementById("link");
|
||||
var event = content.document.createEvent("MouseEvents");
|
||||
event.initMouseEvent("click", true, true, content,
|
||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
link.dispatchEvent(event);
|
||||
});
|
||||
await clicked;
|
||||
|
||||
// Go back.
|
||||
navData = {
|
||||
|
@ -81,18 +70,8 @@
|
|||
title: "C"},
|
||||
{type: "pageshow",
|
||||
title: "B"} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
doPageNavigation(navData);
|
||||
yield undefined;
|
||||
|
||||
var docshell = TestWindow.getWindow().docShell;
|
||||
let shistory;
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
shistory = docshell.browsingContext.sessionHistory;
|
||||
} else {
|
||||
shistory = docshell.sessionHistory.legacySHistory;
|
||||
}
|
||||
await promisePageNavigation(navData);
|
||||
|
||||
// Reload.
|
||||
navData = {
|
||||
|
@ -101,20 +80,33 @@
|
|||
title: "B"},
|
||||
{type: "pageshow",
|
||||
title: "B"} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
// Asking the docshell harness to reload for us will call reload on
|
||||
// nsDocShell which has different behavior than the reload on nsSHistory
|
||||
// so we call reloadCurrentEntry() (which is equivalent to reload(0) and
|
||||
// visible from JS) explicitly here.
|
||||
waitForPageEvents(navData);
|
||||
shistory.reloadCurrentEntry();
|
||||
yield undefined;
|
||||
let reloaded = promisePageEvents(navData);
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
TestWindow.getBrowser().browsingContext.sessionHistory.reloadCurrentEntry();
|
||||
} else {
|
||||
SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory.legacySHistory.reloadCurrentEntry();
|
||||
});
|
||||
}
|
||||
await reloaded;
|
||||
|
||||
// After this sequence of events, we should be able to go back and forward
|
||||
is(TestWindow.getBrowser().canGoBack, true, "Should be able to go back!");
|
||||
is(TestWindow.getBrowser().canGoForward, true, "Should be able to go forward!");
|
||||
is(shistory.requestedIndex, -1, "Requested index should be cleared!");
|
||||
let requestedIndex;
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
requestedIndex = TestWindow.getBrowser().browsingContext.sessionHistory.requestedIndex;
|
||||
} else {
|
||||
requestedIndex = await SpecialPowers.spawn(TestWindow.getBrowser(), [], () => {
|
||||
return docShell.sessionHistory.legacySHistory.requestedIndex;
|
||||
})
|
||||
}
|
||||
is(requestedIndex, -1, "Requested index should be cleared!");
|
||||
|
||||
Services.prefs.clearUserPref("browser.navigation.requireUserInteraction");
|
||||
// Tell the framework the test is finished.
|
||||
|
@ -123,5 +115,5 @@
|
|||
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -95,29 +95,18 @@
|
|||
});
|
||||
yield undefined;
|
||||
|
||||
function generateDetector(state, hidden, title, name) {
|
||||
var detector = function (event) {
|
||||
is(event.target.hidden, hidden,
|
||||
name + " hidden value does not match");
|
||||
is(event.target.visibilityState, state,
|
||||
name + " state value does not match");
|
||||
is(event.target.title, title,
|
||||
name + " title value does not match");
|
||||
document.getElementById("content")
|
||||
.removeEventListener("visibilitychange",
|
||||
detector,
|
||||
true);
|
||||
nextTest();
|
||||
}
|
||||
waitForPageEvents({
|
||||
eventsToListenFor: [ "visibilitychange" ],
|
||||
expectedEvents: [ { type: "visibilitychange",
|
||||
title: "new load",
|
||||
visibilityState: "hidden",
|
||||
hidden: true },
|
||||
],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
|
||||
document.getElementById("content")
|
||||
.addEventListener("visibilitychange", detector, true);
|
||||
}
|
||||
|
||||
generateDetector("hidden", true, "new load", "Going hidden");
|
||||
|
||||
// Now flip our docshell to not active
|
||||
document.getElementById("content").docShellIsActive = false;
|
||||
TestWindow.getBrowser().docShellIsActive = false;
|
||||
yield undefined;
|
||||
|
||||
// And navigate back; there should be no visibility state transitions
|
||||
|
@ -136,10 +125,18 @@
|
|||
});
|
||||
yield undefined;
|
||||
|
||||
generateDetector("visible", false, "initial load", "Going visible");
|
||||
waitForPageEvents({
|
||||
eventsToListenFor: [ "visibilitychange" ],
|
||||
expectedEvents: [ { type: "visibilitychange",
|
||||
title: "initial load",
|
||||
visibilityState: "visible",
|
||||
hidden: false },
|
||||
],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
|
||||
// Now set the docshell active again
|
||||
document.getElementById("content").docShellIsActive = true;
|
||||
TestWindow.getBrowser().docShellIsActive = true;
|
||||
yield undefined;
|
||||
|
||||
// And forward
|
||||
|
@ -170,5 +167,5 @@
|
|||
}
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -13,74 +13,18 @@
|
|||
onload="onLoad();"
|
||||
title="92598 test">
|
||||
|
||||
<script src="chrome://mochikit/content/chrome-harness.js" />
|
||||
<script type="application/javascript" src="docshell_helpers.js" />
|
||||
<script type="application/javascript"><![CDATA[
|
||||
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
|
||||
const LISTEN_EVENTS = ["load", "unload", "pageshow", "pagehide"];
|
||||
|
||||
var gBrowser;
|
||||
var gTestsIterator;
|
||||
var gExpected = [];
|
||||
|
||||
function ok(condition, message) {
|
||||
window.arguments[0].SimpleTest.ok(condition, message);
|
||||
}
|
||||
|
||||
function is(a, b, message) {
|
||||
window.arguments[0].SimpleTest.is(a, b, message);
|
||||
}
|
||||
|
||||
function finish() {
|
||||
for (let eventType of LISTEN_EVENTS) {
|
||||
gBrowser.removeEventListener(eventType, eventListener, true);
|
||||
}
|
||||
|
||||
// Work around bug 467960
|
||||
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
|
||||
let history = gBrowser.browsingContext.sessionHistory;
|
||||
history.purgeHistory(history.count);
|
||||
} else {
|
||||
let history = gBrowser.webNavigation.sessionHistory;
|
||||
history.legacySHistory.purgeHistory(history.count);
|
||||
}
|
||||
|
||||
window.close();
|
||||
window.arguments[0].SimpleTest.finish();
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
gBrowser = document.getElementById("content");
|
||||
for (let eventType of LISTEN_EVENTS) {
|
||||
gBrowser.addEventListener(eventType, eventListener, true);
|
||||
}
|
||||
|
||||
gTestsIterator = testsIterator();
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function eventListener(event) {
|
||||
ok(gExpected.length >= 1, "Unexpected event " + event.type);
|
||||
if (gExpected.length == 0) {
|
||||
// in case of unexpected event, try to continue anyway
|
||||
setTimeout(nextTest, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
var exp = gExpected.shift();
|
||||
is(event.type, exp.type, "Invalid event received");
|
||||
if (typeof(exp.persisted) != "undefined") {
|
||||
is(event.persisted, exp.persisted, "Invalid persisted state");
|
||||
}
|
||||
if (exp.title) {
|
||||
ok(event.originalTarget instanceof HTMLDocument,
|
||||
"originalTarget not a HTMLDocument");
|
||||
is(event.originalTarget.title, exp.title, "titles don't match");
|
||||
}
|
||||
|
||||
if (gExpected.length == 0) {
|
||||
setTimeout(nextTest, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
gTestsIterator.next();
|
||||
}
|
||||
|
@ -88,35 +32,58 @@
|
|||
function* testsIterator() {
|
||||
// Load a page with a no-cache header, followed by a simple page
|
||||
// On pagehide, first page should report it is not being persisted
|
||||
var test1DocURI = "http://mochi.test:8888/tests/docshell/test/chrome/92598_nostore.html";
|
||||
var test1DocURI = "http://mochi.test:8888/chrome/docshell/test/chrome/92598_nostore.html";
|
||||
|
||||
gExpected = [{type: "pagehide", persisted: true},
|
||||
{type: "load", title: "test1"},
|
||||
{type: "pageshow", title: "test1", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test1DocURI);
|
||||
doPageNavigation({
|
||||
uri: test1DocURI,
|
||||
eventsToListenFor: ["load", "pageshow"],
|
||||
expectedEvents: [ { type: "load",
|
||||
title: "test1" },
|
||||
{ type: "pageshow",
|
||||
title: "test1",
|
||||
persisted: false } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
var test2Doc = "data:text/html,<html><head><title>test2</title></head>" +
|
||||
"<body>test2</body></html>";
|
||||
|
||||
gExpected = [{type: "pagehide", title: "test1", persisted: false},
|
||||
{type: "unload", title: "test1"},
|
||||
{type: "load", title: "test2"},
|
||||
{type: "pageshow", title: "test2", persisted: false}];
|
||||
BrowserTestUtils.loadURI(gBrowser, test2Doc);
|
||||
doPageNavigation({
|
||||
uri: test2Doc,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
title: "test1",
|
||||
persisted: false },
|
||||
{ type: "load",
|
||||
title: "test2" },
|
||||
{ type: "pageshow",
|
||||
title: "test2",
|
||||
persisted: false } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
// Now go back in history. First page should not have been cached.
|
||||
// Check persisted property to confirm
|
||||
gExpected = [{type: "pagehide", title: "test2", persisted: true},
|
||||
{type: "load", title: "test1"},
|
||||
{type: "pageshow", title: "test1", persisted: false}];
|
||||
gBrowser.goBack();
|
||||
doPageNavigation({
|
||||
back: true,
|
||||
eventsToListenFor: ["load", "pageshow", "pagehide"],
|
||||
expectedEvents: [ { type: "pagehide",
|
||||
title: "test2",
|
||||
persisted: true },
|
||||
{ type: "load",
|
||||
title: "test1" },
|
||||
{ type: "pageshow",
|
||||
title: "test1",
|
||||
persisted: false } ],
|
||||
onNavComplete: nextTest
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
finish();
|
||||
}
|
||||
]]></script>
|
||||
|
||||
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
|
||||
<browser type="content" primary="true" flex="1" id="content" remote="true" />
|
||||
</window>
|
||||
|
|
|
@ -5,8 +5,6 @@ support-files =
|
|||
662200b.html
|
||||
662200c.html
|
||||
89419.html
|
||||
92598_nostore.html
|
||||
bug112564_window.xhtml
|
||||
bug113934_window.xhtml
|
||||
bug215405_window.xhtml
|
||||
bug293235.html
|
||||
|
@ -33,7 +31,6 @@ support-files =
|
|||
bug449778_window.xhtml
|
||||
bug449780_window.xhtml
|
||||
bug454235-subframe.xhtml
|
||||
bug582176_window.xhtml
|
||||
bug608669.xhtml
|
||||
bug662200_window.xhtml
|
||||
bug690056_window.xhtml
|
||||
|
@ -41,7 +38,6 @@ support-files =
|
|||
bug89419_window.xhtml
|
||||
bug909218.html
|
||||
bug909218.js
|
||||
bug92598_window.xhtml
|
||||
docshell_helpers.js
|
||||
DocShellHelpers.jsm
|
||||
file_viewsource_forbidden_in_iframe.html
|
||||
|
@ -51,6 +47,10 @@ support-files =
|
|||
|
||||
[test_allowContentRetargeting.html]
|
||||
[test_bug112564.xhtml]
|
||||
support-files =
|
||||
bug112564_window.xhtml
|
||||
112564_nocache.html
|
||||
112564_nocache.html^headers^
|
||||
[test_bug113934.xhtml]
|
||||
[test_bug215405.xhtml]
|
||||
[test_bug293235.xhtml]
|
||||
|
@ -77,6 +77,11 @@ skip-if = (os == 'win' && processor == 'aarch64') # bug 1533814
|
|||
[test_bug565388.xhtml]
|
||||
skip-if = true # Bug 1026815,Bug 1546159
|
||||
[test_bug582176.xhtml]
|
||||
support-files =
|
||||
582176_dummy.html
|
||||
582176_xml.xml
|
||||
582176_xslt.xsl
|
||||
bug582176_window.xhtml
|
||||
[test_bug608669.xhtml]
|
||||
[test_bug662200.xhtml]
|
||||
[test_bug690056.xhtml]
|
||||
|
@ -85,6 +90,10 @@ skip-if = true # Bug 1026815,Bug 1546159
|
|||
[test_bug89419.xhtml]
|
||||
[test_bug909218.html]
|
||||
[test_bug92598.xhtml]
|
||||
support-files =
|
||||
92598_nostore.html
|
||||
92598_nostore.html^headers^
|
||||
bug92598_window.xhtml
|
||||
[test_open_and_immediately_close_opener.html]
|
||||
# This bug only manifests in the non-e10s window open codepath. The test
|
||||
# should be updated to make sure it still opens a new window in the parent
|
||||
|
|
Загрузка…
Ссылка в новой задаче