Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: third_party/WebKit/Source/core/dom/ScriptLoader.cpp

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: WIP: ModuleLoaderClient && crafts to make it work even if notifyFinished adds another ModuleLoaderC… Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/ScriptLoader.cpp
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
index a02e2ca2086a275cb4d1cf3ef5647e11e0236ce3..cafd04a047a2320ae27dee55890cd29982081d78 100644
--- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
@@ -34,6 +34,7 @@
#include "core/dom/ScriptLoaderClient.h"
#include "core/dom/ScriptRunner.h"
#include "core/dom/ScriptableDocumentParser.h"
+#include "core/dom/ModuleMap.h"
#include "core/dom/Text.h"
#include "core/events/Event.h"
#include "core/fetch/AccessControlStatus.h"
@@ -260,6 +261,7 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition,
if (m_documentWriteIntervention ==
DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle)
defer = FetchRequest::IdleLoad;
+
if (!fetchScript(client->sourceAttributeValue(), defer))
return false;
}
@@ -335,10 +337,17 @@ bool ScriptLoader::fetchScript(const String& sourceUrl,
return false;
DCHECK(!m_resource);
+
if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) {
- FetchRequest request(
- ResourceRequest(elementDocument->completeURL(sourceUrl)),
- m_element->localName());
+ KURL url = elementDocument->completeURL(sourceUrl);
+
+ if (RuntimeEnabledFeatures::moduleScriptsEnabled() &&
+ client()->typeAttributeValue() == "module") {
+ elementDocument->ensureModuleMap()->fetch(url);
+ return true;
+ }
+
+ FetchRequest request(ResourceRequest(url), m_element->localName());
CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(
m_element->fastGetAttribute(HTMLNames::crossoriginAttr));

Powered by Google App Engine
This is Rietveld 408576698