diff options
author | Moonchild <moonchild@palemoon.org> | 2020-09-08 08:22:28 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-09-08 11:04:54 +0000 |
commit | 71b988d1b43333431c4a087671c35486ac7ad586 (patch) | |
tree | 59c48192512bb790d91c2fc64d326f1b40f25545 /dom | |
parent | ddc43bf9d7009a5d3b2ff84688450540b8eff84e (diff) | |
download | UXP-71b988d1b43333431c4a087671c35486ac7ad586.tar UXP-71b988d1b43333431c4a087671c35486ac7ad586.tar.gz UXP-71b988d1b43333431c4a087671c35486ac7ad586.tar.lz UXP-71b988d1b43333431c4a087671c35486ac7ad586.tar.xz UXP-71b988d1b43333431c4a087671c35486ac7ad586.zip |
Issue #618 - Make ES6 modules work for resource: URIs
Diffstat (limited to 'dom')
-rw-r--r-- | dom/script/ScriptLoader.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 851987ed1..71838580f 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); |