js/xpconnect/tests/mochitest/test_bug390488.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>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=390488
     5 -->
     6 <head>
     7   <title>Test for Bug 390488</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=390488">Mozilla Bug 390488</a>
    13 <p id="display">
    14   <div id="testdiv" onclick="checkForStacks();" style="visibility:hidden">
    15   </div>
    16 </p>
    17 <div id="content" style="display: none">
    19 </div>
    20 <pre id="test">
    21 <script class="testbody" type="text/javascript">
    23 /** Test for Bug 390488 **/
    24   function getStack1() {
    25     var func = arguments.callee.caller;
    26     var stack = "";
    27     for (var i = 1; func && i < 8; i++) {
    28       stack += " " + i + ". " + func.name;
    29       func = func.caller;
    30     }
    31     return stack;
    32   }
    34   function getStack2() {
    35     var stack = new Error().stack;
    36     // Remove the two lines due to calling this
    37     return stack.substring(stack.indexOf("\n", stack.indexOf("\n")+1)+1);
    38   }
    40   function simulateClick() {
    41     var evt = document.createEvent("MouseEvents");
    42     evt.initMouseEvent("click", true, true, window,
    43       0, 0, 0, 0, 0, false, false, false, false, 0, null);
    44     $("testdiv").dispatchEvent(evt);
    45   }
    47   function matches(s, p, name) {
    48     ok(s.match(p) != null, name,
    49        "got " + uneval(s) + ", expected a string matching " + uneval(p));
    50   }
    52   function checkForStacks() {
    53     matches(getStack1(), /checkForStacks .* onclick .* simulateClick/,
    54             "Stack from walking caller chain should be correct");
    55     isnot(getStack2().indexOf("simulateClick@"),  -1,
    56           "Stack from |new Error().stack| should include simulateClick");
    57   }
    59   simulateClick();
    60 </script>
    61 </pre>
    62 </body>
    63 </html>

mercurial