summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-09-08 08:22:28 +0000
committerMoonchild <moonchild@palemoon.org>2020-09-08 08:22:28 +0000
commit8e5d9da5ebb4c464d582bd4d2f811056474d22be (patch)
tree943ce40b8380af5bccbf2fa1f801b7c7a864ffaa /dom
parente4fb3f48aee341424fac593abe2e24a791a8da00 (diff)
downloaduxp-8e5d9da5ebb4c464d582bd4d2f811056474d22be.tar.gz
Issue #618 - Make ES6 modules work for resource: URIs
Diffstat (limited to 'dom')
-rw-r--r--dom/script/ScriptLoader.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp
index 851987ed19..71838580f1 100644
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -2446,6 +2446,18 @@ ScriptLoader::NumberOfProcessors()
return mNumberOfProcessors;
}
+static bool
+IsInternalURIScheme(nsIURI* uri)
+{
+ // Note: Extend this if other schemes need to be included.
+ bool isResource;
+ if (NS_SUCCEEDED(uri->SchemeIs("resource", &isResource)) && isResource) {
+ return true;
+ }
+
+ return false;
+}
+
nsresult
ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
nsIIncrementalStreamLoader* aLoader,
@@ -2533,7 +2545,17 @@ ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
return NS_ERROR_FAILURE;
}
- channel->GetURI(getter_AddRefs(request->mBaseURL));
+ nsCOMPtr<nsIURI> uri;
+ rv = channel->GetOriginalURI(getter_AddRefs(uri));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // Fixup internal scheme URIs like resource:, because the channel URI
+ // will point to file: which won't be allowed to load.
+ if (uri && IsInternalURIScheme(uri)) {
+ request->mBaseURL = uri;
+ } else {
+ channel->GetURI(getter_AddRefs(request->mBaseURL));
+ }
// Attempt to compile off main thread.
rv = AttemptAsyncScriptCompile(request);