Commit 3437aff4 authored by David Bokan's avatar David Bokan Committed by Commit Bot

Modernize scale-and-scroll-iframe-window.html test

This CL converts this test to use testharness.js assertions rather than
js-test.js and a pixel test. The impetus for this is the pixel diff when
root layer scrolling is turned on. The difference it not related to what
this test is checking (and is actually correct when RLS is turned on).
See the bug (comment #7) for more details.

Bug: 781431
Change-Id: Ida7c287b616b4fd166b436e9957f28bf794098d4
Reviewed-on: https://chromium-review.googlesource.com/894365Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533170}
parent f8c029b4
PASS successfullyParsed is true
TEST COMPLETE
PASS frame.contentDocument.scrollingElement.scrollTop is 100
PASS frame.contentDocument.scrollingElement.scrollLeft is 100
PASS frame.contentWindow.scrollX is 100
PASS frame.contentWindow.scrollY is 100
<html> <script src="../../resources/testharness.js"></script>
<head> <script src="../../resources/testharnessreport.js"></script>
<script> <script>
window.enablePixelTesting = true; const mainTest = async_test(
'window.scrollTo while zoomed causes correct amount of scroll', {});
function scroll() { const frameTest = async_test(
window.scrollTo(0, 100); 'window.scrollTo while zoomed causes correct amount of scroll in '
var frame = document.getElementById('frame'); + 'iframe', {});
frame.contentWindow.scrollTo(100,100);
function runTest() {
shouldBe("frame.contentDocument.scrollingElement.scrollTop", "100"); var scaleFactor = 2;
shouldBe("frame.contentDocument.scrollingElement.scrollLeft", "100"); if (window.internals)
shouldBe("frame.contentWindow.scrollX", "100"); internals.setPageScaleFactor(scaleFactor);
shouldBe("frame.contentWindow.scrollY", "100");
} window.scrollTo(0, 100);
function scaleWithEventSender() { mainTest.step(function() {
var scaleFactor = 0.5; assert_equals(document.scrollingElement.scrollLeft, 0,
if (window.internals) { "scrollingElement has correct scrollLeft");
internals.setPageScaleFactorLimits(scaleFactor, scaleFactor); assert_equals(document.scrollingElement.scrollTop, 100,
internals.setPageScaleFactor(scaleFactor); "scrollingElement has correct scrollTop");
} assert_equals(window.scrollX, 0,
} "window has correct scrollX");
assert_equals(window.scrollY, 100,
function test() { "window has correct scrollY");
scaleWithEventSender(); });
scroll(); mainTest.done();
}
</script>
<script src="../../resources/js-test.js"></script>
</head>
<body onload="test();" style="width: 4000px; height: 4000px">
<div id="console"></div>
<iframe id="frame" style="width:400px; height: 400px; position: absolute; top: 100px;"></iframe>
<script>
var frame = document.getElementById('frame'); var frame = document.getElementById('frame');
var doc = frame.contentDocument.open(); frame.contentWindow.scrollTo(100,100);
doc.write("<html><style>::-webkit-scrollbar {width: 0px;height: 0px;}</style></html>");
doc.write("<div style='left:0; top:0; width:100px; height:100px; position:absolute; background:yellow;'></div>"); frameTest.step(function() {
doc.write("<div style='left:100px; top:0; width:100px; height:100px; position:absolute; background:green;'></div>"); assert_equals(frame.contentDocument.scrollingElement.scrollLeft,
doc.write("<div style='left:200px; top:0; width:100px; height:100px; position:absolute; background:blue;'></div>"); 100,
doc.write("<div style='left:300px; top:0; width:100px; height:100px; position:absolute; background:green;'></div>"); "IFrame ScrollingElement has correct scrollLeft");
doc.write("<div style='left:400px; top:0; width:100px; height:100px; position:absolute; background:blue;'></div>"); assert_equals(frame.contentDocument.scrollingElement.scrollTop,
100,
doc.write("<div style='left:0; top:100px; width:100px; height:100px; position:absolute; background: green;'></div>"); "IFrame ScrollingElement has correct scrollTop");
doc.write("<div style='left:100px; top:100px; width:100px; height:100px; position:absolute; background:blue;'></div>"); assert_equals(frame.contentWindow.scrollX, 100,
doc.write("<div style='left:200px; top:100px; width:100px; height:100px; position:absolute; background:green;'></div>"); "IFrame window has correct scrollX");
doc.write("<div style='left:300px; top:100px; width:100px; height:100px; position:absolute; background:blue;'></div>"); assert_equals(frame.contentWindow.scrollY, 100,
doc.write("<div style='left:400px; top:100px; width:100px; height:100px; position:absolute; background:green;'></div>"); "IFrame window has correct scrollY");
doc.close(); });
frame.contentDocument.body.style.width = "2000px"; frameTest.done();
frame.contentDocument.body.style.height = "2000px"; }
</script>
</body> addEventListener('load', runTest);
</html> </script>
<style>
body {
width: 4000px;
height: 4000px;
}
</style>
<div id="console"></div>
<iframe id="frame" style="width:400px; height: 400px; position: absolute; top: 100px;"></iframe>
<script>
var frame = document.getElementById('frame');
var doc = frame.contentDocument.open();
doc.write("<html><style>::-webkit-scrollbar {width: 0px;height: 0px;}</style></html>");
doc.write("<div style='left:0; top:0; width:100px; height:100px; position:absolute; background:yellow;'></div>");
doc.write("<div style='left:100px; top:0; width:100px; height:100px; position:absolute; background:green;'></div>");
doc.write("<div style='left:200px; top:0; width:100px; height:100px; position:absolute; background:blue;'></div>");
doc.write("<div style='left:300px; top:0; width:100px; height:100px; position:absolute; background:green;'></div>");
doc.write("<div style='left:400px; top:0; width:100px; height:100px; position:absolute; background:blue;'></div>");
doc.write("<div style='left:0; top:100px; width:100px; height:100px; position:absolute; background: green;'></div>");
doc.write("<div style='left:100px; top:100px; width:100px; height:100px; position:absolute; background:blue;'></div>");
doc.write("<div style='left:200px; top:100px; width:100px; height:100px; position:absolute; background:green;'></div>");
doc.write("<div style='left:300px; top:100px; width:100px; height:100px; position:absolute; background:blue;'></div>");
doc.write("<div style='left:400px; top:100px; width:100px; height:100px; position:absolute; background:green;'></div>");
doc.close();
frame.contentDocument.body.style.width = "2000px";
frame.contentDocument.body.style.height = "2000px";
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment