4 https://bugzilla.mozilla.org/show_bug.cgi?id=901250
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">
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 &&
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 &&
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();
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>
54 <div id=
"content" style=
"display: none">