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=255820 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
michael@0 | 8 | <title>Test for Bug 255820</title> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=255820">Mozilla Bug 255820</a> |
michael@0 | 14 | <p id="display"> |
michael@0 | 15 | <iframe id="f1"></iframe> |
michael@0 | 16 | <iframe id="f2"></iframe> |
michael@0 | 17 | <iframe id="f3"></iframe> |
michael@0 | 18 | </p> |
michael@0 | 19 | <div id="content" style="display: none"> |
michael@0 | 20 | |
michael@0 | 21 | </div> |
michael@0 | 22 | <pre id="test"> |
michael@0 | 23 | <script class="testbody" type="text/javascript"> |
michael@0 | 24 | |
michael@0 | 25 | /** Test for Bug 255820 **/ |
michael@0 | 26 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 27 | |
michael@0 | 28 | is(document.characterSet, "UTF-8", |
michael@0 | 29 | "Unexpected character set for our document"); |
michael@0 | 30 | |
michael@0 | 31 | var testsLeft = 4; |
michael@0 | 32 | |
michael@0 | 33 | function testFinished() { |
michael@0 | 34 | --testsLeft; |
michael@0 | 35 | if (testsLeft == 0) { |
michael@0 | 36 | SimpleTest.finish(); |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function charsetTestFinished(id, doc, charsetTarget) { |
michael@0 | 41 | is(doc.characterSet, charsetTarget, "Unexpected charset for subframe " + id); |
michael@0 | 42 | testFinished(); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function f2Continue() { |
michael@0 | 46 | // Commented out pending discussion at the WHATWG |
michael@0 | 47 | // $("f2"). |
michael@0 | 48 | // setAttribute("onload", |
michael@0 | 49 | // "charsetTestFinished('f2 reloaded', this.contentDocument, 'us-ascii');"); |
michael@0 | 50 | $("f2"). |
michael@0 | 51 | setAttribute("onload", |
michael@0 | 52 | "testFinished();"); |
michael@0 | 53 | $("f2").contentWindow.location.reload(); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function f3Continue() { |
michael@0 | 57 | var doc = $("f3").contentDocument; |
michael@0 | 58 | is(doc.defaultView.getComputedStyle(doc.body, "").color, "rgb(0, 180, 0)", |
michael@0 | 59 | "Wrong color before reload"); |
michael@0 | 60 | $("f3"). |
michael@0 | 61 | setAttribute("onload", |
michael@0 | 62 | 'var doc = this.contentDocument; ' + |
michael@0 | 63 | 'is(doc.defaultView.getComputedStyle(doc.body, "").color, ' + |
michael@0 | 64 | ' "rgb(0, 180, 0)",' + |
michael@0 | 65 | ' "Wrong color after reload");' + |
michael@0 | 66 | "charsetTestFinished('f1', this.contentDocument, 'UTF-8')"); |
michael@0 | 67 | $("f3").contentWindow.location.reload(); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | function runTest() { |
michael@0 | 71 | var doc = $("f1").contentDocument; |
michael@0 | 72 | is(doc.characterSet, "UTF-8", |
michael@0 | 73 | "Unexpected initial character set for first frame"); |
michael@0 | 74 | doc.open(); |
michael@0 | 75 | doc.write('<html></html>'); |
michael@0 | 76 | doc.close(); |
michael@0 | 77 | is(doc.characterSet, "UTF-8", |
michael@0 | 78 | "Unexpected character set for first frame after write"); |
michael@0 | 79 | $("f1"). |
michael@0 | 80 | setAttribute("onload", |
michael@0 | 81 | "charsetTestFinished('f1', this.contentDocument, 'UTF-8')"); |
michael@0 | 82 | $("f1").contentWindow.location.reload(); |
michael@0 | 83 | |
michael@0 | 84 | doc = $("f2").contentDocument; |
michael@0 | 85 | is(doc.characterSet, "UTF-8", |
michael@0 | 86 | "Unexpected initial character set for second frame"); |
michael@0 | 87 | doc.open(); |
michael@0 | 88 | var str = '<html><head>'; |
michael@0 | 89 | str += '<script src="data:application/javascript,"><'+'/script>'; |
michael@0 | 90 | str += '<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">'; |
michael@0 | 91 | str += '</head><body>'; |
michael@0 | 92 | str += '</body></html>'; |
michael@0 | 93 | doc.write(str); |
michael@0 | 94 | doc.close(); |
michael@0 | 95 | is(doc.characterSet, "UTF-8", |
michael@0 | 96 | "Unexpected character set for second frame after write"); |
michael@0 | 97 | $("f2"). |
michael@0 | 98 | setAttribute("onload", |
michael@0 | 99 | "charsetTestFinished('f2', this.contentDocument, 'UTF-8');" + |
michael@0 | 100 | "f2Continue()"); |
michael@0 | 101 | |
michael@0 | 102 | doc = $("f3").contentDocument; |
michael@0 | 103 | is(doc.characterSet, "UTF-8", |
michael@0 | 104 | "Unexpected initial character set for first frame"); |
michael@0 | 105 | doc.open(); |
michael@0 | 106 | var str = '<html><head>'; |
michael@0 | 107 | str += '<style>body { color: rgb(255, 0, 0) }</style>'; |
michael@0 | 108 | str += '<link type="text/css" rel="stylesheet" href="data:text/css, body { color: rgb(0, 180, 0) }">'; |
michael@0 | 109 | str += '</head><body>'; |
michael@0 | 110 | str += '</body></html>'; |
michael@0 | 111 | doc.write(str); |
michael@0 | 112 | doc.close(); |
michael@0 | 113 | is(doc.characterSet, "UTF-8", |
michael@0 | 114 | "Unexpected character set for first frame after write"); |
michael@0 | 115 | $("f3").setAttribute("onload", "f3Continue()"); |
michael@0 | 116 | } |
michael@0 | 117 | |
michael@0 | 118 | addLoadEvent(runTest); |
michael@0 | 119 | </script> |
michael@0 | 120 | </pre> |
michael@0 | 121 | </body> |
michael@0 | 122 | </html> |
michael@0 | 123 |