OLD | NEW |
(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 when arg is not fully specified</tit
le> |
| 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;background-color: red
"> |
| 7 </div> |
| 8 </div> |
| 9 <script> |
| 10 add_completion_callback(() => document.getElementById("container").remove()); |
| 11 var content_height = 500; |
| 12 var content_width = 500; |
| 13 var window_height = document.documentElement.clientHeight; |
| 14 var window_width = document.documentElement.clientWidth; |
| 15 var content = document.getElementById("content"); |
| 16 |
| 17 function instantScrollToTestArgs(arg, expected_x, expected_y) { |
| 18 window.scrollTo(0, 0); |
| 19 assert_not_equals(window.scrollX, expected_x); |
| 20 assert_not_equals(window.scrollY, expected_y); |
| 21 if (arg == "omitted") |
| 22 content.scrollIntoView(); |
| 23 else |
| 24 content.scrollIntoView(arg); |
| 25 assert_approx_equals(window.scrollX, expected_x, 1); |
| 26 assert_approx_equals(window.scrollY, expected_y, 1); |
| 27 } |
| 28 |
| 29 test(t => { |
| 30 instantScrollToTestArgs("omitted", |
| 31 content.offsetLeft + content_width - window_width, |
| 32 content.offsetTop); |
| 33 instantScrollToTestArgs(true, |
| 34 content.offsetLeft + content_width - window_width, |
| 35 content.offsetTop); |
| 36 instantScrollToTestArgs(false, |
| 37 content.offsetLeft + content_width - window_width, |
| 38 content.offsetTop + content_height - window_height); |
| 39 instantScrollToTestArgs({}, |
| 40 content.offsetLeft + (content_width - window_width) / 2, |
| 41 content.offsetTop + (content_height - window_height) / 2); |
| 42 instantScrollToTestArgs(null, |
| 43 content.offsetLeft + (content_width - window_width) / 2, |
| 44 content.offsetTop + (content_height - window_height) / 2); |
| 45 instantScrollToTestArgs(undefined, |
| 46 content.offsetLeft + content_width - window_width, |
| 47 content.offsetTop); |
| 48 }, "scrollIntoView should behave correctly when the arg is not fully specified a
s ScrollIntoViewOptions"); |
| 49 |
| 50 </script> |
OLD | NEW |