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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | const PREF_DISK_CACHE_SSL = "browser.cache.disk_cache_ssl"; |
michael@0 | 5 | const URL = "://example.com/browser/toolkit/components/thumbnails/" + |
michael@0 | 6 | "test/privacy_cache_control.sjs"; |
michael@0 | 7 | |
michael@0 | 8 | function runTests() { |
michael@0 | 9 | registerCleanupFunction(function () { |
michael@0 | 10 | Services.prefs.clearUserPref(PREF_DISK_CACHE_SSL); |
michael@0 | 11 | }); |
michael@0 | 12 | |
michael@0 | 13 | let positive = [ |
michael@0 | 14 | // A normal HTTP page without any Cache-Control header. |
michael@0 | 15 | {scheme: "http", cacheControl: null, diskCacheSSL: false}, |
michael@0 | 16 | |
michael@0 | 17 | // A normal HTTP page with 'Cache-Control: private'. |
michael@0 | 18 | {scheme: "http", cacheControl: "private", diskCacheSSL: false}, |
michael@0 | 19 | |
michael@0 | 20 | // Capture HTTPS pages if browser.cache.disk_cache_ssl == true. |
michael@0 | 21 | {scheme: "https", cacheControl: null, diskCacheSSL: true}, |
michael@0 | 22 | {scheme: "https", cacheControl: "public", diskCacheSSL: true}, |
michael@0 | 23 | {scheme: "https", cacheControl: "private", diskCacheSSL: true} |
michael@0 | 24 | ]; |
michael@0 | 25 | |
michael@0 | 26 | let negative = [ |
michael@0 | 27 | // Never capture pages with 'Cache-Control: no-store'. |
michael@0 | 28 | {scheme: "http", cacheControl: "no-store", diskCacheSSL: false}, |
michael@0 | 29 | {scheme: "http", cacheControl: "no-store", diskCacheSSL: true}, |
michael@0 | 30 | {scheme: "https", cacheControl: "no-store", diskCacheSSL: false}, |
michael@0 | 31 | {scheme: "https", cacheControl: "no-store", diskCacheSSL: true}, |
michael@0 | 32 | |
michael@0 | 33 | // Don't capture HTTPS pages by default. |
michael@0 | 34 | {scheme: "https", cacheControl: null, diskCacheSSL: false}, |
michael@0 | 35 | {scheme: "https", cacheControl: "public", diskCacheSSL: false}, |
michael@0 | 36 | {scheme: "https", cacheControl: "private", diskCacheSSL: false} |
michael@0 | 37 | ]; |
michael@0 | 38 | |
michael@0 | 39 | let urls = positive.map((combi) => { |
michael@0 | 40 | let url = combi.scheme + URL; |
michael@0 | 41 | if (combi.cacheControl) |
michael@0 | 42 | url += "?" + combi.cacheControl; |
michael@0 | 43 | return url; |
michael@0 | 44 | }); |
michael@0 | 45 | yield addVisitsAndRepopulateNewTabLinks(urls, next); |
michael@0 | 46 | |
michael@0 | 47 | yield checkCombinations(positive, true); |
michael@0 | 48 | yield checkCombinations(negative, false); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function checkCombinations(aCombinations, aResult) { |
michael@0 | 52 | let combi = aCombinations.shift(); |
michael@0 | 53 | if (!combi) { |
michael@0 | 54 | next(); |
michael@0 | 55 | return; |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | let url = combi.scheme + URL; |
michael@0 | 59 | if (combi.cacheControl) |
michael@0 | 60 | url += "?" + combi.cacheControl; |
michael@0 | 61 | Services.prefs.setBoolPref(PREF_DISK_CACHE_SSL, combi.diskCacheSSL); |
michael@0 | 62 | |
michael@0 | 63 | let tab = gBrowser.selectedTab = gBrowser.addTab(url); |
michael@0 | 64 | let browser = gBrowser.selectedBrowser; |
michael@0 | 65 | |
michael@0 | 66 | whenLoaded(browser, function () { |
michael@0 | 67 | let msg = JSON.stringify(combi) + " == " + aResult; |
michael@0 | 68 | is(gBrowserThumbnails._shouldCapture(browser), aResult, msg); |
michael@0 | 69 | gBrowser.removeTab(tab); |
michael@0 | 70 | |
michael@0 | 71 | // Continue with the next combination. |
michael@0 | 72 | checkCombinations(aCombinations, aResult); |
michael@0 | 73 | }); |
michael@0 | 74 | } |