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