tor-browser

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

test_webconsole-node-grip.html (2361B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>DOMNode Object actor test</title>
      6  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
      8  <script type="application/javascript" src="webconsole-helpers.js"></script>
      9  <script>
     10 "use strict";
     11 
     12 const TEST_URL = "data:text/html,<html><body>Hello</body></html>";
     13 
     14 window.onload = async function() {
     15  SimpleTest.waitForExplicitFinish();
     16 
     17  try {
     18    const commands = await addTabAndCreateCommands(TEST_URL);
     19    await testNotInTreeElementNode(commands);
     20    await testInTreeElementNode(commands);
     21    await testNotInTreeTextNode(commands);
     22    await testInTreeTextNode(commands);
     23  } catch (e) {
     24    ok(false, `Error thrown: ${e.message}`);
     25  }
     26  SimpleTest.finish();
     27 };
     28 
     29 async function testNotInTreeElementNode(commands) {
     30  info("Testing isConnected property on a ElementNode not in the DOM tree");
     31  const {result} = await commands.scriptCommand.execute("document.createElement(\"div\")");
     32  is(result.getGrip().preview.isConnected, false,
     33    "isConnected is false since we only created the element");
     34 }
     35 
     36 async function testInTreeElementNode(commands) {
     37  info("Testing isConnected property on a ElementNode in the DOM tree");
     38  const {result} = await commands.scriptCommand.execute("document.body");
     39  is(result.getGrip().preview.isConnected, true,
     40    "isConnected is true as expected, since the element was retrieved from the DOM tree");
     41 }
     42 
     43 async function testNotInTreeTextNode(commands) {
     44  info("Testing isConnected property on a TextNode not in the DOM tree");
     45  const {result} = await commands.scriptCommand.execute("document.createTextNode(\"Hello\")");
     46  is(result.getGrip().preview.isConnected, false,
     47    "isConnected is false since we only created the element");
     48 }
     49 
     50 async function testInTreeTextNode(commands) {
     51  info("Testing isConnected property on a TextNode in the DOM tree");
     52  const {result} = await commands.scriptCommand.execute("document.body.firstChild");
     53  is(result.getGrip().preview.isConnected, true,
     54    "isConnected is true as expected, since the element was retrieved from the DOM tree");
     55 }
     56 
     57  </script>
     58 </head>
     59 <body>
     60  <p id="display"></p>
     61  <div id="content" style="display: none">
     62  </div>
     63  <pre id="test">
     64  </pre>
     65 </body>
     66 </html>