Index: third_party/WebKit/LayoutTests/external/wpt/scroll-into-view/check-scroll-position.html |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/scroll-into-view/check-scroll-position.html b/third_party/WebKit/LayoutTests/external/wpt/scroll-into-view/check-scroll-position.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a98e000e769170c959cceb5116fe149322b52ed1 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/external/wpt/scroll-into-view/check-scroll-position.html |
@@ -0,0 +1,76 @@ |
+<!DOCTYPE HTML> |
+<title> Check End Position of ScrollIntoView</title> |
+<div id='container' style='height: 2500px; width: 2500px;'> |
+ <div id='content' style='height: 500px; width: 500px;margin-left: 1000px; margin-right: 1000px; margin-top: 1000px;margin-bottom: 1000px'> |
+ </div> |
+</div> |
+<script src='/resources/testharness.js'></script> |
+<script src='/resources/testharnessreport.js'></script> |
+<script> |
+ |
+var frames = 0; |
+var content_height = 500; |
+var content_width = 500; |
+var window_height = visualViewport.clientHeight; |
+var window_width = visualViewport.clientWidth; |
+var content = document.getElementById('content'); |
+ |
+function animate (funct, x, y, next) { |
+ if (frames < 500) { |
+ ++frames; |
+ requestAnimationFrame(animate.bind(null, funct, x, y, next)); |
+ } else { |
+ assert_approx_equals(window.scrollX, x, 1); |
+ assert_approx_equals(window.scrollY, y, 1); |
+ funct.done(); |
+ next(); |
+ } |
+} |
+ |
+var checkNearest = async_test("Smooth ScrollIntoView should scroll the element to the 'nearest' position"); |
+checkNearest.step(function() { |
+ content.scrollIntoView( |
+ {behavior: 'smooth', block: 'nearest', inlinePosition: 'nearest'}); |
+ frames = 0; |
+ var x = content.offsetLeft + content_width - window_width; |
+ var y = content.offsetTop + content_height - window_height; |
+ animate(checkNearest, x, y, test2); |
+}); |
+ |
+var checkStart = async_test("Smooth ScrollIntoView should scroll the element to the 'start' position"); |
+function test2() { |
+ checkStart.step(function() { |
+ content.scrollIntoView( |
+ {behavior: 'smooth', block: 'start', inlinePosition: 'start'}); |
+ frames = 0; |
+ animate(checkStart, content.offsetLeft, content.offsetTop, test3); |
+ }); |
+} |
+ |
+var checkCenter = async_test("Smooth ScrollIntoView should scroll the element to the 'center' position"); |
+function test3() { |
+ checkCenter.step(function() { |
+ content.scrollIntoView( |
+ {behavior: 'smooth', block: 'center', inlinePosition: 'center'}); |
+ frames = 0; |
+ var x = content.offsetLeft + (content_width - window_width) / 2; |
+ var y = content.offsetTop + (content_height - window_height) / 2; |
+ animate(checkCenter, x, y, test4); |
+ }); |
+} |
+ |
+var checkEnd = async_test("Smooth ScrollIntoView should scroll the element to the 'end' position"); |
+function test4() { |
+ checkEnd.step(function() { |
+ content.scrollIntoView( |
+ {behavior: 'smooth', block: 'end', inlinePosition: 'end'}); |
+ frames = 0; |
+ var x = content.offsetLeft + content_width - window_width; |
+ var y = content.offsetTop + content_height - window_height; |
+ animate(checkEnd, x, y, end); |
+ }); |
+} |
+ |
+function end() {} |
+ |
+</script> |