summaryrefslogtreecommitdiffstats
path: root/docshell/test
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-08-10 18:01:49 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-02-21 19:52:35 +0100
commit4fd939e8c9dd97c45e7fcd1314f3ab482a2cf23d (patch)
treeb4f563927fa6f72db494b9a7ae2b846781b2da35 /docshell/test
parenta80b5f2728fdb0d2eaeace78528ea8c64427d39e (diff)
downloadUXP-4fd939e8c9dd97c45e7fcd1314f3ab482a2cf23d.tar
UXP-4fd939e8c9dd97c45e7fcd1314f3ab482a2cf23d.tar.gz
UXP-4fd939e8c9dd97c45e7fcd1314f3ab482a2cf23d.tar.lz
UXP-4fd939e8c9dd97c45e7fcd1314f3ab482a2cf23d.tar.xz
UXP-4fd939e8c9dd97c45e7fcd1314f3ab482a2cf23d.zip
JS - make window.pageYOffset/pageXOffset/scrollX/scrollY double
Diffstat (limited to 'docshell/test')
-rw-r--r--docshell/test/file_bug1151421.html19
-rw-r--r--docshell/test/mochitest.ini2
-rw-r--r--docshell/test/navigation/file_scrollRestoration.html14
-rw-r--r--docshell/test/test_bug1151421.html61
-rw-r--r--docshell/test/test_bug1186774.html2
-rw-r--r--docshell/test/test_bug590573.html16
-rw-r--r--docshell/test/test_bug653741.html4
-rw-r--r--docshell/test/test_bug662170.html2
8 files changed, 101 insertions, 19 deletions
diff --git a/docshell/test/file_bug1151421.html b/docshell/test/file_bug1151421.html
new file mode 100644
index 000000000..7bb8c8f36
--- /dev/null
+++ b/docshell/test/file_bug1151421.html
@@ -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>
diff --git a/docshell/test/mochitest.ini b/docshell/test/mochitest.ini
index 725486b77..7b27908fb 100644
--- a/docshell/test/mochitest.ini
+++ b/docshell/test/mochitest.ini
@@ -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]
diff --git a/docshell/test/navigation/file_scrollRestoration.html b/docshell/test/navigation/file_scrollRestoration.html
index 5450c2724..92e43d7fb 100644
--- a/docshell/test/navigation/file_scrollRestoration.html
+++ b/docshell/test/navigation/file_scrollRestoration.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,";
diff --git a/docshell/test/test_bug1151421.html b/docshell/test/test_bug1151421.html
new file mode 100644
index 000000000..76e34d502
--- /dev/null
+++ b/docshell/test/test_bug1151421.html
@@ -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>
diff --git a/docshell/test/test_bug1186774.html b/docshell/test/test_bug1186774.html
index 52ef5f62c..623e7996b 100644
--- a/docshell/test/test_bug1186774.html
+++ b/docshell/test/test_bug1186774.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();
}
diff --git a/docshell/test/test_bug590573.html b/docshell/test/test_bug590573.html
index aa6d3bd79..e218140ea 100644
--- a/docshell/test/test_bug590573.html
+++ b/docshell/test/test_bug590573.html
@@ -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);
diff --git a/docshell/test/test_bug653741.html b/docshell/test/test_bug653741.html
index f4d4587b8..a1faf5e2d 100644
--- a/docshell/test/test_bug653741.html
+++ b/docshell/test/test_bug653741.html
@@ -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();
}
diff --git a/docshell/test/test_bug662170.html b/docshell/test/test_bug662170.html
index 514bb55b1..0e626fed4 100644
--- a/docshell/test/test_bug662170.html
+++ b/docshell/test/test_bug662170.html
@@ -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.