From 205d129c10264f095293dd40ffc1336e4127278f Mon Sep 17 00:00:00 2001 From: Shawn Wilsher Date: Mon, 8 Dec 2008 18:51:46 -0500 Subject: [PATCH] Backed out changeset b6f762fde736 (bug 466582) for unit test orange. --- chrome/src/nsChromeProtocolHandler.cpp | 61 ++++- chrome/src/nsChromeRegistry.cpp | 59 ----- chrome/test/unit/data/test_bug401153.manifest | 3 + .../test_data_protocol_registration.manifest | 5 - .../data/test_no_remote_registration.manifest | 30 --- chrome/test/unit/test_bug401153.js | 15 +- .../unit/test_data_protocol_registration.js | 98 -------- .../test/unit/test_no_remote_registration.js | 238 ------------------ docshell/base/nsDocShell.cpp | 6 - .../decoders/icon/nsIconProtocolHandler.cpp | 5 +- netwerk/base/public/nsIProtocolHandler.idl | 9 +- netwerk/protocol/data/src/nsDataHandler.cpp | 2 +- .../file/src/nsFileProtocolHandler.cpp | 2 +- .../protocol/res/src/nsResProtocolHandler.cpp | 2 +- .../places/src/nsAnnoProtocolHandler.cpp | 3 +- 15 files changed, 69 insertions(+), 469 deletions(-) delete mode 100644 chrome/test/unit/data/test_data_protocol_registration.manifest delete mode 100644 chrome/test/unit/data/test_no_remote_registration.manifest delete mode 100644 chrome/test/unit/test_data_protocol_registration.js delete mode 100644 chrome/test/unit/test_no_remote_registration.js diff --git a/chrome/src/nsChromeProtocolHandler.cpp b/chrome/src/nsChromeProtocolHandler.cpp index 771dbec1adaf..1bac678c9b86 100644 --- a/chrome/src/nsChromeProtocolHandler.cpp +++ b/chrome/src/nsChromeProtocolHandler.cpp @@ -418,7 +418,7 @@ nsChromeProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_re NS_IMETHODIMP nsChromeProtocolHandler::GetProtocolFlags(PRUint32 *result) { - *result = URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE; + *result = URI_STD | URI_IS_UI_RESOURCE; return NS_OK; } @@ -465,7 +465,7 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, NS_ENSURE_ARG_POINTER(aURI); NS_PRECONDITION(aResult, "Null out param"); - + #ifdef DEBUG // Check that the uri we got is already canonified nsresult debug_rv; @@ -554,6 +554,38 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, rv = ioServ->NewChannelFromURI(resolvedURI, getter_AddRefs(result)); if (NS_FAILED(rv)) return rv; + // XXX Will be removed someday when we handle remote chrome. + nsCOMPtr fileChan + (do_QueryInterface(result)); + if (fileChan) { +#ifdef DEBUG + nsCOMPtr file; + fileChan->GetFile(getter_AddRefs(file)); + + PRBool exists = PR_FALSE; + file->Exists(&exists); + if (!exists) { + nsCAutoString path; + file->GetNativePath(path); + printf("Chrome file doesn't exist: %s\n", path.get()); + } +#endif + } + else { + nsCOMPtr jarChan + (do_QueryInterface(result)); + if (!jarChan) { + nsRefPtr cachedChannel; + if (NS_FAILED(CallQueryInterface(result.get(), + static_cast( + getter_AddRefs(cachedChannel))))) { + NS_WARNING("Remote chrome not allowed! Only file:, resource:, jar:, and cached chrome channels are valid.\n"); + result = nsnull; + return NS_ERROR_FAILURE; + } + } + } + // Make sure that the channel remembers where it was // originally loaded from. rv = result->SetOriginalURI(aURI); @@ -595,15 +627,24 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, if (objectOutput) { nsCOMPtr file; - nsCOMPtr uri; - result->GetURI(getter_AddRefs(uri)); - uri = NS_GetInnermostURI(uri); + if (fileChan) { + fileChan->GetFile(getter_AddRefs(file)); + } else { + nsCOMPtr uri; + result->GetURI(getter_AddRefs(uri)); - // Here we have a URL of the form resource:/chrome/A.jar - // or file:/some/path/to/A.jar. - nsCOMPtr fileURL(do_QueryInterface(uri)); - if (fileURL) - fileURL->GetFile(getter_AddRefs(file)); + // Loop, jar URIs can nest (e.g. jar:jar:A.jar!B.jar!C.xml). + // Often, however, we have jar:resource:/chrome/A.jar!C.xml. + nsCOMPtr jarURI; + while ((jarURI = do_QueryInterface(uri)) != nsnull) + jarURI->GetJARFile(getter_AddRefs(uri)); + + // Here we have a URL of the form resource:/chrome/A.jar + // or file:/some/path/to/A.jar. + nsCOMPtr fileURL(do_QueryInterface(uri)); + if (fileURL) + fileURL->GetFile(getter_AddRefs(file)); + } if (file) { rv = fastLoadServ->AddDependency(file); diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index c5950a0265fc..64eb6e5e3806 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -252,16 +252,6 @@ LanguagesMatch(const nsACString& a, const nsACString& b) return PR_FALSE; } -static PRBool -CanLoadResource(nsIURI* aResourceURI) -{ - PRBool isLocalResource = PR_FALSE; - (void)NS_URIChainHasFlags(aResourceURI, - nsIProtocolHandler::URI_IS_LOCAL_RESOURCE, - &isLocalResource); - return isLocalResource; -} - nsChromeRegistry::ProviderEntry* nsChromeRegistry::nsProviderArray::GetProvider(const nsACString& aPreferred, MatchType aType) { @@ -2344,13 +2334,6 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length, if (NS_FAILED(rv)) continue; - if (!CanLoadResource(resolved)) { - LogMessageWithContext(resolved, line, nsIScriptError::warningFlag, - "Warning: cannot register non-local URI '%s' as content.", - uri); - continue; - } - PackageEntry* entry = static_cast(PL_DHashTableOperate(&mPackagesHash, & (const nsACString&) nsDependentCString(package), @@ -2426,13 +2409,6 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length, if (NS_FAILED(rv)) continue; - if (!CanLoadResource(resolved)) { - LogMessageWithContext(resolved, line, nsIScriptError::warningFlag, - "Warning: cannot register non-local URI '%s' as a locale.", - uri); - continue; - } - PackageEntry* entry = static_cast(PL_DHashTableOperate(&mPackagesHash, & (const nsACString&) nsDependentCString(package), @@ -2488,13 +2464,6 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length, if (NS_FAILED(rv)) continue; - if (!CanLoadResource(resolved)) { - LogMessageWithContext(resolved, line, nsIScriptError::warningFlag, - "Warning: cannot register non-local URI '%s' as a skin.", - uri); - continue; - } - PackageEntry* entry = static_cast(PL_DHashTableOperate(&mPackagesHash, & (const nsACString&) nsDependentCString(package), @@ -2556,13 +2525,6 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length, continue; } - if (!CanLoadResource(overlayuri)) { - LogMessageWithContext(overlayuri, line, nsIScriptError::warningFlag, - "Warning: cannot register non-local URI '%s' as an overlay.", - overlay); - continue; - } - mOverlayHash.Add(baseuri, overlayuri); } else if (!strcmp(token, "style")) { @@ -2610,13 +2572,6 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length, if (NS_FAILED(rv)) continue; - if (!CanLoadResource(overlayuri)) { - LogMessageWithContext(overlayuri, line, nsIScriptError::warningFlag, - "Warning: cannot register non-local URI '%s' as a style overlay.", - overlay); - continue; - } - mStyleHash.Add(baseuri, overlayuri); } else if (!strcmp(token, "override")) { @@ -2670,13 +2625,6 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length, if (NS_FAILED(rv)) continue; - if (!CanLoadResource(resolveduri)) { - LogMessageWithContext(resolveduri, line, nsIScriptError::warningFlag, - "Warning: cannot register non-local URI '%s' as an override.", - resolved); - continue; - } - mOverrideTable.Put(chromeuri, resolveduri); } else if (!strcmp(token, "resource")) { @@ -2742,13 +2690,6 @@ nsChromeRegistry::ProcessManifestBuffer(char *buf, PRInt32 length, if (NS_FAILED(rv)) continue; - if (!CanLoadResource(resolved)) { - LogMessageWithContext(resolved, line, nsIScriptError::warningFlag, - "Warning: cannot register non-local URI '%s' as a resource.", - uri); - continue; - } - rv = rph->SetSubstitution(host, resolved); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/chrome/test/unit/data/test_bug401153.manifest b/chrome/test/unit/data/test_bug401153.manifest index 88bd803bc034..82b7832986ea 100644 --- a/chrome/test/unit/data/test_bug401153.manifest +++ b/chrome/test/unit/data/test_bug401153.manifest @@ -4,6 +4,9 @@ resource test1 test1/ # Duplicates should be ignored resource test1 foo/ +# Mapping off file system should work +resource test2 http://www.mozilla.org/ + # Mapping into jar files should work resource test3 jar:test3.jar!/resources/ diff --git a/chrome/test/unit/data/test_data_protocol_registration.manifest b/chrome/test/unit/data/test_data_protocol_registration.manifest deleted file mode 100644 index 4effa6ee6500..000000000000 --- a/chrome/test/unit/data/test_data_protocol_registration.manifest +++ /dev/null @@ -1,5 +0,0 @@ -# package used only for valid override -content good-package bar/ - -# Local resource (should work) -override chrome://good-package/content/test.xul data:application/vnd.mozilla.xul+xml, diff --git a/chrome/test/unit/data/test_no_remote_registration.manifest b/chrome/test/unit/data/test_no_remote_registration.manifest deleted file mode 100644 index bf43b3d3fc79..000000000000 --- a/chrome/test/unit/data/test_no_remote_registration.manifest +++ /dev/null @@ -1,30 +0,0 @@ -# package used only for valid overlaying and overrides -content good-package bar/ - -# UI Resource URIs (should work) -content moz-protocol-ui-resource moz-protocol-ui-resource://foo/ -locale moz-protocol-ui-resource en-us moz-protocol-ui-resource://foo/ -skin moz-protocol-ui-resource skin1 moz-protocol-ui-resource://foo/ -override chrome://good-package/content/override-moz-protocol-ui-resource.xul moz-protocol-ui-resource://foo/ -resource moz-protocol-ui-resource moz-protocol-ui-resource://foo/ - -# Local file URIs (should work) -content moz-protocol-local-file moz-protocol-local-file://foo/ -locale moz-protocol-local-file en-us moz-protocol-local-file://foo/ -skin moz-protocol-local-file skin1 moz-protocol-local-file://foo/ -override chrome://good-package/content/override-moz-protocol-local-file.xul moz-protocol-local-file://foo/ -resource moz-protocol-local-file moz-protocol-local-file://foo/ - -# Loadable by anyone URIs (should not work) -content moz-protocol-loadable-by-anyone moz-protocol-loadable-by-anyone://foo/ -locale moz-protocol-loadable-by-anyone en-us moz-protocol-loadable-by-anyone://foo/ -skin moz-protocol-loadable-by-anyone skin1 moz-protocol-loadable-by-anyone://foo/ -override chrome://good-package/content/override-moz-protocol-loadable-by-anyone.xul moz-protocol-loadable-by-anyone://foo/ -resource moz-protocol-loadable-by-anyone moz-protocol-loadable-by-anyone://foo/ - -# Local resource (should work) -content moz-protocol-local-resource moz-protocol-local-resource://foo/ -locale moz-protocol-local-resource en-us moz-protocol-local-resource://foo/ -skin moz-protocol-local-resource skin1 moz-protocol-local-resource://foo/ -override chrome://good-package/content/override-moz-protocol-local-resource.xul moz-protocol-local-resource://foo/ -resource moz-protocol-local-resource moz-protocol-local-resource://foo/ diff --git a/chrome/test/unit/test_bug401153.js b/chrome/test/unit/test_bug401153.js index 06845a1b5eed..13bed57130a1 100644 --- a/chrome/test/unit/test_bug401153.js +++ b/chrome/test/unit/test_bug401153.js @@ -89,12 +89,12 @@ function test_succeeded_mapping(namespace, target) { try { do_check_true(rph.hasSubstitution(namespace)); - var uri = gIOS.newURI("resource://" + namespace, null, null); - dump("### checking for " + target + ", getting " + rph.resolveURI(uri) + "\n"); - do_check_eq(rph.resolveURI(uri), target); + var thistarget = target + "/test.js"; + var uri = gIOS.newURI("resource://" + namespace + "/test.js", + null, null); + do_check_eq(rph.resolveURI(uri), thistarget); } catch (ex) { - dump(ex + "\n"); do_throw(namespace); } } @@ -107,8 +107,9 @@ function test_failed_mapping(namespace) function run_test() { var data = gIOS.newFileURI(do_get_file("chrome/test/unit/data")).spec; - test_succeeded_mapping("test1", data + "test1/"); - test_succeeded_mapping("test3", "jar:" + data + "test3.jar!/resources/"); + test_succeeded_mapping("test1", data + "test1"); + test_succeeded_mapping("test2", "http://www.mozilla.org"); + test_succeeded_mapping("test3", "jar:" + data + "test3.jar!/resources"); test_failed_mapping("test4"); - test_succeeded_mapping("test5", data + "test5/"); + test_succeeded_mapping("test5", data + "test5"); } diff --git a/chrome/test/unit/test_data_protocol_registration.js b/chrome/test/unit/test_data_protocol_registration.js deleted file mode 100644 index 2d68474ba9ac..000000000000 --- a/chrome/test/unit/test_data_protocol_registration.js +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=2 sts=2 tw=78 expandtab : - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Chrome Registration Test Code. - * - * The Initial Developer of the Original Code is - * Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shawn Wilsher (Original Author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -let manifests = [ - do_get_file("chrome/test/unit/data/test_data_protocol_registration.manifest"), -]; -registerManifests(manifests); - -let XULAppInfoFactory = { - // These two are used when we register all our factories (and unregister) - CID: XULAPPINFO_CID, - scheme: "XULAppInfo", - contractID: XULAPPINFO_CONTRACTID, - createInstance: function (outer, iid) { - if (outer != null) - throw Cr.NS_ERROR_NO_AGGREGATION; - return XULAppInfo.QueryInterface(iid); - } -}; - -function run_test() -{ - // Add our XULAppInfo factory - let factories = [XULAppInfoFactory]; - - // Register our factories - for (let i = 0; i < factories.length; i++) { - let factory = factories[i]; - Components.manager.QueryInterface(Ci.nsIComponentRegistrar) - .registerFactory(factory.CID, "test-" + factory.scheme, - factory.contractID, factory); - } - - // Check for new chrome - let cr = Cc["@mozilla.org/chrome/chrome-registry;1"]. - getService(Ci.nsIChromeRegistry); - cr.checkForNewChrome(); - - // Check that our override worked - let expectedURI = "data:application/vnd.mozilla.xul+xml,"; - let sourceURI = "chrome://good-package/content/test.xul"; - try { - let ios = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); - sourceURI = ios.newURI(sourceURI, null, null); - // this throws for packages that are not registered - let uri = cr.convertChromeURL(sourceURI).spec; - - do_check_eq(expectedURI, uri); - } - catch (e) { - dump(e + "\n"); - do_throw("Should have registered our URI!"); - } - - // Unregister our factories so we do not leak - for (let i = 0; i < factories.length; i++) { - let factory = factories[i]; - Components.manager.QueryInterface(Ci.nsIComponentRegistrar) - .unregisterFactory(factory.CID, factory); - } -} diff --git a/chrome/test/unit/test_no_remote_registration.js b/chrome/test/unit/test_no_remote_registration.js deleted file mode 100644 index dcc8df0be960..000000000000 --- a/chrome/test/unit/test_no_remote_registration.js +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=2 sts=2 tw=78 expandtab : - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Chrome Registration Test Code. - * - * The Initial Developer of the Original Code is - * Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Shawn Wilsher (Original Author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -let manifests = [ - do_get_file("chrome/test/unit/data/test_no_remote_registration.manifest"), -]; -registerManifests(manifests); - -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -let XULAppInfo = { - vendor: "Mozilla", - name: "XPCShell", - ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}", - version: "5", - appBuildID: "2007010101", - platformVersion: "1.9", - platformBuildID: "2007010101", - inSafeMode: false, - logConsoleErrors: true, - OS: "XPCShell", - XPCOMABI: "noarch-spidermonkey", - QueryInterface: XPCOMUtils.generateQI([ - Ci.nsIXULAppInfo, - Ci.nsIXULRuntime, - ]) -}; - -let XULAppInfoFactory = { - // These two are used when we register all our factories (and unregister) - CID: XULAPPINFO_CID, - scheme: "XULAppInfo", - contractID: XULAPPINFO_CONTRACTID, - createInstance: function (outer, iid) { - if (outer != null) - throw Cr.NS_ERROR_NO_AGGREGATION; - return XULAppInfo.QueryInterface(iid); - } -}; - -function ProtocolHandler(aScheme, aFlags) -{ - this.scheme = aScheme; - this.protocolFlags = aFlags; - this.contractID = "@mozilla.org/network/protocol;1?name=" + aScheme; -} - -ProtocolHandler.prototype = -{ - defaultPort: -1, - allowPort: function() false, - newURI: function(aSpec, aCharset, aBaseURI) - { - let uri = Cc["@mozilla.org/network/standard-url;1"]. - createInstance(Ci.nsIURI); - uri.spec = aSpec; - if (!uri.scheme) { - // We got a partial uri, so let's resolve it with the base one - uri.spec = aBaseURI.resolve(aSpec); - } - return uri; - }, - newChannel: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED }, - QueryInterface: XPCOMUtils.generateQI([ - Ci.nsIProtocolHandler - ]) -}; - -let testProtocols = [ - {scheme: "moz-protocol-ui-resource", - flags: Ci.nsIProtocolHandler.URI_IS_UI_RESOURCE, - CID: Components.ID("{d6dedc93-558f-44fe-90f4-3b4bba8a0b14}"), - shouldRegister: true - }, - {scheme: "moz-protocol-local-file", - flags: Ci.nsIProtocolHandler.URI_IS_LOCAL_FILE, - CID: Components.ID("{ee30d594-0a2d-4f47-89cc-d4cde320ab69}"), - shouldRegister: true - }, - {scheme: "moz-protocol-loadable-by-anyone", - flags: Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE, - CID: Components.ID("{c3735f23-3b0c-4a33-bfa0-79436dcd40b2}"), - shouldRegister: false - }, - {scheme: "moz-protocol-local-resource", - flags: Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE, - CID: Components.ID("{b79e977c-f840-469a-b413-0125cc1b62a5}"), - shouldRegister: true - }, -]; -function run_test() -{ - // Create factories - let factories = []; - for (let i = 0; i < testProtocols.length; i++) { - factories[i] = { - scheme: testProtocols[i].scheme, - flags: testProtocols[i].flags, - CID: testProtocols[i].CID, - contractID: "@mozilla.org/network/protocol;1?name=" + testProtocols[i].scheme, - createInstance: function(aOuter, aIID) - { - if (aOuter != null) - throw Cr.NS_ERROR_NO_AGGREGATION; - let handler = new ProtocolHandler(this.scheme, this.flags, this.CID); - return handler.QueryInterface(aIID); - } - }; - } - // Add our XULAppInfo factory - factories.push(XULAppInfoFactory); - - // Register our factories - for (let i = 0; i < factories.length; i++) { - let factory = factories[i]; - Components.manager.QueryInterface(Ci.nsIComponentRegistrar) - .registerFactory(factory.CID, "test-" + factory.scheme, - factory.contractID, factory); - } - - // Check for new chrome - let cr = Cc["@mozilla.org/chrome/chrome-registry;1"]. - getService(Ci.nsIChromeRegistry); - cr.checkForNewChrome(); - - // See if our various things were able to register - let registrationTypes = [ - "content", - "locale", - "skin", - "override", - "resource", - ]; - for (let i = 0; i < testProtocols.length; i++) { - let protocol = testProtocols[i]; - for (let j = 0; j < registrationTypes.length; j++) { - let type = registrationTypes[j]; - dump("Testing protocol '" + protocol.scheme + "' with type '" + type + - "'\n"); - let expectedURI = protocol.scheme + "://foo/"; - let sourceURI = "chrome://" + protocol.scheme + "/" + type + "/"; - switch (type) { - case "content": - expectedURI += protocol.scheme + ".xul"; - break; - case "locale": - expectedURI += protocol.scheme + ".dtd"; - break; - case "skin": - expectedURI += protocol.scheme + ".css"; - break; - case "override": - sourceURI = "chrome://good-package/content/override-" + - protocol.scheme + ".xul"; - break; - case "resource": - sourceURI = "resource://" + protocol.scheme + "/"; - break; - }; - try { - let ios = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); - sourceURI = ios.newURI(sourceURI, null, null); - let uri; - if (type == "resource") { - // resources go about a slightly different way than everything else - let rph = ios.getProtocolHandler("resource"). - QueryInterface(Ci.nsIResProtocolHandler); - // this throws for packages that are not registered - uri = rph.resolveURI(sourceURI); - } - else { - // this throws for packages that are not registered - uri = cr.convertChromeURL(sourceURI).spec; - } - - if (protocol.shouldRegister) { - do_check_eq(expectedURI, uri); - } - else { - // Overrides will not throw, so we'll get to here. We want to make - // sure that the two strings are not the same in this situation. - do_check_neq(expectedURI, uri); - } - } - catch (e) { - if (protocol.shouldRegister) { - dump(e + "\n"); - do_throw("Should have registered our URI for protocol " + - protocol.scheme); - } - } - } - } - - // Unregister our factories so we do not leak - for (let i = 0; i < factories.length; i++) { - let factory = factories[i]; - Components.manager.QueryInterface(Ci.nsIComponentRegistrar) - .unregisterFactory(factory.CID, factory); - } -} diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 56bf69f2ebd7..1f1e3624648f 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9705,12 +9705,6 @@ nsClassifierCallback::Run() NS_ENSURE_SUCCESS(rv, rv); if (hasFlags) return NS_OK; - rv = NS_URIChainHasFlags(uri, - nsIProtocolHandler::URI_IS_LOCAL_RESOURCE, - &hasFlags); - NS_ENSURE_SUCCESS(rv, rv); - if (hasFlags) return NS_OK; - nsCOMPtr uriClassifier = do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; diff --git a/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp b/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp index 6b50ca1c4c05..4136c6f78c6d 100644 --- a/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp +++ b/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp @@ -81,10 +81,9 @@ NS_IMETHODIMP nsIconProtocolHandler::AllowPort(PRInt32 port, const char *scheme, return NS_OK; } -NS_IMETHODIMP nsIconProtocolHandler::GetProtocolFlags(PRUint32 *result) +NS_IMETHODIMP nsIconProtocolHandler::GetProtocolFlags(PRUint32 *result) { - *result = URI_NORELATIVE | URI_NOAUTH | URI_IS_UI_RESOURCE | - URI_IS_LOCAL_RESOURCE; + *result = URI_NORELATIVE | URI_NOAUTH | URI_IS_UI_RESOURCE; return NS_OK; } diff --git a/netwerk/base/public/nsIProtocolHandler.idl b/netwerk/base/public/nsIProtocolHandler.idl index 49403c3e6e34..1daa90f759e9 100644 --- a/netwerk/base/public/nsIProtocolHandler.idl +++ b/netwerk/base/public/nsIProtocolHandler.idl @@ -221,14 +221,7 @@ interface nsIProtocolHandler : nsISupports * do not return any data that we can use. */ const unsigned long URI_DOES_NOT_RETURN_DATA = (1<<11); - - /** - * URIs for this protocol are considered to be local resources. This could - * be a local file (URI_IS_LOCAL_FILE), a UI resource (URI_IS_UI_RESOURCE), - * or something else that would not hit the network. - */ - const unsigned long URI_IS_LOCAL_RESOURCE = (1<<12); - + /** * This protocol handler can be proxied via a proxy (socks or http) * (e.g., irc, smtp, http, etc.). If the protocol supports transparent diff --git a/netwerk/protocol/data/src/nsDataHandler.cpp b/netwerk/protocol/data/src/nsDataHandler.cpp index 9853735ab654..15c7b68b6825 100644 --- a/netwerk/protocol/data/src/nsDataHandler.cpp +++ b/netwerk/protocol/data/src/nsDataHandler.cpp @@ -91,7 +91,7 @@ nsDataHandler::GetDefaultPort(PRInt32 *result) { NS_IMETHODIMP nsDataHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH | URI_INHERITS_SECURITY_CONTEXT | - URI_LOADABLE_BY_ANYONE | URI_NON_PERSISTABLE | URI_IS_LOCAL_RESOURCE; + URI_LOADABLE_BY_ANYONE | URI_NON_PERSISTABLE; return NS_OK; } diff --git a/netwerk/protocol/file/src/nsFileProtocolHandler.cpp b/netwerk/protocol/file/src/nsFileProtocolHandler.cpp index d7e0e00efa3d..f0a43a00b764 100644 --- a/netwerk/protocol/file/src/nsFileProtocolHandler.cpp +++ b/netwerk/protocol/file/src/nsFileProtocolHandler.cpp @@ -251,7 +251,7 @@ nsFileProtocolHandler::GetDefaultPort(PRInt32 *result) NS_IMETHODIMP nsFileProtocolHandler::GetProtocolFlags(PRUint32 *result) { - *result = URI_NOAUTH | URI_IS_LOCAL_FILE | URI_IS_LOCAL_RESOURCE; + *result = URI_NOAUTH | URI_IS_LOCAL_FILE; return NS_OK; } diff --git a/netwerk/protocol/res/src/nsResProtocolHandler.cpp b/netwerk/protocol/res/src/nsResProtocolHandler.cpp index daf984bcf164..12d1db234f80 100644 --- a/netwerk/protocol/res/src/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/src/nsResProtocolHandler.cpp @@ -215,7 +215,7 @@ nsResProtocolHandler::GetProtocolFlags(PRUint32 *result) { // XXXbz Is this really true for all resource: URIs? Could we // somehow give different flags to some of them? - *result = URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE; + *result = URI_STD | URI_IS_UI_RESOURCE; return NS_OK; } diff --git a/toolkit/components/places/src/nsAnnoProtocolHandler.cpp b/toolkit/components/places/src/nsAnnoProtocolHandler.cpp index b5e17df92450..dc6e743c8049 100644 --- a/toolkit/components/places/src/nsAnnoProtocolHandler.cpp +++ b/toolkit/components/places/src/nsAnnoProtocolHandler.cpp @@ -87,8 +87,7 @@ nsAnnoProtocolHandler::GetDefaultPort(PRInt32 *aDefaultPort) NS_IMETHODIMP nsAnnoProtocolHandler::GetProtocolFlags(PRUint32 *aProtocolFlags) { - *aProtocolFlags = (URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD | - URI_IS_LOCAL_RESOURCE); + *aProtocolFlags = (URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD); return NS_OK; }