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=292789 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 292789</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> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=292789">Mozilla Bug 292789</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | <script src="chrome://global/content/treeUtils.js"></script> |
michael@0 | 16 | <script type="application/javascript;version=1.8" src="chrome://mozapps/content/xpinstall/xpinstallConfirm.js"></script> |
michael@0 | 17 | <script id="resjs" type="application/javascript;version=1.8"></script> |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | /** Test for Bug 292789 |
michael@0 | 23 | ** |
michael@0 | 24 | ** Selectively allow access to whitelisted chrome packages |
michael@0 | 25 | ** even for ALLOW_CHROME mechanisms (<script>, <img> etc) |
michael@0 | 26 | **/ |
michael@0 | 27 | |
michael@0 | 28 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 29 | |
michael@0 | 30 | /** <script src=""> test **/ |
michael@0 | 31 | function testScriptSrc(aCallback) { |
michael@0 | 32 | is(typeof gTreeUtils.sort, "function", |
michael@0 | 33 | "content can still load <script> from chrome://global"); |
michael@0 | 34 | is(typeof XPInstallConfirm, "undefined", |
michael@0 | 35 | "content should not be able to load <script> from chrome://mozapps"); |
michael@0 | 36 | |
michael@0 | 37 | /** make sure the last one didn't pass because someone |
michael@0 | 38 | ** moved the resource |
michael@0 | 39 | **/ |
michael@0 | 40 | var resjs = document.getElementById("resjs"); |
michael@0 | 41 | resjs.onload = scriptOnload; |
michael@0 | 42 | resjs.src = "resource://gre/chrome/toolkit/content/mozapps/xpinstall/xpinstallConfirm.js"; |
michael@0 | 43 | document.getElementById("content").appendChild(resjs); |
michael@0 | 44 | |
michael@0 | 45 | function scriptOnload() { |
michael@0 | 46 | is(typeof XPInstallConfirm, "object", |
michael@0 | 47 | "xpinstallConfirm.js has not moved unexpectedly"); |
michael@0 | 48 | |
michael@0 | 49 | // trigger the callback |
michael@0 | 50 | if (aCallback) |
michael@0 | 51 | aCallback(); |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | /** <img src=""> tests **/ |
michael@0 | 56 | var img_global = "chrome://global/skin/icons/Error.png"; |
michael@0 | 57 | var img_mozapps = "chrome://mozapps/skin/passwordmgr/key.png"; |
michael@0 | 58 | var res_mozapps = "resource://gre/chrome/toolkit/skin/classic/mozapps/passwordmgr/key.png"; |
michael@0 | 59 | |
michael@0 | 60 | var imgTests = [[img_global, "success"], |
michael@0 | 61 | [img_mozapps, "fail"], |
michael@0 | 62 | [res_mozapps, "success"]]; |
michael@0 | 63 | |
michael@0 | 64 | var curImgTest = 0; |
michael@0 | 65 | |
michael@0 | 66 | function runImgTest() { |
michael@0 | 67 | var test = imgTests[curImgTest++]; |
michael@0 | 68 | var callback = curImgTest == imgTests.length ? finishTest : runImgTest; |
michael@0 | 69 | loadImage(test[0], test[1], callback); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function finishTest() { |
michael@0 | 73 | SimpleTest.finish(); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | function fail(event) { |
michael@0 | 77 | is(event.target.expected, "fail", |
michael@0 | 78 | "content should not be allowed to load "+event.target.src); |
michael@0 | 79 | if (event.target.callback) |
michael@0 | 80 | event.target.callback(); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | function success(event) { |
michael@0 | 84 | is(event.target.expected, "success", |
michael@0 | 85 | "content should be able to load "+event.target.src); |
michael@0 | 86 | if (event.target.callback) |
michael@0 | 87 | event.target.callback(); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | function loadImage(uri, expect, callback) { |
michael@0 | 91 | var img = document.createElement("img"); |
michael@0 | 92 | img.onerror = fail; |
michael@0 | 93 | img.onload = success; |
michael@0 | 94 | img.expected = expect; |
michael@0 | 95 | img.callback = callback; |
michael@0 | 96 | img.src = uri; |
michael@0 | 97 | //document.getElementById("content").appendChild(img); |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | // Start off the script src test, and have it start the img tests when complete. |
michael@0 | 101 | testScriptSrc(runImgTest); |
michael@0 | 102 | </script> |
michael@0 | 103 | </pre> |
michael@0 | 104 | </body> |
michael@0 | 105 | </html> |