tor-browser

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

test_object_actor_native_getters.html (1959B)


      1 <!DOCTYPE HTML>
      2 <html lang="en">
      3 <head>
      4  <meta charset="utf8">
      5  <title>Test for the native getters in object actors</title>
      6  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      7  <script type="text/javascript" src="common.js"></script>
      8  <!-- Any copyright is dedicated to the Public Domain.
      9     - http://creativecommons.org/publicdomain/zero/1.0/ -->
     10 </head>
     11 <body>
     12 <p>Test for the native getters in object actors</p>
     13 
     14 <script class="testbody" type="text/javascript">
     15 "use strict";
     16 
     17 SimpleTest.waitForExplicitFinish();
     18 
     19 async function startTest() {
     20  removeEventListener("load", startTest);
     21  const {state} = await attachConsoleToTab(["ConsoleAPI"]);
     22 
     23  const onConsoleAPICall = state.webConsoleFront.once("consoleAPICall");
     24  top.console.log("hello", document);
     25  const {message} = await onConsoleAPICall;
     26 
     27  info("checking the console API call packet");
     28  checkConsoleAPICall(message, {
     29    level: "log",
     30    filename: /test_object_actor/,
     31    arguments: ["hello", {
     32      type: "object",
     33      actor: /[a-z]/,
     34    }],
     35  });
     36 
     37  info("inspecting object properties");
     38  const args = message.arguments;
     39  const {ownProperties, safeGetterValues} = await args[1].getPrototypeAndProperties();
     40 
     41  const expectedProps = {
     42    "location": {
     43      get: {
     44        type: "object",
     45        class: "Function",
     46        actor: /[a-z]/,
     47      },
     48    },
     49  };
     50  ok(Object.keys(ownProperties).length >= Object.keys(expectedProps).length,
     51    "number of properties");
     52 
     53  info("check ownProperties");
     54  checkObject(ownProperties, expectedProps);
     55 
     56  info("check safeGetterValues");
     57  checkObject(safeGetterValues, {
     58    "title": {
     59      getterValue: /native getters in object actors/,
     60      getterPrototypeLevel: 2,
     61    },
     62    "styleSheets": {
     63      getterValue: /Front for obj\//,
     64      getterPrototypeLevel: 2,
     65    },
     66  });
     67 
     68  await closeDebugger(state);
     69  SimpleTest.finish();
     70 }
     71 
     72 addEventListener("load", startTest);
     73 </script>
     74 </body>
     75 </html>