// Listen to the first callback, since this indicates that the page loaded. var page1LoadCallbackEnabled = true;
function page1Load() {
if (page1LoadCallbackEnabled) {
page1LoadCallbackEnabled = false;
dump("Got page1 load.\n");
pageLoad();
} else {
dump("Ignoring page1 load.\n");
}
}
var page1PageShowCallbackEnabled = false;
function page1PageShow() {
if (page1PageShowCallbackEnabled) {
page1PageShowCallbackEnabled = false;
dump("Got page1 pageshow.\n");
pageLoad();
} else {
dump("Ignoring page1 pageshow.\n");
}
}
var page2LoadCallbackEnabled = false;
function page2Load() {
if (page2LoadCallbackEnabled) {
page2LoadCallbackEnabled = false;
dump("Got page2 popstate.\n");
pageLoad();
} else {
dump("Ignoring page2 popstate.\n");
}
}
var page2PopstateCallbackEnabled = false;
function page2Popstate() {
if (page2PopstateCallbackEnabled) {
page2PopstateCallbackEnabled = false;
dump("Got page2 popstate.\n");
pageLoad();
} else {
dump("Ignoring page2 popstate.\n");
}
}
var page2PageShowCallbackEnabled = false;
function page2PageShow() {
if (page2PageShowCallbackEnabled) {
page2PageShowCallbackEnabled = false;
dump("Got page2 pageshow.\n");
pageLoad();
} else {
dump("Ignoring page2 pageshow.\n");
}
}
var popup = window.open("file_bug590573_1.html");
var gTestContinuation = null; var loads = 0;
function pageLoad() {
loads++;
dump("pageLoad(loads=" + loads + ", page location=" + popup.location + ")\n");
if (!gTestContinuation) {
gTestContinuation = testBody();
} var ret = gTestContinuation.next();
if (ret.done) {
SimpleTest.finish();
}
}
popup.history.pushState("", "", "?pushed");
is(Math.round(popup.scrollY), 100, "test 2");
popup.scroll(0, 200); // set state-2's position to 200
popup.history.back();
continueAsync();
yield;
is(Math.round(popup.scrollY), 100, "test 3");
popup.scroll(0, 150); // set original page's position to 150
// At this point, the history looks like:
// PATH POSITION
// file_bug590573_1.html 150 <-- oldest
// file_bug590573_1.html?pushed 200 <-- newest, current
// Now test that the scroll position is persisted when we have real
// navigations involved. First, we need to spin the event loop so that the
// navigation doesn't replace our current history entry.
// We need to spin the event loop again before we go back, otherwise the
// scroll positions don't get updated properly.
setTimeout(pageLoad, 0);
yield;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.