toolkit/devtools/webconsole/test/test_object_actor_native_getters.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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 type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     7   <script type="text/javascript;version=1.8" 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>
    14 <script class="testbody" type="text/javascript;version=1.8">
    15 SimpleTest.waitForExplicitFinish();
    17 let expectedProps = [];
    18 let expectedSafeGetters = [];
    20 function startTest()
    21 {
    22   removeEventListener("load", startTest);
    24   attachConsole(["ConsoleAPI"], onAttach, true);
    25 }
    27 function onAttach(aState, aResponse)
    28 {
    29   onConsoleCall = onConsoleCall.bind(null, aState);
    30   aState.dbgClient.addListener("consoleAPICall", onConsoleCall);
    32   top.console.log("hello", document);
    34   expectedProps = {
    35     "location": {
    36       get: {
    37         type: "object",
    38         class: "Function",
    39         actor: /[a-z]/,
    40       },
    41     },
    42   };
    44   expectedSafeGetters = {
    45     "title": {
    46       getterValue: /native getters in object actors/,
    47       getterPrototypeLevel: 2,
    48     },
    49     "styleSheets": {
    50       getterValue: "[object Object]",
    51       getterPrototypeLevel: 2,
    52     },
    53   };
    54 }
    56 function onConsoleCall(aState, aType, aPacket)
    57 {
    58   is(aPacket.from, aState.actor, "console API call actor");
    60   info("checking the console API call packet");
    62   checkConsoleAPICall(aPacket.message, {
    63     level: "log",
    64     filename: /test_object_actor/,
    65     functionName: "onAttach",
    66     arguments: ["hello", {
    67       type: "object",
    68       actor: /[a-z]/,
    69     }],
    70   });
    72   aState.dbgClient.removeListener("consoleAPICall", onConsoleCall);
    74   info("inspecting object properties");
    75   let args = aPacket.message.arguments;
    76   onProperties = onProperties.bind(null, aState);
    78   let client = new ObjectClient(aState.dbgClient, args[1]);
    79   client.getPrototypeAndProperties(onProperties);
    80 }
    82 function onProperties(aState, aResponse)
    83 {
    84   let props = aResponse.ownProperties;
    85   let keys = Object.keys(props);
    86   info(keys.length + " ownProperties: " + keys);
    88   ok(keys.length >= Object.keys(expectedProps).length, "number of properties");
    90   info("check ownProperties");
    91   checkObject(props, expectedProps);
    92   info("check safeGetterValues");
    93   checkObject(aResponse.safeGetterValues, expectedSafeGetters);
    95   expectedProps = [];
    96   expectedSafeGetters = [];
    98   closeDebugger(aState, function() {
    99     SimpleTest.finish();
   100   });
   101 }
   103 addEventListener("load", startTest);
   104 </script>
   105 </body>
   106 </html>

mercurial