js/xpconnect/tests/mochitest/test_bug940783.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=940783
     5 -->
     6 <head>
     7   <meta charset="utf-8">
     8   <title>Test for Bug 940783</title>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11   <script type="application/javascript">
    13   /** Test for Bug 940783 **/
    14   SimpleTest.waitForExplicitFinish();
    16   function checkHistoryThrows(hist) {
    17     checkThrows(function() { hist.length; });
    18     checkThrows(function() { hist.state; });
    19     checkThrows(function() { hist.go(); });
    20     checkThrows(function() { hist.back(); });
    21     checkThrows(function() { hist.forward(); });
    22     checkThrows(function() { hist.pushState({}, "foo"); });
    23     checkThrows(function() { hist.replaceState({}, "foo"); });
    25   }
    27   window.gLoads = 0;
    28   function load() {
    29     var iwin = $('ifr').contentWindow;
    30     ++gLoads;
    31     if (gLoads == 1) {
    32       window.gHist = iwin.history;
    33       iwin.location = "file_empty.html";
    34     } else if (gLoads == 2) {
    35       checkHistoryThrows(gHist);
    36       window.gHist = iwin.history;
    37       iwin.location = "http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
    38     } else {
    39       checkHistoryThrows(gHist);
    40       $('ifr').setAttribute('onload', null);
    41       SimpleTest.finish();
    42     }
    43   }
    45   function checkThrows(fn) {
    46     try { fn(); ok(false, "Should have thrown: " + fn.toSource()); }
    47     catch (e) { ok(!!/denied|insecure/.exec(e), "Threw correctly: " + e); }
    48   }
    50   </script>
    51 </head>
    52 <body>
    53 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=940783">Mozilla Bug 940783</a>
    54 <p id="display"></p>
    55 <div id="content" style="display: none">
    56 <iframe id="ifr" onload="load();" src="file_empty.html"></iframe>
    58 </div>
    59 <pre id="test">
    60 </pre>
    61 </body>
    62 </html>

mercurial