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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 6 | |
michael@0 | 7 | const Cc = Components.classes; |
michael@0 | 8 | const Ci = Components.interfaces; |
michael@0 | 9 | const Cu = Components.utils; |
michael@0 | 10 | |
michael@0 | 11 | function do_check_true(cond, text) { |
michael@0 | 12 | // we don't have the test harness' utilities in this scope, so we need this |
michael@0 | 13 | // little helper. In the failure case, the exception is propagated to the |
michael@0 | 14 | // caller in the main run_test() function, and the test fails. |
michael@0 | 15 | if (!cond) |
michael@0 | 16 | throw "Failed check: " + text; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function BlobComponent() { |
michael@0 | 20 | this.wrappedJSObject = this; |
michael@0 | 21 | } |
michael@0 | 22 | BlobComponent.prototype = |
michael@0 | 23 | { |
michael@0 | 24 | doTest: function() { |
michael@0 | 25 | // throw if anything goes wrong |
michael@0 | 26 | let testContent = "<a id=\"a\"><b id=\"b\">hey!<\/b><\/a>"; |
michael@0 | 27 | // should be able to construct a file |
michael@0 | 28 | var f1 = Blob([testContent], {"type" : "text/xml"}); |
michael@0 | 29 | // with either constructor syntax |
michael@0 | 30 | var f2 = new Blob([testContent], {"type" : "text/xml"}); |
michael@0 | 31 | |
michael@0 | 32 | // do some tests |
michael@0 | 33 | do_check_true(f1 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob"); |
michael@0 | 34 | do_check_true(f2 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob"); |
michael@0 | 35 | |
michael@0 | 36 | do_check_true(!(f1 instanceof Ci.nsIDOMFile), "Should not be a DOM File"); |
michael@0 | 37 | do_check_true(!(f2 instanceof Ci.nsIDOMFile), "Should not be a DOM File"); |
michael@0 | 38 | |
michael@0 | 39 | do_check_true(f1.type == "text/xml", "Wrong type"); |
michael@0 | 40 | do_check_true(f2.type == "text/xml", "Wrong type"); |
michael@0 | 41 | |
michael@0 | 42 | do_check_true(f1.size == testContent.length, "Wrong content size"); |
michael@0 | 43 | do_check_true(f2.size == testContent.length, "Wrong content size"); |
michael@0 | 44 | |
michael@0 | 45 | var f3 = new Blob(); |
michael@0 | 46 | do_check_true(f3.size == 0, "Wrong size"); |
michael@0 | 47 | do_check_true(f3.type == "", "Wrong type"); |
michael@0 | 48 | |
michael@0 | 49 | var threw = false; |
michael@0 | 50 | try { |
michael@0 | 51 | // Needs a valid ctor argument |
michael@0 | 52 | var f3 = Blob(Date(132131532)); |
michael@0 | 53 | } catch (e) { |
michael@0 | 54 | threw = true; |
michael@0 | 55 | } |
michael@0 | 56 | do_check_true(threw, "Passing a random object should fail"); |
michael@0 | 57 | |
michael@0 | 58 | return true; |
michael@0 | 59 | }, |
michael@0 | 60 | |
michael@0 | 61 | // nsIClassInfo + information for XPCOM registration code in XPCOMUtils.jsm |
michael@0 | 62 | classDescription: "Blob in components scope code", |
michael@0 | 63 | classID: Components.ID("{06215993-a3c2-41e3-bdfd-0a3a2cc0b65c}"), |
michael@0 | 64 | contractID: "@mozilla.org/tests/component-blob;1", |
michael@0 | 65 | |
michael@0 | 66 | // nsIClassInfo |
michael@0 | 67 | implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT, |
michael@0 | 68 | flags: 0, |
michael@0 | 69 | |
michael@0 | 70 | getInterfaces: function getInterfaces(aCount) { |
michael@0 | 71 | var interfaces = [Components.interfaces.nsIClassInfo]; |
michael@0 | 72 | aCount.value = interfaces.length; |
michael@0 | 73 | return interfaces; |
michael@0 | 74 | }, |
michael@0 | 75 | |
michael@0 | 76 | getHelperForLanguage: function getHelperForLanguage(aLanguage) { |
michael@0 | 77 | return null; |
michael@0 | 78 | }, |
michael@0 | 79 | |
michael@0 | 80 | // nsISupports |
michael@0 | 81 | QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIClassInfo]) |
michael@0 | 82 | }; |
michael@0 | 83 | |
michael@0 | 84 | var gComponentsArray = [BlobComponent]; |
michael@0 | 85 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory(gComponentsArray); |