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=449141 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 449141</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=449141">Mozilla Bug 449141</a> |
michael@0 | 13 | <p id="display"> |
michael@0 | 14 | |
michael@0 | 15 | </p> |
michael@0 | 16 | <pre id="results"></pre> |
michael@0 | 17 | <div id="content" style="display: none"> |
michael@0 | 18 | <iframe src="bug449141_page.html" id="source"></iframe> |
michael@0 | 19 | </div> |
michael@0 | 20 | <pre id="test"> |
michael@0 | 21 | <script class="testbody" type="text/javascript"> |
michael@0 | 22 | /** Test for Bug 449141 **/ |
michael@0 | 23 | |
michael@0 | 24 | const Cc = SpecialPowers.Cc; |
michael@0 | 25 | const Ci = SpecialPowers.Ci; |
michael@0 | 26 | |
michael@0 | 27 | function getTempDir() { |
michael@0 | 28 | return Cc["@mozilla.org/file/directory_service;1"] |
michael@0 | 29 | .getService(Ci.nsIProperties) |
michael@0 | 30 | .get("TmpD", Ci.nsILocalFile); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | // STATE_STOP from nsIWebProgressListener.idl |
michael@0 | 34 | const STATE_STOP = 0x00000010; |
michael@0 | 35 | |
michael@0 | 36 | var progressListener = { |
michael@0 | 37 | onProgressChange: function() { |
michael@0 | 38 | /* Ignore progress callback */ |
michael@0 | 39 | }, |
michael@0 | 40 | onStateChange: function(aProgress, aRequest, aStateFlag, aStatus) { |
michael@0 | 41 | if (aStateFlag & STATE_STOP) { |
michael@0 | 42 | var dirExists = false; |
michael@0 | 43 | var videoExists = false; |
michael@0 | 44 | |
michael@0 | 45 | var videoFile = getTempDir(); |
michael@0 | 46 | videoFile.append(this.dirName); |
michael@0 | 47 | dirExists = videoFile.exists(); |
michael@0 | 48 | videoFile.append("320x240.ogv"); |
michael@0 | 49 | videoExists = videoFile.exists(); |
michael@0 | 50 | this.folder.remove(true); |
michael@0 | 51 | this.file.remove(false); |
michael@0 | 52 | ok(dirExists, 'Directory containing video file should be created'); |
michael@0 | 53 | ok(videoExists, 'Video should be persisted with document'); |
michael@0 | 54 | SimpleTest.finish(); |
michael@0 | 55 | } |
michael@0 | 56 | } |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | function persistDocument(aDoc) { |
michael@0 | 60 | const nsIWBP = Ci.nsIWebBrowserPersist; |
michael@0 | 61 | const persistFlags = |
michael@0 | 62 | nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES |
michael@0 | 63 | | nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION |
michael@0 | 64 | const encodingFlags = |
michael@0 | 65 | nsIWBP.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES; |
michael@0 | 66 | |
michael@0 | 67 | var ioService = Cc["@mozilla.org/network/io-service;1"] |
michael@0 | 68 | .getService(Ci.nsIIOService); |
michael@0 | 69 | |
michael@0 | 70 | var id = Math.round(Math.random() * 10000); |
michael@0 | 71 | var dirName = "bug449141_serialized" + id; |
michael@0 | 72 | progressListener.dirName = dirName; |
michael@0 | 73 | |
michael@0 | 74 | var file = getTempDir(); |
michael@0 | 75 | file.append("bug449141-serialized" + id + ".html"); |
michael@0 | 76 | |
michael@0 | 77 | var persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] |
michael@0 | 78 | .createInstance(Ci.nsIWebBrowserPersist); |
michael@0 | 79 | persist.progressListener = progressListener; |
michael@0 | 80 | persist.persistFlags = persistFlags; |
michael@0 | 81 | const kWrapColumn = 80; |
michael@0 | 82 | var folder = getTempDir(); |
michael@0 | 83 | folder.append(dirName); |
michael@0 | 84 | progressListener.folder = folder; |
michael@0 | 85 | progressListener.file = file; |
michael@0 | 86 | persist.saveDocument(aDoc, ioService.newFileURI(file), |
michael@0 | 87 | folder, |
michael@0 | 88 | aDoc.contentType, |
michael@0 | 89 | encodingFlags, kWrapColumn); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 93 | |
michael@0 | 94 | addLoadEvent(function() { |
michael@0 | 95 | netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
michael@0 | 96 | var srcDoc = document.getElementById('source').contentDocument; |
michael@0 | 97 | persistDocument(srcDoc); |
michael@0 | 98 | }); |
michael@0 | 99 | </script> |
michael@0 | 100 | </pre> |
michael@0 | 101 | </body> |
michael@0 | 102 | </html> |