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=147777 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 147777</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=147777">Mozilla Bug 147777</a> |
michael@0 | 14 | <iframe id="iframe" src="visited-lying-inner.html" style="width: 20em; height: 5em"></iframe> |
michael@0 | 15 | <pre id="test"> |
michael@0 | 16 | <script type="application/javascript"> |
michael@0 | 17 | |
michael@0 | 18 | /** Test for Bug 147777 **/ |
michael@0 | 19 | |
michael@0 | 20 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 21 | window.addEventListener("load", start, false); |
michael@0 | 22 | |
michael@0 | 23 | var iframe; |
michael@0 | 24 | var visitedlink, unvisitedlink; |
michael@0 | 25 | var snapshot1; |
michael@0 | 26 | |
michael@0 | 27 | function start() |
michael@0 | 28 | { |
michael@0 | 29 | // Our load event has fired, so we know our iframe is loaded. |
michael@0 | 30 | iframe = document.getElementById("iframe"); |
michael@0 | 31 | visitedlink = iframe.contentDocument.getElementById("visitedlink"); |
michael@0 | 32 | unvisitedlink = iframe.contentDocument.getElementById("unvisitedlink"); |
michael@0 | 33 | |
michael@0 | 34 | // First, take a snapshot of it with both links unvisited. |
michael@0 | 35 | snapshot1 = snapshotWindow(iframe.contentWindow, false); |
michael@0 | 36 | |
michael@0 | 37 | // Then, change one of the links in the iframe to being visited. |
michael@0 | 38 | visitedlink.href = window.location; |
michael@0 | 39 | |
michael@0 | 40 | // Then, start polling to see when the history has updated the display. |
michael@0 | 41 | setTimeout(poll_for_restyle, 100); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function poll_for_restyle() |
michael@0 | 45 | { |
michael@0 | 46 | var snapshot2 = snapshotWindow(iframe.contentWindow, false); |
michael@0 | 47 | var equal = compareSnapshots(snapshot1, snapshot2, true)[0]; |
michael@0 | 48 | if (equal) { |
michael@0 | 49 | // keep polling |
michael@0 | 50 | setTimeout(poll_for_restyle, 100); |
michael@0 | 51 | } else { |
michael@0 | 52 | // We now know that the link is visited, so we're ready to run |
michael@0 | 53 | // tests. |
michael@0 | 54 | run_tests(); |
michael@0 | 55 | } |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function run_tests() |
michael@0 | 59 | { |
michael@0 | 60 | // Test querySelector and querySelectorAll. |
michael@0 | 61 | var subdoc = iframe.contentDocument; |
michael@0 | 62 | is(subdoc.querySelector(":link"), unvisitedlink, |
michael@0 | 63 | "first :link should be the unvisited link"); |
michael@0 | 64 | is(subdoc.querySelector(":visited"), null, |
michael@0 | 65 | "querySelector should not find anything :visited"); |
michael@0 | 66 | var qsr = subdoc.querySelectorAll(":link"); |
michael@0 | 67 | is(qsr.length, 2, "querySelectorAll(:link) should find 2 results"); |
michael@0 | 68 | is(qsr[0], unvisitedlink, "querySelectorAll(:link)[0]"); |
michael@0 | 69 | is(qsr[1], visitedlink, "querySelectorAll(:link)[1]"); |
michael@0 | 70 | qsr = subdoc.querySelectorAll(":visited"); |
michael@0 | 71 | is(qsr.length, 0, "querySelectorAll(:visited) should find 0 results"); |
michael@0 | 72 | |
michael@0 | 73 | // Test getComputedStyle. |
michael@0 | 74 | var subwin = iframe.contentWindow; |
michael@0 | 75 | is(subwin.getComputedStyle(unvisitedlink, "").color, "rgb(0, 0, 255)", |
michael@0 | 76 | "getComputedStyle on unvisited link should report color is blue"); |
michael@0 | 77 | is(subwin.getComputedStyle(visitedlink, "").color, "rgb(0, 0, 255)", |
michael@0 | 78 | "getComputedStyle on visited link should report color is blue"); |
michael@0 | 79 | |
michael@0 | 80 | // Test mozMatchesSelector. |
michael@0 | 81 | is(unvisitedlink.mozMatchesSelector(":link"), true, |
michael@0 | 82 | "unvisited link matches :link"); |
michael@0 | 83 | is(visitedlink.mozMatchesSelector(":link"), true, |
michael@0 | 84 | "visited link matches :link"); |
michael@0 | 85 | is(unvisitedlink.mozMatchesSelector(":visited"), false, |
michael@0 | 86 | "unvisited link does not match :visited"); |
michael@0 | 87 | is(visitedlink.mozMatchesSelector(":visited"), false, |
michael@0 | 88 | "visited link does not match :visited"); |
michael@0 | 89 | |
michael@0 | 90 | SimpleTest.finish(); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | </script> |
michael@0 | 94 | </pre> |
michael@0 | 95 | </body> |
michael@0 | 96 | </html> |