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 | const Cc = Components.classes; |
michael@0 | 2 | const Ci = Components.interfaces; |
michael@0 | 3 | const Cu = Components.utils; |
michael@0 | 4 | |
michael@0 | 5 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 6 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 7 | |
michael@0 | 8 | function shouldHaveChanged(a, b) |
michael@0 | 9 | { |
michael@0 | 10 | if (a.length != b.length) { |
michael@0 | 11 | throw Error("TEST-UNEXPECTED-FAIL: telemetry count array size changed"); |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | for (let i = 0; i < a.length; ++i) { |
michael@0 | 15 | if (a[i] == b[i]) { |
michael@0 | 16 | continue; |
michael@0 | 17 | } |
michael@0 | 18 | return; // something was different, that's all that matters |
michael@0 | 19 | } |
michael@0 | 20 | throw Error("TEST-UNEXPECTED-FAIL: telemetry data didn't change"); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | function TestStartupCacheTelemetry() { } |
michael@0 | 24 | |
michael@0 | 25 | TestStartupCacheTelemetry.prototype = { |
michael@0 | 26 | classID: Components.ID("{73cbeffd-d6c7-42f0-aaf3-f176430dcfc8}"), |
michael@0 | 27 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), |
michael@0 | 28 | |
michael@0 | 29 | saveInitial: function() { |
michael@0 | 30 | let t = Services.telemetry; |
michael@0 | 31 | this._age = t.getHistogramById("STARTUP_CACHE_AGE_HOURS").snapshot.counts; |
michael@0 | 32 | this._invalid = t.getHistogramById("STARTUP_CACHE_INVALID").snapshot.counts; |
michael@0 | 33 | }, |
michael@0 | 34 | |
michael@0 | 35 | checkFinal: function() { |
michael@0 | 36 | let t = Services.telemetry; |
michael@0 | 37 | let newAge = t.getHistogramById("STARTUP_CACHE_AGE_HOURS").snapshot.counts; |
michael@0 | 38 | shouldHaveChanged(this._age, newAge); |
michael@0 | 39 | |
michael@0 | 40 | let newInvalid = t.getHistogramById("STARTUP_CACHE_INVALID").snapshot.counts; |
michael@0 | 41 | shouldHaveChanged(this._invalid, newInvalid); |
michael@0 | 42 | }, |
michael@0 | 43 | |
michael@0 | 44 | observe: function(subject, topic, data) { |
michael@0 | 45 | switch (topic) { |
michael@0 | 46 | case "save-initial": |
michael@0 | 47 | this.saveInitial(); |
michael@0 | 48 | break; |
michael@0 | 49 | |
michael@0 | 50 | case "check-final": |
michael@0 | 51 | this.checkFinal(); |
michael@0 | 52 | break; |
michael@0 | 53 | |
michael@0 | 54 | default: |
michael@0 | 55 | throw Error("BADDOG, NO MILKBONE FOR YOU"); |
michael@0 | 56 | } |
michael@0 | 57 | }, |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestStartupCacheTelemetry]); |