toolkit/devtools/webconsole/test/test_jsterm_cd_iframe.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 cd() function</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 cd() function</p>
    14 <script class="testbody" type="text/javascript;version=1.8">
    15 SimpleTest.waitForExplicitFinish();
    17 let gState;
    19 function startTest()
    20 {
    21   removeEventListener("load", startTest);
    23   attachConsole([], onAttach, true);
    24 }
    26 function onAttach(aState, aResponse)
    27 {
    28   top.foobarObject = Object.create(null);
    29   top.foobarObject.bug609872 = "parent";
    31   window.foobarObject = Object.create(null);
    32   window.foobarObject.bug609872 = "child";
    34   gState = aState;
    36   let tests = [doCheckParent, doCdIframe, doCheckIframe, doCdParent,
    37       doCheckParent2];
    38   runTests(tests, testEnd);
    39 }
    41 function doCheckParent()
    42 {
    43   info("check parent window");
    44   gState.client.evaluateJS("window.foobarObject.bug609872",
    45       onFooObjectFromParent);
    46 }
    48 function onFooObjectFromParent(aResponse)
    49 {
    50   checkObject(aResponse, {
    51     from: gState.actor,
    52     input: "window.foobarObject.bug609872",
    53     result: "parent",
    54   });
    56   ok(!aResponse.exception, "no eval exception");
    57   ok(!aResponse.helperResult, "no helper result");
    59   nextTest();
    60 }
    62 function doCdIframe()
    63 {
    64   info("test cd('iframe')");
    65   gState.client.evaluateJS("cd('iframe')", onCdIframe);
    66 }
    68 function onCdIframe(aResponse)
    69 {
    70   checkObject(aResponse, {
    71     from: gState.actor,
    72     input: "cd('iframe')",
    73     result: { type: "undefined" },
    74     helperResult: { type: "cd" },
    75   });
    77   ok(!aResponse.exception, "no eval exception");
    79   nextTest();
    80 }
    82 function doCheckIframe()
    83 {
    84   info("check foobarObject from the iframe");
    85   gState.client.evaluateJS("window.foobarObject.bug609872",
    86                            onFooObjectFromIframe);
    87 }
    89 function onFooObjectFromIframe(aResponse)
    90 {
    91   checkObject(aResponse, {
    92     from: gState.actor,
    93     input: "window.foobarObject.bug609872",
    94     result: "child",
    95   });
    97   ok(!aResponse.exception, "no js eval exception");
    98   ok(!aResponse.helperResult, "no helper result");
   100   nextTest();
   101 }
   103 function doCdParent()
   104 {
   105   info("test cd() back to parent");
   106   gState.client.evaluateJS("cd()", onCdParent);
   107 }
   109 function onCdParent(aResponse)
   110 {
   111   checkObject(aResponse, {
   112     from: gState.actor,
   113     input: "cd()",
   114     result: { type: "undefined" },
   115     helperResult: { type: "cd" },
   116   });
   118   ok(!aResponse.exception, "no eval exception");
   120   nextTest();
   121 }
   123 function doCheckParent2()
   124 {
   125   gState.client.evaluateJS("window.foobarObject.bug609872",
   126                            onFooObjectFromParent2);
   127 }
   129 function onFooObjectFromParent2(aResponse)
   130 {
   131   checkObject(aResponse, {
   132     from: gState.actor,
   133     input: "window.foobarObject.bug609872",
   134     result: "parent",
   135   });
   137   ok(!aResponse.exception, "no eval exception");
   138   ok(!aResponse.helperResult, "no helper result");
   140   nextTest();
   141 }
   143 function testEnd()
   144 {
   145   closeDebugger(gState, function() {
   146     gState = null;
   147     SimpleTest.finish();
   148   });
   149 }
   151 addEventListener("load", startTest);
   152 </script>
   153 </body>
   154 </html>

mercurial