mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-09-10 11:54:40 +00:00
237 lines
6.2 KiB
HTML
237 lines
6.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=590573
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 590573</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=590573">Mozilla Bug 590573</a>
|
|
|
|
<script type='application/javascript;version=1.7'>
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
// 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 page1PopstateCallbackEnabled = false;
|
|
function page1Popstate()
|
|
{
|
|
if (page1PopstateCallbackEnabled) {
|
|
page1PopstateCallbackEnabled = false;
|
|
dump('Got page1 popstate.\n');
|
|
pageLoad();
|
|
}
|
|
else {
|
|
dump('Ignoring page1 popstate.\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');
|
|
}
|
|
}
|
|
|
|
function dumpSHistory(theWindow)
|
|
{
|
|
let sh = SpecialPowers.wrap(theWindow).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
|
|
.getInterface(SpecialPowers.Ci.nsIWebNavigation)
|
|
.sessionHistory;
|
|
if (!sh) {
|
|
dump(" window has no shistory.\n");
|
|
return;
|
|
}
|
|
|
|
dump(" count: " + sh.count + "\n");
|
|
dump(" index: " + sh.index + "\n");
|
|
dump(" requestedIndex: " + sh.requestedIndex + "\n");
|
|
|
|
for (let i = 0; i < sh.count; i++) {
|
|
let shentry = sh.getEntryAtIndex(i, false);
|
|
dump(" " + i + ": " + shentry.URI.spec + '\n');
|
|
shentry.QueryInterface(SpecialPowers.Ci.nsISHContainer);
|
|
for (let j = 0; j < shentry.childCount; j++) {
|
|
let child = shentry.GetChildAt(j);
|
|
dump(" child " + j + ": " + child.URI.spec + '\n');
|
|
}
|
|
}
|
|
|
|
return sh;
|
|
}
|
|
|
|
var popup = window.open('file_bug590573_1.html');
|
|
|
|
var loads = 0;
|
|
function pageLoad()
|
|
{
|
|
loads++;
|
|
dump('pageLoad(loads=' + loads + ', page location=' + popup.location + ')\n');
|
|
|
|
dumpSHistory(window);
|
|
|
|
if (loads == 1) {
|
|
is(popup.scrollY, 0, "test 1");
|
|
popup.scroll(0, 100);
|
|
|
|
popup.history.pushState('', '', '?pushed');
|
|
is(popup.scrollY, 100, "test 2");
|
|
popup.scroll(0, 200); // set state-2's position to 200
|
|
|
|
popup.history.back();
|
|
is(popup.scrollY, 100, "test 3");
|
|
popup.scroll(0, 150); // set original page's position to 150
|
|
|
|
popup.history.forward();
|
|
is(popup.scrollY, 200, "test 4");
|
|
|
|
popup.history.back();
|
|
is(popup.scrollY, 150, "test 5");
|
|
|
|
popup.history.forward();
|
|
is(popup.scrollY, 200, "test 6");
|
|
|
|
// 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.
|
|
|
|
setTimeout(pageLoad, 0);
|
|
}
|
|
else if (loads == 2) {
|
|
page2LoadCallbackEnabled = true;
|
|
popup.location = 'file_bug590573_2.html';
|
|
}
|
|
else if (loads == 3) {
|
|
ok(popup.location.href.match('file_bug590573_2.html$'),
|
|
"Location was " + popup.location +
|
|
" but should end with file_bug590573_2.html");
|
|
|
|
is(popup.scrollY, 0, "test 7");
|
|
popup.scroll(0, 300);
|
|
|
|
// We need to spin the event loop again before we go back, otherwise the
|
|
// scroll positions don't get updated properly.
|
|
setTimeout(pageLoad, 0);
|
|
}
|
|
else if (loads == 4) {
|
|
page1PageShowCallbackEnabled = true;
|
|
popup.history.back();
|
|
}
|
|
else if (loads == 5) {
|
|
// Spin the event loop again so that we get the right scroll positions.
|
|
setTimeout(pageLoad, 0);
|
|
}
|
|
else if (loads == 6) {
|
|
is(popup.location.search, "?pushed");
|
|
ok(popup.document.getElementById('div1'), 'page should have div1.');
|
|
|
|
// Bug 821821, on android 4.0.4 on panda we get 199 instead of 200
|
|
if (popup.scrollY >= 199 && popup.scrollY <= 200) {
|
|
is(1, 1, "test 8");
|
|
} else {
|
|
is(1, 0, "test 8, got " + popup.scrollY + " for popup.scrollY instead of 199|200");
|
|
}
|
|
|
|
popup.history.back();
|
|
is(popup.scrollY, 150, "test 9");
|
|
popup.history.forward();
|
|
|
|
// Bug 821821, on android 4.0.4 on panda we get 199 instead of 200
|
|
if (popup.scrollY >= 199 && popup.scrollY <= 200) {
|
|
is(1, 1, "test 10");
|
|
} else {
|
|
is(1, 0, "test 10, got " + popup.scrollY + " for popup.scrollY instead of 199|200");
|
|
}
|
|
|
|
// Spin one last time...
|
|
setTimeout(pageLoad, 0);
|
|
}
|
|
else if (loads == 7) {
|
|
page2PageShowCallbackEnabled = true;
|
|
popup.history.forward();
|
|
}
|
|
else if (loads == 8) {
|
|
// Bug 821821, on Android tegras we get 299 instead of 300 sometimes
|
|
if (popup.scrollY >= 299 && popup.scrollY <= 300) {
|
|
is(1, 1, "test 11");
|
|
} else {
|
|
is(1, 0, "test 11, got " + popup.scrollY + " for popup.scrollY instead of 299|300");
|
|
}
|
|
popup.close();
|
|
SimpleTest.finish();
|
|
}
|
|
else {
|
|
ok(false, "Got extra load!");
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|