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 | function run_test() { |
michael@0 | 2 | var ios = Components.classes["@mozilla.org/network/io-service;1"]. |
michael@0 | 3 | getService(Components.interfaces.nsIIOService); |
michael@0 | 4 | |
michael@0 | 5 | var dataFile = do_get_file("data/bug121341.properties"); |
michael@0 | 6 | |
michael@0 | 7 | var channel = ios.newChannelFromURI(ios.newFileURI(dataFile, null, null)); |
michael@0 | 8 | var inp = channel.open(); |
michael@0 | 9 | |
michael@0 | 10 | var properties = Components.classes["@mozilla.org/persistent-properties;1"]. |
michael@0 | 11 | createInstance(Components.interfaces.nsIPersistentProperties); |
michael@0 | 12 | properties.load(inp); |
michael@0 | 13 | |
michael@0 | 14 | var value; |
michael@0 | 15 | |
michael@0 | 16 | value = properties.getStringProperty("1"); |
michael@0 | 17 | do_check_eq(value, "abc"); |
michael@0 | 18 | |
michael@0 | 19 | value = properties.getStringProperty("2"); |
michael@0 | 20 | do_check_eq(value, "xy"); |
michael@0 | 21 | |
michael@0 | 22 | value = properties.getStringProperty("3"); |
michael@0 | 23 | do_check_eq(value, "\u1234\t\r\n\u00AB\u0001\n"); |
michael@0 | 24 | |
michael@0 | 25 | value = properties.getStringProperty("4"); |
michael@0 | 26 | do_check_eq(value, "this is multiline property"); |
michael@0 | 27 | |
michael@0 | 28 | value = properties.getStringProperty("5"); |
michael@0 | 29 | do_check_eq(value, "this is another multiline property"); |
michael@0 | 30 | |
michael@0 | 31 | value = properties.getStringProperty("6"); |
michael@0 | 32 | do_check_eq(value, "test\u0036"); |
michael@0 | 33 | |
michael@0 | 34 | value = properties.getStringProperty("7"); |
michael@0 | 35 | do_check_eq(value, "yet another multiline propery"); |
michael@0 | 36 | |
michael@0 | 37 | value = properties.getStringProperty("8"); |
michael@0 | 38 | do_check_eq(value, "\ttest5\u0020"); |
michael@0 | 39 | |
michael@0 | 40 | value = properties.getStringProperty("9"); |
michael@0 | 41 | do_check_eq(value, " test6\t"); |
michael@0 | 42 | |
michael@0 | 43 | value = properties.getStringProperty("10a\u1234b"); |
michael@0 | 44 | do_check_eq(value, "c\uCDEFd"); |
michael@0 | 45 | |
michael@0 | 46 | value = properties.getStringProperty("11"); |
michael@0 | 47 | do_check_eq(value, "\uABCD"); |
michael@0 | 48 | |
michael@0 | 49 | dataFile = do_get_file("data/bug121341-2.properties"); |
michael@0 | 50 | |
michael@0 | 51 | channel = ios.newChannelFromURI(ios.newFileURI(dataFile, null, null)); |
michael@0 | 52 | inp = channel.open(); |
michael@0 | 53 | |
michael@0 | 54 | var properties2 = Components.classes["@mozilla.org/persistent-properties;1"]. |
michael@0 | 55 | createInstance(Components.interfaces.nsIPersistentProperties); |
michael@0 | 56 | try { |
michael@0 | 57 | properties2.load(inp); |
michael@0 | 58 | do_throw("load() didn't fail"); |
michael@0 | 59 | } |
michael@0 | 60 | catch (e) { |
michael@0 | 61 | } |
michael@0 | 62 | } |