From 4fd939e8c9dd97c45e7fcd1314f3ab482a2cf23d Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 10 Aug 2017 18:01:49 +0200 Subject: JS - make window.pageYOffset/pageXOffset/scrollX/scrollY double --- docshell/test/file_bug1151421.html | 19 +++++++ docshell/test/mochitest.ini | 2 + .../test/navigation/file_scrollRestoration.html | 14 ++--- docshell/test/test_bug1151421.html | 61 ++++++++++++++++++++++ docshell/test/test_bug1186774.html | 2 +- docshell/test/test_bug590573.html | 16 +++--- docshell/test/test_bug653741.html | 4 +- docshell/test/test_bug662170.html | 2 +- 8 files changed, 101 insertions(+), 19 deletions(-) create mode 100644 docshell/test/file_bug1151421.html create mode 100644 docshell/test/test_bug1151421.html (limited to 'docshell/test') 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 @@ + + + + + + +
+
content
+
+ + + 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 @@ + + + + + Test for Bug 1151421 + + + + +Mozilla Bug 1151421 + + + + +
+ + + + 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. -- cgit v1.2.3