dom/xbl/test/test_bug379959.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=379959
     5 -->
     6 <head>
     7   <title>Test for Bug 379959</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 onload="runTest();">
    12   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=379959">Mozilla Bug 379959</a>
    13   <p id="display">
    14     Note: In order to re-run this test correctly you need to shift-reload
    15     rather than simply reload. If you just reload we will restore the
    16     previous url in the iframe which will result in an extra unexpected
    17     message.
    18   </p>
    19   <div id="content" style="display: none"></div>
    20   <iframe id="f"></iframe>
    22   <pre id="test">
    23     <script class="testbody" type="application/javascript;version=1.7">
    24 SimpleTest.waitForExplicitFinish();
    26 var messages = 0;
    28 function receiveMessage(e) {
    29   is(e.origin, "http://mochi.test:8888", "wrong sender!");
    30   messages++;
    32   switch (messages) {
    33     case 1:
    34       receiveMessage1(e.data);
    35       break;
    36     case 2:
    37       receiveMessage2(e.data);
    38       break;
    39     case 3:
    40       receiveMessage3(e.data);
    41       break;
    42     case 4:
    43       receiveMessage4(e.data);
    44       break;
    45     default:
    46       ok(false, "should not be reached");
    47       Simpletest.finish();
    48   }
    49 }
    51 window.addEventListener("message", receiveMessage, false);
    53 var iframe = document.getElementById('f');
    55 function runTest() {
    56   // Test with data-urls off
    57   SpecialPowers.pushPrefEnv({"set": [["layout.debug.enable_data_xbl", false]]}, runTest1);
    58 }
    60 function runTest1() {
    61   iframe.src = "file_bug379959_data.html";
    62 }
    64 function receiveMessage1(aData) {
    65   is(aData, 0, "data-url load should have failed");
    66   // Test with data-urls on
    67   SpecialPowers.pushPrefEnv({"set": [["layout.debug.enable_data_xbl", true]]}, runTest2);
    68 }
    70 function runTest2() {
    71   iframe.src = "file_bug379959_data.html";
    72 }
    74 function receiveMessage2(aData) {
    75   is(aData, 1, "data-url load should have been successful");
    76   // Try a cross-site load
    77   iframe.src = "file_bug379959_cross.html";
    78 }
    80 function receiveMessage3(aData) {
    81   is(aData, 1, "same site load should have succeeded");
    82 }
    84 function receiveMessage4(aData) {
    85   is(aData, 0, "cross site load should have failed");
    87   // Check that we got the right number of messages to make sure that
    88   // the right message has aligned with the right test
    89   is(messages, 4, "wrong number of messages");
    91   SimpleTest.finish();
    92 }
    94     </script>
    95   </pre>
    96 </body>
    97 </html>

mercurial