tor-browser

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

test_inspector-resize.html (1845B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 Test that the inspector actor emits "resize" events when the page is resized.
      5 https://bugzilla.mozilla.org/show_bug.cgi?id=1222409
      6 -->
      7 <head>
      8  <meta charset="utf-8">
      9  <title>Test for Bug 1222409</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";
     15 
     16 window.onload = function() {
     17  SimpleTest.waitForExplicitFinish();
     18 
     19  let win = null;
     20  let inspector = null;
     21 
     22  addAsyncTest(async function setup() {
     23    info("Setting up inspector and walker actors.");
     24 
     25    const url = document.getElementById("inspectorContent").href;
     26 
     27    const { target, doc } = await attachURL(url);
     28    inspector = await target.getFront("inspector");
     29    win = doc.defaultView;
     30    runNextTest();
     31  });
     32 
     33  addAsyncTest(async function() {
     34    const walker = inspector.walker;
     35 
     36    // We can't receive events from the walker if we haven't first executed a
     37    // method on the actor to initialize it.
     38    await walker.querySelector(walker.rootNode, "img");
     39 
     40    const {outerWidth, outerHeight} = win;
     41    // eslint-disable-next-line new-cap
     42    const onResize = new Promise(resolve => {
     43      walker.once("resize", () => {
     44        resolve();
     45      });
     46    });
     47    win.resizeTo(800, 600);
     48    await onResize;
     49 
     50    ok(true, "The resize event was emitted");
     51    win.resizeTo(outerWidth, outerHeight);
     52 
     53    runNextTest();
     54  });
     55 
     56  runNextTest();
     57 };
     58  </script>
     59 </head>
     60 <body>
     61 <a id="inspectorContent" target="_blank" href="inspector-search-data.html">Test Document</a>
     62 <p id="display"></p>
     63 <div id="content" style="display: none">
     64 
     65 </div>
     66 <pre id="test">
     67 </pre>
     68 </body>
     69 </html>