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 Cu = Components.utils; |
michael@0 | 2 | const READWRITE = "readwrite"; |
michael@0 | 3 | const UNKNOWN = "foobar"; |
michael@0 | 4 | |
michael@0 | 5 | var gData = [ |
michael@0 | 6 | // test normal expansion |
michael@0 | 7 | { |
michael@0 | 8 | permission: "contacts", |
michael@0 | 9 | access: READWRITE, |
michael@0 | 10 | expected: ["contacts-read", "contacts-create", |
michael@0 | 11 | "contacts-write"] |
michael@0 | 12 | }, |
michael@0 | 13 | // test additional expansion and access not having read+create+write |
michael@0 | 14 | { |
michael@0 | 15 | permission: "settings", |
michael@0 | 16 | access: READWRITE, |
michael@0 | 17 | expected: ["settings-read", "settings-write", |
michael@0 | 18 | "indexedDB-chrome-settings-read", |
michael@0 | 19 | "indexedDB-chrome-settings-write"] |
michael@0 | 20 | }, |
michael@0 | 21 | // test substitute |
michael@0 | 22 | { |
michael@0 | 23 | permission: "storage", |
michael@0 | 24 | expected: ["indexedDB-unlimited", |
michael@0 | 25 | "default-persistent-storage"] |
michael@0 | 26 | }, |
michael@0 | 27 | // test unknown access |
michael@0 | 28 | { |
michael@0 | 29 | permission: "contacts", |
michael@0 | 30 | access: UNKNOWN, |
michael@0 | 31 | expected: [] |
michael@0 | 32 | }, |
michael@0 | 33 | // test unknown permission |
michael@0 | 34 | { |
michael@0 | 35 | permission: UNKNOWN, |
michael@0 | 36 | access: READWRITE, |
michael@0 | 37 | expected: [] |
michael@0 | 38 | } |
michael@0 | 39 | ]; |
michael@0 | 40 | |
michael@0 | 41 | // check if 2 arrays contain the same elements |
michael@0 | 42 | function do_check_set_eq(a1, a2) { |
michael@0 | 43 | do_check_eq(a1.length, a2.length) |
michael@0 | 44 | |
michael@0 | 45 | Array.sort(a1); |
michael@0 | 46 | Array.sort(a2); |
michael@0 | 47 | |
michael@0 | 48 | for (let i = 0; i < a1.length; ++i) { |
michael@0 | 49 | do_check_eq(a1[i], a2[i]) |
michael@0 | 50 | } |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function run_test() { |
michael@0 | 54 | var scope = {}; |
michael@0 | 55 | Cu.import("resource://gre/modules/PermissionsTable.jsm", scope); |
michael@0 | 56 | |
michael@0 | 57 | for (var i = 0; i < gData.length; i++) { |
michael@0 | 58 | var perms = scope.expandPermissions(gData[i].permission, |
michael@0 | 59 | gData[i].access); |
michael@0 | 60 | do_check_set_eq(perms, gData[i].expected); |
michael@0 | 61 | } |
michael@0 | 62 | } |