tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_inspector-scroll-into-view.html (1950B)


      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>
      9 
     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";
     15 
     16 window.onload = async function() {
     17  SimpleTest.waitForExplicitFinish();
     18 
     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;
     23 
     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;
     31 
     32  ok(!inViewport, "Element is not in viewport initially");
     33 
     34  await nodeFront.scrollIntoView();
     35 
     36  await new Promise(res => SimpleTest.executeSoon(res));
     37 
     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");
     44 
     45  await target.destroy();
     46  SimpleTest.finish();
     47 };
     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">
     55 
     56 </div>
     57 <pre id="test">
     58 </pre>
     59 </body>
     60 </html>