Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/scroll-into-view/check-scroll-position.html

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Fixed the comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <script src='/resources/testharness.js'></script>
3 <script src='/resources/testharnessreport.js'></script>
4 <title> Check End Position of ScrollIntoView</title>
5 <div id='container' style='height: 2500px; width: 2500px;'>
6 <div id='content' style='height: 500px; width: 500px;margin-left: 1000px; marg in-right: 1000px; margin-top: 1000px;margin-bottom: 1000px'>
7 </div>
8 </div>
9 <script>
10
11 var frames = 0;
12 var content_height = 500;
13 var content_width = 500;
14 var window_height = visualViewport.clientHeight;
15 var window_width = visualViewport.clientWidth;
16 var content = document.getElementById('content');
17
18 function animate (funct, x, y, next) {
19 if (frames < 500) {
20 ++frames;
21 requestAnimationFrame(animate.bind(null, funct, x, y, next));
22 } else {
23 funct.step(function() {
24 assert_approx_equals(window.scrollX, x, 1);
25 assert_approx_equals(window.scrollY, y, 1);
26 funct.done();
27 next();
bokan 2017/05/19 18:37:14 You'll need to check if next is null now.
sunyunjia 2017/05/19 22:30:41 Done.
28 });
29 }
30 }
31
32 var checkNearest = async_test("Smooth ScrollIntoView should scroll the element t o the 'nearest' position");
33 checkNearest.step(function() {
34 content.scrollIntoView(
35 {behavior: 'smooth', block: 'nearest', inlinePosition: 'nearest'});
36 frames = 0;
37 var x = content.offsetLeft + content_width - window_width;
38 var y = content.offsetTop + content_height - window_height;
39 animate(checkNearest, x, y, test2);
40 });
41
42 var checkStart = async_test("Smooth ScrollIntoView should scroll the element to the 'start' position");
43 function test2() {
44 checkStart.step(function() {
45 content.scrollIntoView(
46 {behavior: 'smooth', block: 'start', inlinePosition: 'start'});
47 frames = 0;
48 animate(checkStart, content.offsetLeft, content.offsetTop, test3);
49 });
50 }
51
52 var checkCenter = async_test("Smooth ScrollIntoView should scroll the element to the 'center' position");
53 function test3() {
54 checkCenter.step(function() {
55 content.scrollIntoView(
56 {behavior: 'smooth', block: 'center', inlinePosition: 'center'});
57 frames = 0;
58 var x = content.offsetLeft + (content_width - window_width) / 2;
59 var y = content.offsetTop + (content_height - window_height) / 2;
60 animate(checkCenter, x, y, test4);
61 });
62 }
63
64 var checkEnd = async_test("Smooth ScrollIntoView should scroll the element to th e 'end' position");
65 function test4() {
66 checkEnd.step(function() {
67 content.scrollIntoView(
68 {behavior: 'smooth', block: 'end', inlinePosition: 'end'});
69 frames = 0;
70 var x = content.offsetLeft + content_width - window_width;
71 var y = content.offsetTop + content_height - window_height;
72 animate(checkEnd, x, y, null);
73 });
74 }
75
76 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/BUILD.gn » ('j') | third_party/WebKit/Source/core/dom/Element.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698