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=534804 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 534804</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | <style type="text/css" id="styleone"> </style> |
michael@0 | 11 | <style type="text/css" id="styletwo"> </style> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534804">Mozilla Bug 534804</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <pre id="test"> |
michael@0 | 17 | <script type="application/javascript"> |
michael@0 | 18 | |
michael@0 | 19 | /** Test for Bug 534804 **/ |
michael@0 | 20 | |
michael@0 | 21 | var styleone = document.getElementById("styleone"); |
michael@0 | 22 | var styletwo = document.getElementById("styletwo"); |
michael@0 | 23 | var display = document.getElementById("display"); |
michael@0 | 24 | |
michael@0 | 25 | run1(); |
michael@0 | 26 | styletwo.firstChild.data = "#e > span:nth-child(2n+1) { color: green }"; |
michael@0 | 27 | run1(); |
michael@0 | 28 | styletwo.firstChild.data = "#e > span:first-child { color: green }"; |
michael@0 | 29 | run1(); |
michael@0 | 30 | styletwo.firstChild.data = "#e > span:nth-last-child(2n+1) { color: green }"; |
michael@0 | 31 | run1(); |
michael@0 | 32 | styletwo.firstChild.data = "#e > span:last-child { color: green }"; |
michael@0 | 33 | run1(); |
michael@0 | 34 | |
michael@0 | 35 | function run1() |
michael@0 | 36 | { |
michael@0 | 37 | function identity(bool) { return bool; } |
michael@0 | 38 | function inverse(bool) { return !bool; } |
michael@0 | 39 | function always_false(bool) { return false; } |
michael@0 | 40 | run2("#e:empty + span", identity, always_false); |
michael@0 | 41 | run2("#e:empty ~ span", identity, identity); |
michael@0 | 42 | run2("#e:not(:empty) + span", inverse, always_false); |
michael@0 | 43 | run2("#e:not(:empty) ~ span", inverse, inverse); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function run2(sel, next_sibling_rule, later_sibling_rule) |
michael@0 | 47 | { |
michael@0 | 48 | styleone.firstChild.data = sel + " { text-decoration: underline }"; |
michael@0 | 49 | |
michael@0 | 50 | // Rebuild the subtree every time. |
michael@0 | 51 | var span1 = document.createElement("span"); |
michael@0 | 52 | span1.id = "e"; |
michael@0 | 53 | var span2 = document.createElement("span"); |
michael@0 | 54 | var span3 = document.createElement("span"); |
michael@0 | 55 | display.appendChild(span1); |
michael@0 | 56 | display.appendChild(span2); |
michael@0 | 57 | display.appendChild(span3); |
michael@0 | 58 | |
michael@0 | 59 | function td(e) { return getComputedStyle(e, "").textDecoration; } |
michael@0 | 60 | |
michael@0 | 61 | function check(desc, isempty) { |
michael@0 | 62 | is(td(span2), next_sibling_rule(isempty) ? "underline" : "none", |
michael@0 | 63 | "match of next sibling in state " + desc); |
michael@0 | 64 | is(td(span3), later_sibling_rule(isempty) ? "underline" : "none", |
michael@0 | 65 | "match of next sibling in state " + desc); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | check("initially empty", true); |
michael@0 | 69 | var kid = document.createElement("span"); |
michael@0 | 70 | span1.appendChild(kid); |
michael@0 | 71 | check("after append", false); |
michael@0 | 72 | span1.removeChild(kid); |
michael@0 | 73 | check("after remove", true); |
michael@0 | 74 | span1.appendChild(document.createTextNode("")); |
michael@0 | 75 | span1.appendChild(document.createComment("a comment")); |
michael@0 | 76 | span1.appendChild(document.createTextNode("")); |
michael@0 | 77 | check("after append of insignificant children", true); |
michael@0 | 78 | span1.insertBefore(kid, span1.childNodes[1]); |
michael@0 | 79 | check("after insert", false); |
michael@0 | 80 | |
michael@0 | 81 | display.removeChild(span1); |
michael@0 | 82 | display.removeChild(span2); |
michael@0 | 83 | display.removeChild(span3); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | </script> |
michael@0 | 87 | </pre> |
michael@0 | 88 | </body> |
michael@0 | 89 | </html> |