зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1778289 - Part 12: Update spec links as the PR is merged. r=jonco,yulia
The PR has been merged. See https://html.spec.whatwg.org/multipage/webappapis.html#import-maps Differential Revision: https://phabricator.services.mozilla.com/D158828
This commit is contained in:
Родитель
6994b82d44
Коммит
ee07ecaeec
|
@ -329,7 +329,7 @@ nsresult nsContentSink::ProcessLinkFromHeader(const net::LinkHeader& aHeader) {
|
|||
}
|
||||
|
||||
if (linkTypes & LinkStyle::eMODULE_PRELOAD) {
|
||||
// https://whatpr.org/html/8075/webappapis.html#fetch-a-modulepreload-module-script-graph
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-modulepreload-module-script-graph
|
||||
// Step 1. Disallow further import maps given settings object.
|
||||
mDocument->ScriptLoader()->GetModuleLoader()->DisallowImportMaps();
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ test_simpleImportMap.html, here we reverse the order, for example, we list
|
|||
"scope1/" after "scope1/scope2/" in this test.
|
||||
|
||||
See:
|
||||
https://whatpr.org/html/8075/webappapis.html#sorting-and-normalizing-a-module-specifier-map, Step 3.
|
||||
https://whatpr.org/html/8075/webappapis.html#sorting-and-normalizing-scopes, Step 3.
|
||||
https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-a-module-specifier-map, Step 3.
|
||||
https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-scopes, Step 3.
|
||||
-->
|
||||
|
||||
<script type="importmap">
|
||||
|
|
|
@ -499,7 +499,7 @@ void HTMLLinkElement::
|
|||
return;
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#fetch-a-modulepreload-module-script-graph
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-modulepreload-module-script-graph
|
||||
// Step 1. Disallow further import maps given settings object.
|
||||
OwnerDoc()->ScriptLoader()->GetModuleLoader()->DisallowImportMaps();
|
||||
return;
|
||||
|
|
|
@ -183,7 +183,7 @@ void HTMLScriptElement::FreezeExecutionAttrs(Document* aOwnerDoc) {
|
|||
mKind = ScriptKind::eModule;
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/scripting.html#prepare-the-script-element
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element
|
||||
// Step 11. Otherwise, if the script block's type string is an ASCII
|
||||
// case-insensitive match for the string "importmap", then set el's type to
|
||||
// "importmap".
|
||||
|
|
|
@ -110,7 +110,7 @@ nsresult ModuleLoader::StartFetch(ModuleLoadRequest* aRequest) {
|
|||
nsresult rv = GetScriptLoader()->StartLoadInternal(aRequest, securityFlags);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#fetch-an-import()-module-script-graph
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-an-import()-module-script-graph
|
||||
// Step 1. Disallow further import maps given settings object.
|
||||
if (!aRequest->GetScriptLoadContext()->IsPreload()) {
|
||||
LOG(("ScriptLoadRequest (%p): Disallow further import maps.", aRequest));
|
||||
|
|
|
@ -909,7 +909,7 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
|||
LOG(("ScriptLoader (%p): Process external script for element %p", this,
|
||||
aElement));
|
||||
|
||||
// https://whatpr.org/html/8075/scripting.html#prepare-the-script-element
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element
|
||||
// Step 30.1. If el's type is "importmap", then queue an element task on the
|
||||
// DOM manipulation task source given el to fire an event named error at el,
|
||||
// and return.
|
||||
|
@ -956,7 +956,7 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
|||
|
||||
LOG(("ScriptLoadRequest (%p): Using preload request", request.get()));
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#fetch-a-module-script-tree
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-module-script-tree
|
||||
// Step 1. Disallow further import maps given settings object.
|
||||
if (request->IsModuleRequest()) {
|
||||
LOG(("ScriptLoadRequest (%p): Disallow further import maps.",
|
||||
|
@ -1125,7 +1125,7 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement,
|
|||
// Check if adding an import map script is allowed. If not, we bail out
|
||||
// early to prevent creating a load request.
|
||||
if (aScriptKind == ScriptKind::eImportMap) {
|
||||
// https://whatpr.org/html/8075/scripting.html#prepare-the-script-element
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element
|
||||
// Step 31.2 type is "importmap":
|
||||
// Step 1. If el's relevant global object's import maps allowed is false,
|
||||
// then queue an element task on the DOM manipulation task source given el
|
||||
|
@ -1172,7 +1172,7 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement,
|
|||
request->mBaseURL = mDocument->GetDocBaseURI();
|
||||
|
||||
if (request->IsModuleRequest()) {
|
||||
// https://whatpr.org/html/8075/webappapis.html#fetch-an-inline-module-script-graph
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-an-inline-module-script-graph
|
||||
// Step 1. Disallow further import maps given settings object.
|
||||
mModuleLoader->DisallowImportMaps();
|
||||
|
||||
|
@ -1204,7 +1204,7 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement,
|
|||
}
|
||||
|
||||
if (request->IsImportMapRequest()) {
|
||||
// https://whatpr.org/html/8075/scripting.html#prepare-the-script-element
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element
|
||||
// Step 31.2 type is "importmap":
|
||||
// Impl note: Step 1 is done above before creating a ScriptLoadRequest.
|
||||
MOZ_ASSERT(mModuleLoader->IsImportMapAllowed());
|
||||
|
@ -1224,12 +1224,12 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement,
|
|||
|
||||
// TODO: Bug 1781758: Move RegisterImportMap into EvaluateScriptElement.
|
||||
//
|
||||
// https://whatpr.org/html/8075/scripting.html#execute-the-script-element
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-element
|
||||
// The spec defines 'register an import map' should be done in
|
||||
// 'execute the script element', because inside 'execute the script element'
|
||||
// it will perform a 'preparation-time document check'.
|
||||
// However, as import maps could be only inline scripts by now, the
|
||||
// 'preparation-time document check' will never fail for import maps
|
||||
// 'preparation-time document check' will never fail for import maps.
|
||||
// So we simply call 'register an import map' here.
|
||||
mModuleLoader->RegisterImportMap(std::move(importMap));
|
||||
return false;
|
||||
|
|
|
@ -41,7 +41,7 @@ void ReportWarningHelper::Report(const char* aMessageName,
|
|||
mLoader->ReportWarningToConsole(mRequest, aMessageName, aParams);
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#resolving-a-url-like-module-specifier
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#resolving-a-url-like-module-specifier
|
||||
static ResolveResult ResolveURLLikeModuleSpecifier(const nsAString& aSpecifier,
|
||||
nsIURI* aBaseURL) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -74,7 +74,7 @@ static ResolveResult ResolveURLLikeModuleSpecifier(const nsAString& aSpecifier,
|
|||
return WrapNotNull(uri);
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#normalizing-a-specifier-key
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#normalizing-a-specifier-key
|
||||
static void NormalizeSpecifierKey(const nsAString& aSpecifierKey,
|
||||
nsIURI* aBaseURL,
|
||||
const ReportWarningHelper& aWarning,
|
||||
|
@ -105,7 +105,7 @@ static void NormalizeSpecifierKey(const nsAString& aSpecifierKey,
|
|||
aRetVal = aSpecifierKey;
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#sorting-and-normalizing-a-module-specifier-map
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-a-module-specifier-map
|
||||
static UniquePtr<SpecifierMap> SortAndNormalizeSpecifierMap(
|
||||
JSContext* aCx, JS::HandleObject aOriginalMap, nsIURI* aBaseURL,
|
||||
const ReportWarningHelper& aWarning) {
|
||||
|
@ -230,7 +230,7 @@ static bool IsMapObject(JSContext* aCx, JS::HandleValue aMapVal, bool* aIsMap) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#sorting-and-normalizing-scopes
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-scopes
|
||||
static UniquePtr<ScopeMap> SortAndNormalizeScopes(
|
||||
JSContext* aCx, JS::HandleObject aOriginalMap, nsIURI* aBaseURL,
|
||||
const ReportWarningHelper& aWarning) {
|
||||
|
@ -309,7 +309,7 @@ static UniquePtr<ScopeMap> SortAndNormalizeScopes(
|
|||
return normalized;
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#parse-an-import-map-string
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#parse-an-import-map-string
|
||||
// static
|
||||
UniquePtr<ImportMap> ImportMap::ParseString(
|
||||
JSContext* aCx, SourceText<char16_t>& aInput, nsIURI* aBaseURL,
|
||||
|
@ -454,7 +454,7 @@ static bool IsSpecialScheme(nsIURI* aURI) {
|
|||
scheme.EqualsLiteral("ws") || scheme.EqualsLiteral("wss");
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#resolving-an-imports-match
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#resolving-an-imports-match
|
||||
static mozilla::Result<nsCOMPtr<nsIURI>, ResolveError> ResolveImportsMatch(
|
||||
nsString& aNormalizedSpecifier, nsIURI* aAsURL,
|
||||
const SpecifierMap* aSpecifierMap) {
|
||||
|
@ -574,7 +574,7 @@ static mozilla::Result<nsCOMPtr<nsIURI>, ResolveError> ResolveImportsMatch(
|
|||
return nsCOMPtr<nsIURI>(nullptr);
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#resolve-a-module-specifier
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier
|
||||
// static
|
||||
ResolveResult ImportMap::ResolveModuleSpecifier(ImportMap* aImportMap,
|
||||
ScriptLoaderInterface* aLoader,
|
||||
|
|
|
@ -46,18 +46,18 @@ class ReportWarningHelper {
|
|||
};
|
||||
|
||||
// Specifier map from import maps.
|
||||
// https://whatpr.org/html/8075/webappapis.html#module-specifier-map
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#module-specifier-map
|
||||
using SpecifierMap =
|
||||
std::map<nsString, nsCOMPtr<nsIURI>, std::greater<nsString>>;
|
||||
|
||||
// Scope map from import maps.
|
||||
// https://whatpr.org/html/8075/webappapis.html#concept-import-map-scopes
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-import-map-scopes
|
||||
using ScopeMap = std::map<nsCString, mozilla::UniquePtr<SpecifierMap>,
|
||||
std::greater<nsCString>>;
|
||||
|
||||
/**
|
||||
* Implementation of Import maps.
|
||||
* https://whatpr.org/html/8075/webappapis.html#import-maps
|
||||
* https://html.spec.whatwg.org/multipage/webappapis.html#import-maps
|
||||
*/
|
||||
class ImportMap {
|
||||
public:
|
||||
|
@ -70,7 +70,7 @@ class ImportMap {
|
|||
* This function will throw a TypeError if there's any invalid key or value in
|
||||
* the JSON text according to the spec.
|
||||
*
|
||||
* https://whatpr.org/html/8075/webappapis.html#parse-an-import-map-string
|
||||
* https://html.spec.whatwg.org/multipage/webappapis.html#parse-an-import-map-string
|
||||
*/
|
||||
static mozilla::UniquePtr<ImportMap> ParseString(
|
||||
JSContext* aCx, JS::SourceText<char16_t>& aInput, nsIURI* aBaseURL,
|
||||
|
@ -80,13 +80,14 @@ class ImportMap {
|
|||
* This implements "Resolve a module specifier" algorithm defined in the
|
||||
* Import maps spec.
|
||||
*
|
||||
* See https://whatpr.org/html/8075/webappapis.html#resolve-a-module-specifier
|
||||
* See
|
||||
* https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier
|
||||
*
|
||||
* Impl note: According to the spec, if the specifier cannot be resolved, this
|
||||
* method will throw a TypeError(Step 13). But the tricky part is when
|
||||
* creating a module script,
|
||||
* see
|
||||
* https://whatpr.org/html/8075/webappapis.html#validate-requested-module-specifiers
|
||||
* https://html.spec.whatwg.org/multipage/webappapis.html#validate-requested-module-specifiers
|
||||
* If the resolving failed, it shall catch the exception and set to the
|
||||
* script's parse error.
|
||||
* For implementation we return a ResolveResult here, and the callers will
|
||||
|
@ -102,9 +103,9 @@ class ImportMap {
|
|||
|
||||
private:
|
||||
/**
|
||||
* https://whatpr.org/html/8075/webappapis.html#import-map
|
||||
* https://html.spec.whatwg.org/multipage/webappapis.html#import-map-processing-model
|
||||
*
|
||||
* An import map is a struct with two items:
|
||||
* Formally, an import map is a struct with two items:
|
||||
* 1. imports, a module specifier map, and
|
||||
* 2. scopes, an ordered map of URLs to module specifier maps.
|
||||
*/
|
||||
|
|
|
@ -1273,17 +1273,17 @@ UniquePtr<ImportMap> ModuleLoaderBase::ParseImportMap(
|
|||
JS::SourceText<char16_t>& text = maybeSource.ref<SourceText<char16_t>>();
|
||||
ReportWarningHelper warning{mLoader, aRequest};
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#create-an-import-map-parse-result
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#create-an-import-map-parse-result
|
||||
// Step 2. Parse an import map string given input and baseURL, catching any
|
||||
// exceptions. If this threw an exception, then set result's error to rethrow
|
||||
// to that exception. Otherwise, set result's import map to the return value.
|
||||
//
|
||||
// https://whatpr.org/html/8075/webappapis.html#register-an-import-map
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#register-an-import-map
|
||||
// Step 1. If result's error to rethrow is not null, then report the exception
|
||||
// given by result's error to rethrow and return.
|
||||
//
|
||||
// Impl note: We didn't implement 'Import map parse result' from the spec,
|
||||
// https://whatpr.org/html/8075/webappapis.html#import-map-parse-result
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#import-map-parse-result
|
||||
// As the struct has another item called 'error to rethow' to store the
|
||||
// exception thrown during parsing import-maps, and report that exception
|
||||
// while registering an import map. Currently only inline import-maps are
|
||||
|
@ -1297,7 +1297,7 @@ void ModuleLoaderBase::RegisterImportMap(UniquePtr<ImportMap> aImportMap) {
|
|||
// Check for aImportMap is done in ScriptLoader.
|
||||
MOZ_ASSERT(aImportMap);
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#register-an-import-map
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#register-an-import-map
|
||||
// The step 1(report the exception if there's an error) is done in
|
||||
// ParseImportMap.
|
||||
//
|
||||
|
@ -1306,7 +1306,8 @@ void ModuleLoaderBase::RegisterImportMap(UniquePtr<ImportMap> aImportMap) {
|
|||
// from the implementation it defaults to nullptr, so we check if the global's
|
||||
// import map is null here.
|
||||
//
|
||||
// Also see https://whatpr.org/html/8075/webappapis.html#empty-import-map
|
||||
// Also see
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#empty-import-map
|
||||
MOZ_ASSERT(!mImportMap);
|
||||
|
||||
// Step 3. Set global's import map to result's import map.
|
||||
|
|
|
@ -181,7 +181,7 @@ class ModuleLoaderBase : public nsISupports {
|
|||
// for fetches to finish and for imports to become avilable.
|
||||
nsCOMPtr<nsISerialEventTarget> mEventTarget;
|
||||
|
||||
// https://whatpr.org/html/8075/webappapis.html#import-maps-allowed
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#import-maps-allowed
|
||||
//
|
||||
// Each Window has an import maps allowed boolean, initially true.
|
||||
bool mImportMapsAllowed = true;
|
||||
|
@ -285,12 +285,12 @@ class ModuleLoaderBase : public nsISupports {
|
|||
mozilla::UniquePtr<ImportMap> ParseImportMap(ScriptLoadRequest* aRequest);
|
||||
|
||||
// Implements
|
||||
// https://whatpr.org/html/8075/webappapis.html#register-an-import-map
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#register-an-import-map
|
||||
void RegisterImportMap(mozilla::UniquePtr<ImportMap> aImportMap);
|
||||
|
||||
// Getter for mImportMapsAllowed.
|
||||
bool IsImportMapAllowed() const { return mImportMapsAllowed; }
|
||||
// https://whatpr.org/html/8075/webappapis.html#disallow-further-import-maps
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#disallow-further-import-maps
|
||||
void DisallowImportMaps() { mImportMapsAllowed = false; }
|
||||
|
||||
// Returns true if the module for given URL is already fetched.
|
||||
|
|
Загрузка…
Ссылка в новой задаче