| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <script src="/resources/testharness.js"></script> | 2 <script src="/resources/testharness.js"></script> |
| 3 <script src="/resources/testharnessreport.js"></script> | 3 <script src="/resources/testharnessreport.js"></script> |
| 4 <title>Check End Position of scrollIntoView of shadow elements</title> | 4 <title>Check End Position of scrollIntoView of shadow elements</title> |
| 5 <div id="container"> | 5 <div id="container"> |
| 6 <div id="space1" style="height: 2000px; width: 2000px;background-color: yellow
"> | 6 <div id="space1" style="height: 2000px; width: 2000px;background-color: yellow
"> |
| 7 </div> | 7 </div> |
| 8 <div id="shadow"></div> | 8 <div id="shadow"></div> |
| 9 <div id="space2" style="height: 2000px; width: 2000px;background-color: blue"> | 9 <div id="space2" style="height: 2000px; width: 2000px;background-color: blue"> |
| 10 </div> | 10 </div> |
| 11 </div> | 11 </div> |
| 12 <script> | 12 <script> |
| 13 add_completion_callback(() => document.getElementById("container").remove()); | 13 add_completion_callback(() => document.getElementById("container").remove()); |
| 14 | 14 |
| 15 test(t => { | 15 test(t => { |
| 16 var shadow = document.getElementById("shadow"); | 16 var shadow = document.getElementById("shadow"); |
| 17 var shadowRoot = shadow.createShadowRoot(); | 17 var shadowRoot = shadow.createShadowRoot(); |
| 18 var shadowDiv = document.createElement("div"); | 18 var shadowDiv = document.createElement("div"); |
| 19 shadowDiv.style.height = "200px"; | 19 shadowDiv.style.height = "200px"; |
| 20 shadowDiv.style.width = "200px"; | 20 shadowDiv.style.width = "200px"; |
| 21 shadowDiv.style.backgroundColor = "green"; | 21 shadowDiv.style.backgroundColor = "green"; |
| 22 shadowRoot.appendChild(shadowDiv); | 22 shadowRoot.appendChild(shadowDiv); |
| 23 | 23 |
| 24 window.scrollTo(0, 0); | 24 window.scrollTo(0, 0); |
| 25 var expected_x = shadowDiv.offsetLeft; | 25 var expected_x = shadowDiv.offsetLeft; |
| 26 var expected_y = shadowDiv.offsetTop; | 26 var expected_y = shadowDiv.offsetTop; |
| 27 assert_not_equals(window.scrollX, expected_x); | 27 assert_not_equals(window.scrollX, expected_x); |
| 28 assert_not_equals(window.scrollY, expected_y); | 28 assert_not_equals(window.scrollY, expected_y); |
| 29 shadowDiv.scrollIntoView({block: "start", inlinePosition: "start"}); | 29 shadowDiv.scrollIntoView({block: "start", inline: "start"}); |
| 30 assert_approx_equals(window.scrollX, expected_x, 1); | 30 assert_approx_equals(window.scrollX, expected_x, 1); |
| 31 assert_approx_equals(window.scrollY, expected_y, 1); | 31 assert_approx_equals(window.scrollY, expected_y, 1); |
| 32 }, "scrollIntoView should behave correctly if applies to shadow dom elements"); | 32 }, "scrollIntoView should behave correctly if applies to shadow dom elements"); |
| 33 </script> | 33 </script> |
| OLD | NEW |