From 4b7e224f5f772fc5ba576d00a4bc99fd345d4fb8 Mon Sep 17 00:00:00 2001 From: "reed%reedloden.com" Date: Sat, 1 Dec 2007 01:23:11 +0000 Subject: [PATCH] Back out WeirdAl's patch from bug 398579 to see if it caused the perf regression on Linux. git-svn-id: svn://10.0.0.236/trunk@240181 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/xpconnect/loader/mozJSComponentLoader.cpp | 14 ++++++++++---- mozilla/js/src/xpconnect/tests/unit/test_import.js | 14 -------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp index 0f5767ace79..24d1377ffc0 100644 --- a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp +++ b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp @@ -1396,7 +1396,6 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, JSObject * *_retval) { nsresult rv; - *_retval = nsnull; if (!mInitialized) { rv = ReallyInit(); @@ -1406,12 +1405,19 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, nsCOMPtr ioService = do_GetIOService(&rv); NS_ENSURE_SUCCESS(rv, rv); - // Get the URI. + nsCAutoString scheme; + rv = ioService->ExtractScheme(aLocation, scheme); + if (NS_FAILED(rv) || + !scheme.EqualsLiteral("resource")) { + *_retval = nsnull; + return NS_ERROR_INVALID_ARG; + } + + // Get the resource:// URI. nsCOMPtr resURI; rv = ioService->NewURI(aLocation, nsnull, nsnull, getter_AddRefs(resURI)); nsCOMPtr fileURL = do_QueryInterface(resURI, &rv); - // If we don't have a file URL, then the location passed in is invalid. - NS_ENSURE_SUCCESS(rv, NS_ERROR_INVALID_ARG); + NS_ENSURE_SUCCESS(rv, rv); // Get the file belonging to it. nsCOMPtr file; diff --git a/mozilla/js/src/xpconnect/tests/unit/test_import.js b/mozilla/js/src/xpconnect/tests/unit/test_import.js index 291c2327ff8..8a23d44f318 100644 --- a/mozilla/js/src/xpconnect/tests/unit/test_import.js +++ b/mozilla/js/src/xpconnect/tests/unit/test_import.js @@ -67,20 +67,6 @@ function run_test() { do_check_true(scope2.XPCOMUtils == scope.XPCOMUtils); - // try on a new object using a file URL - var res = Components.classes["@mozilla.org/network/protocol;1?name=resource"] - .getService(Components.interfaces.nsIResProtocolHandler); - var resURI = res.newURI("resource://gre/modules/XPCOMUtils.jsm", null, null); - dump("resURI: " + resURI + "\n"); - var filePath = res.resolveURI(resURI); - do_check_eq(filePath.indexOf("file://"), 0); - var scope3 = {}; - Components.utils.import(filePath, scope3); - do_check_eq(typeof(scope3.XPCOMUtils), "object"); - do_check_eq(typeof(scope3.XPCOMUtils.generateModule), "function"); - - do_check_true(scope3.XPCOMUtils == scope.XPCOMUtils); - // make sure we throw when the second arg is bogus var didThrow = false; try {