mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 17:31:47 +09:00
JS - make window.pageYOffset/pageXOffset/scrollX/scrollY double
This commit is contained in:
parent
e64a819dc3
commit
49ffafc979
16 changed files with 133 additions and 55 deletions
19
docshell/test/file_bug1151421.html
Normal file
19
docshell/test/file_bug1151421.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body, html {
|
||||
height: 100%;
|
||||
}
|
||||
.spacer {
|
||||
height: 80%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload='(parent || opener).childLoad()'>
|
||||
|
||||
<div class="spacer"></div>
|
||||
<div id="content">content</div>
|
||||
<div class="spacer"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -32,6 +32,7 @@ support-files =
|
|||
file_bug680257.html
|
||||
file_bug703855.html
|
||||
file_bug728939.html
|
||||
file_bug1151421.html
|
||||
file_pushState_after_document_open.html
|
||||
historyframes.html
|
||||
|
||||
|
|
@ -85,6 +86,7 @@ support-files = file_bug668513.html
|
|||
[test_bug797909.html]
|
||||
[test_bug1045096.html]
|
||||
[test_bug1121701.html]
|
||||
[test_bug1151421.html]
|
||||
[test_bug1186774.html]
|
||||
[test_forceinheritprincipal_overrule_owner.html]
|
||||
[test_framedhistoryframes.html]
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
}
|
||||
case 2: {
|
||||
opener.is(event.persisted, false, "Shouldn't have persisted session history entry.");
|
||||
opener.isnot(window.scrollY, 0, "Should have restored scrolling.");
|
||||
opener.isnot(Math.round(window.scrollY), 0, "Should have restored scrolling.");
|
||||
opener.is(history.scrollRestoration, "auto", "Should have the same scrollRestoration as before reload.");
|
||||
history.scrollRestoration = "manual";
|
||||
window.onunload = function() {} // Disable bfcache.
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
}
|
||||
case 4: {
|
||||
opener.is(event.persisted, true, "Should have persisted session history entry.");
|
||||
opener.isnot(window.scrollY, 0, "Should have kept the old scroll position.");
|
||||
opener.isnot(Math.round(window.scrollY), 0, "Should have kept the old scroll position.");
|
||||
opener.is(history.scrollRestoration, "manual", "Should have the same scrollRestoration as before reload.");
|
||||
window.scrollTo(0, 0);
|
||||
window.location.hash = "hash";
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
break;
|
||||
}
|
||||
case 5: {
|
||||
opener.isnot(window.scrollY, 0, "Should have scrolled to #hash.");
|
||||
opener.isnot(Math.round(window.scrollY), 0, "Should have scrolled to #hash.");
|
||||
opener.is(history.scrollRestoration, "manual", "Should have the same scrollRestoration mode as before fragment navigation.");
|
||||
window.onunload = function() {} // Disable bfcache.
|
||||
opener.setTimeout("is(testWindow.history.scrollRestoration, 'auto'); testWindow.history.back();", 250);
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
history.pushState({ state: "state2" }, "state2");
|
||||
window.scrollTo(0, 0);
|
||||
history.back();
|
||||
opener.isnot(window.scrollY, 0, "Should have scrolled back to the state1's position");
|
||||
opener.isnot(Math.round(window.scrollY), 0, "Should have scrolled back to the state1's position");
|
||||
opener.is(history.state.state, "state1", "Unexpected state.");
|
||||
|
||||
history.scrollRestoration = "manual";
|
||||
|
|
@ -79,17 +79,17 @@
|
|||
history.pushState({ state: "state4" }, "state4");
|
||||
window.scrollTo(0, 0);
|
||||
history.back();
|
||||
opener.is(window.scrollY, 0, "Shouldn't have scrolled back to the state3's position");
|
||||
opener.is(Math.round(window.scrollY), 0, "Shouldn't have scrolled back to the state3's position");
|
||||
opener.is(history.state.state, "state3", "Unexpected state.");
|
||||
|
||||
history.pushState({ state: "state5" }, "state5");
|
||||
history.scrollRestoration = "auto";
|
||||
document.getElementById("bottom").scrollIntoView();
|
||||
opener.isnot(window.scrollY, 0, "Should have scrolled to 'bottom'.");
|
||||
opener.isnot(Math.round(window.scrollY), 0, "Should have scrolled to 'bottom'.");
|
||||
history.back();
|
||||
window.scrollTo(0, 0);
|
||||
history.forward();
|
||||
opener.isnot(window.scrollY, 0, "Should have scrolled back to the state5's position");
|
||||
opener.isnot(Math.round(window.scrollY), 0, "Should have scrolled back to the state5's position");
|
||||
|
||||
var ifr = document.createElement("iframe");
|
||||
ifr.src = "data:text/html,";
|
||||
|
|
|
|||
61
docshell/test/test_bug1151421.html
Normal file
61
docshell/test/test_bug1151421.html
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1151421
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1151421</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.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=1151421">Mozilla Bug 1151421</a>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1151421 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function childLoad() {
|
||||
// Spin the event loop so we leave the onload handler.
|
||||
SimpleTest.executeSoon(childLoad2);
|
||||
}
|
||||
|
||||
function childLoad2() {
|
||||
let cw = iframe.contentWindow;
|
||||
let content = cw.document.getElementById("content");
|
||||
|
||||
// Create a function to calculate an invariant.
|
||||
let topPlusOffset = function()
|
||||
{
|
||||
return Math.round(content.getBoundingClientRect().top + cw.pageYOffset);
|
||||
}
|
||||
|
||||
let initialTPO = topPlusOffset();
|
||||
|
||||
// Scroll the iframe to various positions, and check the TPO.
|
||||
// Scrolling down to the bottom will adjust the page offset by a fractional amount.
|
||||
let positions = [-100, 0.17, 0, 1.5, 10.41, 1e6, 12.1];
|
||||
|
||||
// Run some tests with scrollTo() and ensure we have the same invariant after scrolling.
|
||||
positions.forEach(function(pos) {
|
||||
cw.scrollTo(0, pos);
|
||||
is(topPlusOffset(), initialTPO, "Top plus offset should remain invariant across scrolling.");
|
||||
});
|
||||
|
||||
positions.reverse().forEach(function(pos) {
|
||||
cw.scrollTo(0, pos);
|
||||
is(topPlusOffset(), initialTPO, "(reverse) Top plus offset should remain invariant across scrolling.");
|
||||
});
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- When the iframe loads, it calls childLoad(). -->
|
||||
<br>
|
||||
<iframe height='100px' id='iframe' src='file_bug1151421.html'></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -28,7 +28,7 @@ function runTest() {
|
|||
}
|
||||
|
||||
child.onpopstate = function() {
|
||||
is(child.scrollY, 6000, "Shouldn't have scrolled before popstate");
|
||||
is(Math.round(child.scrollY), 6000, "Shouldn't have scrolled before popstate");
|
||||
child.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,21 +147,21 @@ function* testBody()
|
|||
popup.scroll(0, 100);
|
||||
|
||||
popup.history.pushState('', '', '?pushed');
|
||||
is(popup.scrollY, 100, "test 2");
|
||||
is(Math.round(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");
|
||||
is(Math.round(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");
|
||||
is(Math.round(popup.scrollY), 200, "test 4");
|
||||
|
||||
popup.history.back();
|
||||
is(popup.scrollY, 150, "test 5");
|
||||
is(Math.round(popup.scrollY), 150, "test 5");
|
||||
|
||||
popup.history.forward();
|
||||
is(popup.scrollY, 200, "test 6");
|
||||
is(Math.round(popup.scrollY), 200, "test 6");
|
||||
|
||||
// At this point, the history looks like:
|
||||
// PATH POSITION
|
||||
|
|
@ -202,13 +202,13 @@ function* testBody()
|
|||
is(popup.location.search, "?pushed");
|
||||
ok(popup.document.getElementById('div1'), 'page should have div1.');
|
||||
|
||||
is(popup.scrollY, 200, "test 8");
|
||||
is(Math.round(popup.scrollY), 200, "test 8");
|
||||
|
||||
popup.history.back();
|
||||
is(popup.scrollY, 150, "test 9");
|
||||
is(Math.round(popup.scrollY), 150, "test 9");
|
||||
popup.history.forward();
|
||||
|
||||
is(popup.scrollY, 200, "test 10");
|
||||
is(Math.round(popup.scrollY), 200, "test 10");
|
||||
|
||||
// Spin one last time...
|
||||
setTimeout(pageLoad, 0);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function childLoad2() {
|
|||
|
||||
// Save the Y offset. For sanity's sake, make sure it's not 0, because we
|
||||
// should be at the bottom of the page!
|
||||
let origYOffset = cw.pageYOffset;
|
||||
let origYOffset = Math.round(cw.pageYOffset);
|
||||
ok(origYOffset != 0, 'Original Y offset is not 0.');
|
||||
|
||||
// Scroll the iframe to the top, then navigate to #bottom again.
|
||||
|
|
@ -37,7 +37,7 @@ function childLoad2() {
|
|||
// bottom again.
|
||||
cw.location = cw.location + '';
|
||||
|
||||
is(cw.pageYOffset, origYOffset, 'Correct offset after reloading page.');
|
||||
is(Math.round(cw.pageYOffset), origYOffset, 'Correct offset after reloading page.');
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ function childLoad2() {
|
|||
cw.scrollTo(0, 300);
|
||||
|
||||
// Did we actually scroll somewhere?
|
||||
isnot(cw.pageYOffset, 0, 'Y offset should be non-zero after scrolling.');
|
||||
isnot(Math.round(cw.pageYOffset), 0, 'Y offset should be non-zero after scrolling.');
|
||||
|
||||
// Now load file_bug662170.html#, which should take us to the top of the
|
||||
// page.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue