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 | <html xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 2 | <!-- |
michael@0 | 3 | https://bugzilla.mozilla.org/show_bug.cgi?id=311681 |
michael@0 | 4 | --> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Test for Bug 311681</title> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body> |
michael@0 | 11 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=311681">Mozilla Bug 311681</a> |
michael@0 | 12 | <script class="testbody" type="text/javascript"> |
michael@0 | 13 | <![CDATA[ |
michael@0 | 14 | // Setup script |
michael@0 | 15 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 16 | |
michael@0 | 17 | // Make sure to trigger the hashtable case by asking for enough elements |
michael@0 | 18 | // by ID. |
michael@0 | 19 | for (var i = 0; i < 256; ++i) { |
michael@0 | 20 | var x = document.getElementById(i); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | // save off the document.getElementById function, since getting it as a |
michael@0 | 24 | // property off the document it causes a content flush. |
michael@0 | 25 | var fun = document.getElementById; |
michael@0 | 26 | |
michael@0 | 27 | // Slot for our initial element with id "content" |
michael@0 | 28 | var testNode; |
michael@0 | 29 | |
michael@0 | 30 | function getCont() { |
michael@0 | 31 | return fun.call(document, "content"); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function testClone() { |
michael@0 | 35 | // Test to make sure that if we have multiple nodes with the same ID in |
michael@0 | 36 | // a document we don't forget about one of them when the other is |
michael@0 | 37 | // removed. |
michael@0 | 38 | var newParent = $("display"); |
michael@0 | 39 | var node = testNode.cloneNode(true); |
michael@0 | 40 | isnot(node, testNode, "Clone should be a different node"); |
michael@0 | 41 | |
michael@0 | 42 | newParent.appendChild(node); |
michael@0 | 43 | |
michael@0 | 44 | // Check what getElementById returns, no flushing |
michael@0 | 45 | is(getCont(), node, "Should be getting new node pre-flush 1"); |
michael@0 | 46 | |
michael@0 | 47 | // Trigger a layout flush, just in case. |
michael@0 | 48 | var itemHeight = newParent.offsetHeight/10; |
michael@0 | 49 | |
michael@0 | 50 | // Check what getElementById returns now. |
michael@0 | 51 | is(getCont(), node, "Should be getting new node post-flush 1"); |
michael@0 | 52 | |
michael@0 | 53 | clear(newParent); |
michael@0 | 54 | |
michael@0 | 55 | // Check what getElementById returns, no flushing |
michael@0 | 56 | is(getCont(), testNode, "Should be getting orig node pre-flush 2"); |
michael@0 | 57 | |
michael@0 | 58 | // Trigger a layout flush, just in case. |
michael@0 | 59 | var itemHeight = newParent.offsetHeight/10; |
michael@0 | 60 | |
michael@0 | 61 | // Check what getElementById returns now. |
michael@0 | 62 | is(getCont(), testNode, "Should be getting orig node post-flush 2"); |
michael@0 | 63 | |
michael@0 | 64 | node = testNode.cloneNode(true); |
michael@0 | 65 | newParent.appendChild(node); |
michael@0 | 66 | testNode.parentNode.removeChild(testNode); |
michael@0 | 67 | |
michael@0 | 68 | // Check what getElementById returns, no flushing |
michael@0 | 69 | is(getCont(), node, "Should be getting clone pre-flush"); |
michael@0 | 70 | |
michael@0 | 71 | // Trigger a layout flush, just in case. |
michael@0 | 72 | var itemHeight = newParent.offsetHeight/10; |
michael@0 | 73 | |
michael@0 | 74 | // Check what getElementById returns now. |
michael@0 | 75 | is(getCont(), node, "Should be getting clone post-flush"); |
michael@0 | 76 | |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | function clear(node) { |
michael@0 | 80 | while (node.hasChildNodes()) { |
michael@0 | 81 | node.removeChild(node.firstChild); |
michael@0 | 82 | } |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | addLoadEvent(testClone); |
michael@0 | 86 | addLoadEvent(SimpleTest.finish); |
michael@0 | 87 | ]]> |
michael@0 | 88 | </script> |
michael@0 | 89 | <p id="display"></p> |
michael@0 | 90 | <div id="content" style="display: none"> |
michael@0 | 91 | <script class="testbody" type="text/javascript"> |
michael@0 | 92 | <![CDATA[ |
michael@0 | 93 | testNode = fun.call(document, "content"); |
michael@0 | 94 | ok(testNode != null, "Should have node here"); |
michael@0 | 95 | ]]> |
michael@0 | 96 | </script> |
michael@0 | 97 | </div> |
michael@0 | 98 | <pre id="test"> |
michael@0 | 99 | </pre> |
michael@0 | 100 | </body> |
michael@0 | 101 | </html> |
michael@0 | 102 |