chrome/test/unit/test_bug401153.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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
michael@0 6 var MANIFESTS = [
michael@0 7 do_get_file("data/test_bug401153.manifest")
michael@0 8 ];
michael@0 9
michael@0 10 registerManifests(MANIFESTS);
michael@0 11
michael@0 12 var XULAppInfo = {
michael@0 13 vendor: "Mozilla",
michael@0 14 name: "XPCShell",
michael@0 15 ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
michael@0 16 version: "5",
michael@0 17 appBuildID: "2007010101",
michael@0 18 platformVersion: "1.9",
michael@0 19 platformBuildID: "2007010101",
michael@0 20 inSafeMode: false,
michael@0 21 logConsoleErrors: true,
michael@0 22 OS: "XPCShell",
michael@0 23 XPCOMABI: "noarch-spidermonkey",
michael@0 24
michael@0 25 QueryInterface: function QueryInterface(iid) {
michael@0 26 if (iid.equals(Ci.nsIXULAppInfo)
michael@0 27 || iid.equals(Ci.nsIXULRuntime)
michael@0 28 || iid.equals(Ci.nsISupports))
michael@0 29 return this;
michael@0 30
michael@0 31 throw Components.results.NS_ERROR_NO_INTERFACE;
michael@0 32 }
michael@0 33 };
michael@0 34
michael@0 35 var XULAppInfoFactory = {
michael@0 36 createInstance: function (outer, iid) {
michael@0 37 if (outer != null)
michael@0 38 throw Components.results.NS_ERROR_NO_AGGREGATION;
michael@0 39 return XULAppInfo.QueryInterface(iid);
michael@0 40 }
michael@0 41 };
michael@0 42 var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
michael@0 43 registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo",
michael@0 44 XULAPPINFO_CONTRACTID, XULAppInfoFactory);
michael@0 45
michael@0 46 var gIOS = Cc["@mozilla.org/network/io-service;1"]
michael@0 47 .getService(Ci.nsIIOService);
michael@0 48 var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
michael@0 49 .getService(Ci.nsIChromeRegistry);
michael@0 50 chromeReg.checkForNewChrome();
michael@0 51
michael@0 52 var rph = gIOS.getProtocolHandler("resource")
michael@0 53 .QueryInterface(Ci.nsIResProtocolHandler);
michael@0 54
michael@0 55 function test_succeeded_mapping(namespace, target)
michael@0 56 {
michael@0 57 try {
michael@0 58 do_check_true(rph.hasSubstitution(namespace));
michael@0 59 var uri = gIOS.newURI("resource://" + namespace, null, null);
michael@0 60 dump("### checking for " + target + ", getting " + rph.resolveURI(uri) + "\n");
michael@0 61 do_check_eq(rph.resolveURI(uri), target);
michael@0 62 }
michael@0 63 catch (ex) {
michael@0 64 dump(ex + "\n");
michael@0 65 do_throw(namespace);
michael@0 66 }
michael@0 67 }
michael@0 68
michael@0 69 function test_failed_mapping(namespace)
michael@0 70 {
michael@0 71 do_check_false(rph.hasSubstitution(namespace));
michael@0 72 }
michael@0 73
michael@0 74 function run_test()
michael@0 75 {
michael@0 76 var data = gIOS.newFileURI(do_get_file("data")).spec;
michael@0 77 test_succeeded_mapping("test1", data + "test1/");
michael@0 78 test_succeeded_mapping("test3", "jar:" + data + "test3.jar!/resources/");
michael@0 79 test_failed_mapping("test4");
michael@0 80 test_succeeded_mapping("test5", data + "test5/");
michael@0 81 }

mercurial