Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / devtools / server / tests / chrome / test_inspector-scroll-into-view.html
bloba107f9ba4adc7736153b975fd5ef39a143bf2a2c
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=901250
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 901250</title>
10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
12 <script type="application/javascript" src="inspector-helpers.js"></script>
13 <script type="application/javascript">
14 "use strict";
16 window.onload = async function() {
17 SimpleTest.waitForExplicitFinish();
19 const url = document.getElementById("inspectorContent").href;
20 const { target, doc } = await attachURL(url);
21 const inspector = await target.getFront("inspector");
22 const walker = inspector.walker;
24 const id = "#scroll-into-view";
25 let rect = doc.querySelector(id).getBoundingClientRect();
26 const nodeFront = await walker.querySelector(walker.rootNode, id);
27 let inViewport = rect.x >= 0 &&
28 rect.y >= 0 &&
29 rect.y <= doc.defaultView.innerHeight &&
30 rect.x <= doc.defaultView.innerWidth;
32 ok(!inViewport, "Element is not in viewport initially");
34 await nodeFront.scrollIntoView();
36 await new Promise(res => SimpleTest.executeSoon(res));
38 rect = doc.querySelector(id).getBoundingClientRect();
39 inViewport = rect.x >= 0 &&
40 rect.y >= 0 &&
41 rect.y <= doc.defaultView.innerHeight &&
42 rect.x <= doc.defaultView.innerWidth;
43 ok(inViewport, "Element is in viewport after calling nodeFront.scrollIntoView");
45 await target.destroy();
46 SimpleTest.finish();
48 </script>
49 </head>
50 <body>
51 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=901250">Mozilla Bug 901250</a>
52 <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
53 <p id="display"></p>
54 <div id="content" style="display: none">
56 </div>
57 <pre id="test">
58 </pre>
59 </body>
60 </html>