Source/WebCore/ChangeLog

 12017-01-26 Yusuke Suzuki <utatane.tea@gmail.com>
 2
 3 Implement dynamic-import for WebCore
 4 https://bugs.webkit.org/show_bug.cgi?id=166926
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This patch introduces browser side dynamic-import implementation.
 9 The dynamic-import is new ES feature which is now stage 3.
 10 The JSC shell already implements it.
 11
 12 The dynamic-import allows us to kick module loading in a dynamic manner.
 13 For example, you can write,
 14
 15 await module = import(`${HOST}/hello.js`);
 16
 17 The dynamic `import` operator (this is not a function) returns a promise with
 18 module namespace object if the module loading succeeds. Otherwise, it returns
 19 a rejected promise.
 20
 21 And importantly, this feature allows us to kick module loading from classic script.
 22 Previously, module loading can be only used from <script type="module"> tag. And
 23 all the module loading is done statically.
 24
 25 * CMakeLists.txt:
 26 * bindings/js/CachedModuleScriptLoader.cpp:
 27 (WebCore::CachedModuleScriptLoader::load):
 28 * bindings/js/CachedScriptFetcher.cpp:
 29 (WebCore::CachedScriptFetcher::create):
 30 (WebCore::CachedScriptFetcher::requestModuleScript):
 31 requestModuleScript function is used only when loading a new module script.
 32 So, LoadableClassicScript should use requestScriptWithCache to load itself.
 33 We pass String() for cross origin mode for null cross origin attribute as
 34 specified.
 35
 36 (WebCore::CachedScriptFetcher::requestScriptWithCache):
 37 * bindings/js/CachedScriptFetcher.h:
 38 (WebCore::CachedScriptFetcher::CachedScriptFetcher):
 39 * bindings/js/JSDOMWindowBase.cpp:
 40 (WebCore::JSDOMWindowBase::moduleLoaderImportModule):
 41 * bindings/js/JSDOMWindowBase.h:
 42 * bindings/js/JSLazyEventListener.cpp:
 43 (WebCore::JSLazyEventListener::initializeJSFunction):
 44 * bindings/js/ScriptController.cpp:
 45 (WebCore::ScriptController::executeScript):
 46 * bindings/js/ScriptModuleLoader.cpp:
 47 (WebCore::resolveModuleSpecifier):
 48 Extract the part of resolving module specifier to a static function to use
 49 it in ScriptModuleLoader::resolve and ScriptModuleLoader::importModule.
 50
 51 (WebCore::ScriptModuleLoader::resolve):
 52 (WebCore::rejectPromise):
 53 (WebCore::ScriptModuleLoader::importModule):
 54 New hook moduleLoaderImportModule is implemented. This hook is called when
 55 `import` operator is used. This hook is responsible to
 56 1. resolve the module name to obtain module specifier. (like, resolve the
 57 relative URL to get absolute URL.)
 58 2. kick module loading with the resolved specifier.
 59 When resolving the module name, the referrer information is needed.
 60 For example, "./script.js" will be resolved to "http://example.com/script.js" if
 61 the referrer module specifier is "http://example.com/".
 62 If `import("./script.js")` is executed in the classic script
 63 src="http://example.com/test.js", it starts loading "http://example.com/script.js".
 64 So the information of the caller of `import` operator is necessary here.
 65 This appropriate referrer is propagated by SourceOrigin.
 66
 67 * bindings/js/ScriptModuleLoader.h:
 68 * dom/InlineClassicScript.h:
 69 * dom/LoadableClassicScript.cpp:
 70 (WebCore::LoadableClassicScript::load):
 71 * dom/LoadableClassicScript.h:
 72 * dom/LoadableModuleScript.h:
 73 * dom/LoadableScript.h:
 74 (WebCore::LoadableScript::LoadableScript):
 75 (WebCore::LoadableScript::isClassicScript): Deleted.
 76 (WebCore::LoadableScript::isModuleScript): Deleted.
 77 * dom/ScriptElement.h:
 78 * dom/ScriptElementCachedScriptFetcher.cpp: Copied from Source/WebCore/dom/InlineClassicScript.h.
 79 (WebCore::ScriptElementCachedScriptFetcher::requestModuleScript):
 80 This requestModuleScript will be used when the script tag (or modules imported from the script tag) uses `import` operator.
 81 In classic scripts, `crossorigin` mode always becomes "omit" while module scripts
 82 propagate the original `crossorigin` value.
 83
 84 * dom/ScriptElementCachedScriptFetcher.h: Copied from Source/WebCore/bindings/js/CachedScriptFetcher.h.
 85 (WebCore::ScriptElementCachedScriptFetcher::crossOriginMode):
 86 (WebCore::ScriptElementCachedScriptFetcher::ScriptElementCachedScriptFetcher):
 87
1882017-01-26 Antoine Quint <graouts@apple.com>
289
390 [Modern Media Controls] Hiding controls, changing their width and showing them again shows an incorrect layout

Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
14751475 dom/Range.cpp
14761476 dom/ScopedEventQueue.cpp
14771477 dom/ScriptElement.cpp
 1478 dom/ScriptElementCachedScriptFetcher.cpp
14781479 dom/ScriptExecutionContext.cpp
14791480 dom/ScriptRunner.cpp
14801481 dom/ScriptableDocumentParser.cpp

Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp

@@CachedModuleScriptLoader::~CachedModuleScriptLoader()
6161bool CachedModuleScriptLoader::load(Document& document, const URL& sourceURL)
6262{
6363 ASSERT(!m_cachedScript);
64  m_cachedScript = m_scriptFetcher->requestScriptWithCache(document, sourceURL);
 64 m_cachedScript = m_scriptFetcher->requestModuleScript(document, sourceURL);
6565 if (!m_cachedScript)
6666 return false;
6767

Source/WebCore/bindings/js/CachedScriptFetcher.cpp

3434
3535namespace WebCore {
3636
37 CachedResourceHandle<CachedScript> CachedScriptFetcher::requestScriptWithCache(Document& document, const URL& sourceURL) const
 37Ref<CachedScriptFetcher> CachedScriptFetcher::create(const String& charset)
 38{
 39 return adoptRef(*new CachedScriptFetcher(charset));
 40}
 41
 42CachedResourceHandle<CachedScript> CachedScriptFetcher::requestModuleScript(Document& document, const URL& sourceURL) const
 43{
 44 return requestScriptWithCache(document, sourceURL, String());
 45}
 46
 47CachedResourceHandle<CachedScript> CachedScriptFetcher::requestScriptWithCache(Document& document, const URL& sourceURL, const String& crossOriginMode) const
3848{
3949 auto* settings = document.settings();
4050 if (settings && !settings->isScriptEnabled())

@@CachedResourceHandle<CachedScript> CachedScriptFetcher::requestScriptWithCache(D
4656 options.contentSecurityPolicyImposition = hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
4757
4858 CachedResourceRequest request(ResourceRequest(sourceURL), options);
49  request.setAsPotentiallyCrossOrigin(m_crossOriginMode, document);
 59 request.setAsPotentiallyCrossOrigin(crossOriginMode, document);
5060 request.upgradeInsecureRequestIfNeeded(document);
5161
5262 request.setCharset(m_charset);
53  request.setInitiator(m_initiatorName);
 63 if (!m_initiatorName.isNull())
 64 request.setInitiator(m_initiatorName);
5465
5566 return document.cachedResourceLoader().requestScript(WTFMove(request));
5667}

Source/WebCore/bindings/js/CachedScriptFetcher.h

@@class URL;
3737
3838class CachedScriptFetcher : public JSC::ScriptFetcher {
3939public:
40  CachedResourceHandle<CachedScript> requestScriptWithCache(Document&, const URL& sourceURL) const;
 40 virtual CachedResourceHandle<CachedScript> requestModuleScript(Document&, const URL& sourceURL) const;
 41
 42 static Ref<CachedScriptFetcher> create(const String& charset);
4143
4244protected:
43  CachedScriptFetcher(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
 45 CachedScriptFetcher(const String& nonce, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
4446 : m_nonce(nonce)
45  , m_crossOriginMode(crossOriginMode)
4647 , m_charset(charset)
4748 , m_initiatorName(initiatorName)
4849 , m_isInUserAgentShadowTree(isInUserAgentShadowTree)
4950 {
5051 }
5152
 53 CachedScriptFetcher(const String& charset)
 54 : m_charset(charset)
 55 {
 56 }
 57
 58 CachedResourceHandle<CachedScript> requestScriptWithCache(Document&, const URL& sourceURL, const String& crossOriginMode) const;
 59
5260private:
5361 String m_nonce;
54  String m_crossOriginMode;
5562 String m_charset;
5663 AtomicString m_initiatorName;
5764 bool m_isInUserAgentShadowTree { false };

Source/WebCore/bindings/js/JSDOMWindowBase.cpp

@@const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = {
6464 &javaScriptRuntimeFlags,
6565 &queueTaskToEventLoop,
6666 &shouldInterruptScriptBeforeTimeout,
67  nullptr,
 67 &moduleLoaderImportModule,
6868 &moduleLoaderResolve,
6969 &moduleLoaderFetch,
7070 nullptr,

@@JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalOb
331331 return JSC::jsUndefined();
332332}
333333
 334JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderImportModule(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSString* moduleName, const JSC::SourceOrigin& sourceOrigin)
 335{
 336 JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
 337 if (RefPtr<Document> document = thisObject->wrapped().document())
 338 return document->moduleLoader()->importModule(globalObject, exec, moduleLoader, moduleName, sourceOrigin);
 339 JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
 340 return deferred->reject(exec, jsUndefined());
 341}
 342
334343} // namespace WebCore

Source/WebCore/bindings/js/JSDOMWindowBase.h

@@namespace WebCore {
7979 static JSC::JSInternalPromise* moduleLoaderResolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
8080 static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue);
8181 static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
 82 static JSC::JSInternalPromise* moduleLoaderImportModule(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSString*, const JSC::SourceOrigin&);
8283
8384 RefPtr<DOMWindow> m_wrapped;
8485 JSDOMWindowShell* m_shell;

Source/WebCore/bindings/js/JSLazyEventListener.cpp

2020#include "config.h"
2121#include "JSLazyEventListener.h"
2222
 23#include "CachedScriptFetcher.h"
2324#include "ContentSecurityPolicy.h"
2425#include "Frame.h"
2526#include "JSNode.h"

@@JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext* exec
112113
113114 JSObject* jsFunction = constructFunctionSkippingEvalEnabledCheck(
114115 exec, exec->lexicalGlobalObject(), args, Identifier::fromString(exec, m_functionName),
115  SourceOrigin { m_sourceURL }, m_sourceURL, m_sourcePosition, overrideLineNumber);
 116 SourceOrigin { m_sourceURL, CachedScriptFetcher::create(document.charset()) }, m_sourceURL, m_sourcePosition, overrideLineNumber);
116117
117118 if (UNLIKELY(scope.exception())) {
118119 reportCurrentException(exec);

Source/WebCore/bindings/js/ScriptController.cpp

@@bool ScriptController::canExecuteScripts(ReasonForCallingCanExecuteScripts reaso
675675JSValue ScriptController::executeScript(const String& script, bool forceUserGesture, ExceptionDetails* exceptionDetails)
676676{
677677 UserGestureIndicator gestureIndicator(forceUserGesture ? std::optional<ProcessingUserGestureState>(ProcessingUserGesture) : std::nullopt);
678  return executeScript(ScriptSourceCode(script, m_frame.document()->url()), exceptionDetails);
 678 return executeScript(ScriptSourceCode(script, m_frame.document()->url(), TextPosition(), JSC::SourceProviderSourceType::Program, CachedScriptFetcher::create(m_frame.document()->charset())), exceptionDetails);
679679}
680680
681681JSValue ScriptController::executeScript(const ScriptSourceCode& sourceCode, ExceptionDetails* exceptionDetails)

Source/WebCore/bindings/js/ScriptModuleLoader.cpp

2828
2929#include "CachedModuleScriptLoader.h"
3030#include "CachedScript.h"
 31#include "CachedScriptFetcher.h"
3132#include "Document.h"
3233#include "Frame.h"
3334#include "JSDOMBinding.h"

3536#include "MIMETypeRegistry.h"
3637#include "ScriptController.h"
3738#include "ScriptSourceCode.h"
 39#include <runtime/Completion.h>
3840#include <runtime/JSInternalPromise.h>
3941#include <runtime/JSInternalPromiseDeferred.h>
4042#include <runtime/JSModuleRecord.h>

@@static bool isRootModule(JSC::JSValue importerModuleKey)
6163 return importerModuleKey.isSymbol() || importerModuleKey.isUndefined();
6264}
6365
 66static Expected<URL, ASCIILiteral> resolveModuleSpecifier(Document& document, const String& specifier, const URL& baseURL)
 67{
 68 // https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier
 69
 70 // 1. Apply the URL parser to specifier. If the result is not failure, return the result.
 71 URL absoluteURL(URL(), specifier);
 72 if (absoluteURL.isValid())
 73 return absoluteURL;
 74
 75 // 2. If specifier does not start with the character U+002F SOLIDUS (/), the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./),
 76 // or the three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F SOLIDUS (../), return failure and abort these steps.
 77 if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../"))
 78 return makeUnexpected(ASCIILiteral("Module specifier does not start with \"/\", \"./\", or \"../\"."));
 79
 80 // 3. Return the result of applying the URL parser to specifier with script's base URL as the base URL.
 81 auto result = document.completeURL(specifier, baseURL);
 82 if (!result.isValid())
 83 return makeUnexpected(ASCIILiteral("Module name does not resolve to a valid URL."));
 84 return result;
 85}
 86
6487JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleNameValue, JSC::JSValue importerModuleKey, JSC::JSValue)
6588{
6689 auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);

@@JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGloba
7598 return jsPromise.promise();
7699 }
77100
78  // https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier
79 
80101 if (!moduleNameValue.isString()) {
81  promise->reject(TypeError, ASCIILiteral("Module specifier is not Symbol or String."));
 102 promise->reject(TypeError, ASCIILiteral("Importer module key is not a Symbol or a String."));
82103 return jsPromise.promise();
83104 }
84105
85106 String specifier = asString(moduleNameValue)->value(exec);
86 
87  // 1. Apply the URL parser to specifier. If the result is not failure, return the result.
88  URL absoluteURL(URL(), specifier);
89  if (absoluteURL.isValid()) {
90  promise->resolve<IDLDOMString>(absoluteURL.string());
91  return jsPromise.promise();
92  }
93 
94  // 2. If specifier does not start with the character U+002F SOLIDUS (/), the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./),
95  // or the three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F SOLIDUS (../), return failure and abort these steps.
96  if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../")) {
97  promise->reject(TypeError, ASCIILiteral("Module specifier does not start with \"/\", \"./\", or \"../\"."));
98  return jsPromise.promise();
99  }
100 
101  // 3. Return the result of applying the URL parser to specifier with script's base URL as the base URL.
102 
103  URL completedURL;
104 
 107 URL baseURL;
105108 if (isRootModule(importerModuleKey))
106  completedURL = m_document.completeURL(specifier);
107  else if (importerModuleKey.isString()) {
 109 baseURL = m_document.baseURL();
 110 else {
 111 ASSERT(importerModuleKey.isString());
108112 URL importerModuleRequestURL(URL(), asString(importerModuleKey)->value(exec));
109  if (!importerModuleRequestURL.isValid()) {
110  promise->reject(TypeError, ASCIILiteral("Importer module key is an invalid URL."));
111  return jsPromise.promise();
112  }
113 
114  URL importerModuleResponseURL = m_requestURLToResponseURLMap.get(importerModuleRequestURL);
115  if (!importerModuleResponseURL.isValid()) {
116  promise->reject(TypeError, ASCIILiteral("Importer module has an invalid response URL."));
117  return jsPromise.promise();
118  }
 113 ASSERT_WITH_MESSAGE(!importerModuleRequestURL.isValid(), "Invalid module referrer never starts importing dependent modules.");
119114
120  completedURL = m_document.completeURL(specifier, importerModuleResponseURL);
121  } else {
122  promise->reject(TypeError, ASCIILiteral("Importer module key is not Symbol or String."));
123  return jsPromise.promise();
 115 auto iterator = m_requestURLToResponseURLMap.find(importerModuleRequestURL);
 116 ASSERT_WITH_MESSAGE(iterator != m_requestURLToResponseURLMap.end(), "Module referrer must register itself to the map before starting importing dependent modules.");
 117 baseURL = iterator->value;
124118 }
125119
126  if (!completedURL.isValid()) {
127  promise->reject(TypeError, ASCIILiteral("Module name constructs an invalid URL."));
 120 auto result = resolveModuleSpecifier(m_document, specifier, baseURL);
 121 if (!result) {
 122 promise->reject(TypeError, result.error());
128123 return jsPromise.promise();
129124 }
130125
131  promise->resolve<IDLDOMString>(completedURL.string());
 126 promise->resolve<IDLDOMString>(result->string());
132127 return jsPromise.promise();
133128}
134129

@@JSC::JSValue ScriptModuleLoader::evaluate(JSC::JSGlobalObject*, JSC::ExecState*
199194 return JSC::jsUndefined();
200195}
201196
 197static JSC::JSInternalPromise* rejectPromise(JSC::ExecState& state, JSDOMGlobalObject& globalObject, ExceptionCode ec, ASCIILiteral message)
 198{
 199 auto& jsPromise = *JSC::JSInternalPromiseDeferred::create(&state, &globalObject);
 200 auto deferred = DeferredPromise::create(globalObject, jsPromise);
 201 deferred->reject(ec, WTFMove(message));
 202 return jsPromise.promise();
 203}
 204
 205JSC::JSInternalPromise* ScriptModuleLoader::importModule(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSString* moduleName, const JSC::SourceOrigin& sourceOrigin)
 206{
 207 auto& state = *exec;
 208 JSC::VM& vm = exec->vm();
 209 auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);
 210
 211 // FIXME: setTimeout and setInterval with "string()" should propagate SourceOrigin.
 212 // https://webkit.org/b/167097
 213 ASSERT_WITH_MESSAGE(!sourceOrigin.isNull(), "If SourceOrigin is null, this function is not invoked.");
 214 if (!sourceOrigin.fetcher())
 215 return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Could not use import operator in this context."));
 216
 217 URL baseURL(URL(), sourceOrigin.string());
 218 if (!baseURL.isValid())
 219 return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not Symbol or String."));
 220
 221 auto specifier = moduleName->value(exec);
 222 auto result = resolveModuleSpecifier(m_document, specifier, baseURL);
 223 if (!result)
 224 return rejectPromise(state, globalObject, TypeError, result.error());
 225
 226 return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, sourceOrigin.fetcher() ));
 227}
 228
202229void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise)
203230{
204231 // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script

Source/WebCore/bindings/js/ScriptModuleLoader.h

@@class ExecState;
3838class JSGlobalObject;
3939class JSInternalPromise;
4040class JSModuleLoader;
 41class SourceOrigin;
4142
4243}
4344

@@class ScriptModuleLoader final : private CachedModuleScriptLoaderClient {
5758 JSC::JSInternalPromise* resolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher);
5859 JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue scriptFetcher);
5960 JSC::JSValue evaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue scriptFetcher);
 61 JSC::JSInternalPromise* importModule(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSString*, const JSC::SourceOrigin&);
6062
6163private:
6264 void notifyFinished(CachedModuleScriptLoader&, RefPtr<DeferredPromise>) final;

Source/WebCore/dom/InlineClassicScript.h

2525
2626#pragma once
2727
28 #include "CachedScriptFetcher.h"
 28#include "ScriptElementCachedScriptFetcher.h"
2929
3030namespace WebCore {
3131
3232class ScriptElement;
3333
34 class InlineClassicScript final : public CachedScriptFetcher {
 34class InlineClassicScript final : public ScriptElementCachedScriptFetcher {
3535public:
3636 static Ref<InlineClassicScript> create(ScriptElement&);
3737
 38 bool isClassicScript() const final { return true; }
 39 bool isModuleScript() const final { return false; }
 40
3841private:
3942 InlineClassicScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
40  : CachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
 43 : ScriptElementCachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
4144 {
4245 }
4346};

Source/WebCore/dom/LoadableClassicScript.cpp

@@void LoadableClassicScript::execute(ScriptElement& scriptElement)
110110bool LoadableClassicScript::load(Document& document, const URL& sourceURL)
111111{
112112 ASSERT(!m_cachedScript);
113  m_cachedScript = requestScriptWithCache(document, sourceURL);
 113 m_cachedScript = requestScriptWithCache(document, sourceURL, crossOriginMode());
114114 if (!m_cachedScript)
115115 return false;
116116 m_cachedScript->addClient(*this);

Source/WebCore/dom/LoadableClassicScript.h

@@class LoadableClassicScript final : public LoadableScript, private CachedResourc
4747 bool wasCanceled() const final;
4848
4949 CachedScript& cachedScript() { return *m_cachedScript; }
 50
5051 bool isClassicScript() const final { return true; }
 52 bool isModuleScript() const final { return false; }
5153
5254 void execute(ScriptElement&) final;
5355

Source/WebCore/dom/LoadableModuleScript.h

@@class LoadableModuleScript final : public LoadableScript, private CachedModuleSc
4343 bool wasCanceled() const final;
4444
4545 CachedModuleScript& moduleScript() { return m_moduleScript.get(); }
 46
 47 bool isClassicScript() const final { return false; }
4648 bool isModuleScript() const final { return true; }
4749
4850 void execute(ScriptElement&) final;

Source/WebCore/dom/LoadableScript.h

2525
2626#pragma once
2727
28 #include "CachedScriptFetcher.h"
 28#include "ScriptElementCachedScriptFetcher.h"
2929#include <runtime/ConsoleTypes.h>
3030#include <wtf/HashCountedSet.h>
3131#include <wtf/RefCounted.h>

@@namespace WebCore {
3636class LoadableScriptClient;
3737class ScriptElement;
3838
39 class LoadableScript : public CachedScriptFetcher {
 39class LoadableScript : public ScriptElementCachedScriptFetcher {
4040public:
4141 enum class ErrorType {
4242 CachedScript,

@@class LoadableScript : public CachedScriptFetcher {
6666 void addClient(LoadableScriptClient&);
6767 void removeClient(LoadableScriptClient&);
6868
69  virtual bool isClassicScript() const { return false; }
70  virtual bool isModuleScript() const { return false; }
71 
7269protected:
7370 LoadableScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
74  : CachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
 71 : ScriptElementCachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
7572 {
7673 }
7774

Source/WebCore/dom/ScriptElement.h

@@class ScriptElement {
9595 bool ignoresLoadRequest() const;
9696 bool isScriptForEventSupported() const;
9797
98  CachedResourceHandle<CachedScript> requestScriptWithCache(const URL&, const String& nonceAttribute, const String& crossoriginAttribute);
99 
10098 bool requestClassicScript(const String& sourceURL);
10199 bool requestModuleScript(const TextPosition& scriptStartPosition);
102100

Source/WebCore/dom/ScriptElementCachedScriptFetcher.cpp

 1/*
 2 * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "ScriptElementCachedScriptFetcher.h"
 28
 29#include "Element.h"
 30#include "ScriptElement.h"
 31
 32namespace WebCore {
 33
 34CachedResourceHandle<CachedScript> ScriptElementCachedScriptFetcher::requestModuleScript(Document& document, const URL& sourceURL) const
 35{
 36 // https://github.com/tc39/proposal-dynamic-import/blob/master/HTML Integration.md
 37 // If the fetcher is not module script, credential mode is always "omit".
 38
 39 String crossOriginMode = m_crossOriginMode;
 40 if (isClassicScript())
 41 crossOriginMode = ASCIILiteral("omit");
 42 return requestScriptWithCache(document, sourceURL, crossOriginMode);
 43}
 44
 45}

Source/WebCore/dom/ScriptElementCachedScriptFetcher.h

 1/*
 2 * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "CachedScriptFetcher.h"
 29
 30namespace WebCore {
 31
 32class ScriptElementCachedScriptFetcher : public CachedScriptFetcher {
 33public:
 34 virtual CachedResourceHandle<CachedScript> requestModuleScript(Document&, const URL& sourceURL) const;
 35
 36 virtual bool isClassicScript() const = 0;
 37 virtual bool isModuleScript() const = 0;
 38
 39 const String& crossOriginMode() const { return m_crossOriginMode; }
 40
 41protected:
 42 ScriptElementCachedScriptFetcher(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
 43 : CachedScriptFetcher(nonce, charset, initiatorName, isInUserAgentShadowTree)
 44 , m_crossOriginMode(crossOriginMode)
 45 {
 46 }
 47
 48private:
 49 String m_crossOriginMode;
 50};
 51
 52} // namespace WebCore

LayoutTests/ChangeLog

 12017-01-26 Yusuke Suzuki <utatane.tea@gmail.com>
 2
 3 Implement dynamic-import for WebCore
 4 https://bugs.webkit.org/show_bug.cgi?id=166926
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * http/tests/misc/import-absolute-url-expected.txt: Added.
 9 * http/tests/misc/import-absolute-url.html: Added.
 10 * http/tests/security/contentSecurityPolicy/1.1/import-scriptnonce-expected.txt: Added.
 11 * http/tests/security/contentSecurityPolicy/1.1/import-scriptnonce.html: Added.
 12 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed1.js: Added.
 13 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed2.js: Added.
 14 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed3.js: Added.
 15 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed4.js: Added.
 16 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed5.js: Added.
 17 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed6.js: Added.
 18 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked1.js: Added.
 19 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked2.js: Added.
 20 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked3.js: Added.
 21 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked4.js: Added.
 22 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked5.js: Added.
 23 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked6.js: Added.
 24 * http/tests/security/import-module-crossorigin-loads-error-expected.txt: Added.
 25 * http/tests/security/import-module-crossorigin-loads-error-src-expected.txt: Added.
 26 * http/tests/security/import-module-crossorigin-loads-error-src.html: Added.
 27 * http/tests/security/import-module-crossorigin-loads-error.html: Added.
 28 * http/tests/security/import-module-crossorigin-loads-expected.txt: Added.
 29 * http/tests/security/import-module-crossorigin-loads-src-expected.txt: Added.
 30 * http/tests/security/import-module-crossorigin-loads-src.html: Added.
 31 * http/tests/security/import-module-crossorigin-loads.html: Added.
 32 * http/tests/security/import-script-crossorigin-loads-error-expected.txt: Added.
 33 * http/tests/security/import-script-crossorigin-loads-error.html: Added.
 34 * http/tests/security/import-script-crossorigin-loads-omit-expected.txt: Added.
 35 * http/tests/security/import-script-crossorigin-loads-omit.html: Added.
 36 * http/tests/security/resources/cors-deny.php: Added.
 37 * http/tests/security/resources/import-module-crossorigin-loads-error-src.js: Added.
 38 (import.string_appeared_here.then):
 39 * http/tests/security/resources/import-module-crossorigin-loads-src.js: Added.
 40 (import.string_appeared_here.then):
 41 * js/dom/modules/import-execution-order-expected.txt: Added.
 42 * js/dom/modules/import-execution-order.html: Copied from LayoutTests/js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html.
 43 * js/dom/modules/import-from-handler-expected.txt: Added.
 44 * js/dom/modules/import-from-handler.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
 45 * js/dom/modules/import-from-javascript-url-expected.txt: Added.
 46 * js/dom/modules/import-from-javascript-url.html: Copied from LayoutTests/js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html.
 47 * js/dom/modules/import-from-loaded-classic-expected.txt: Added.
 48 * js/dom/modules/import-from-loaded-classic.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
 49 * js/dom/modules/import-from-loaded-module-expected.txt: Added.
 50 * js/dom/modules/import-from-loaded-module.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
 51 * js/dom/modules/import-from-module-expected.txt: Added.
 52 * js/dom/modules/import-from-module.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
 53 * js/dom/modules/import-incorrect-relative-specifier-expected.txt: Added.
 54 * js/dom/modules/import-incorrect-relative-specifier.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
 55 * js/dom/modules/import-simple-expected.txt: Added.
 56 * js/dom/modules/import-simple.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
 57 * js/dom/modules/module-document-write-src.html:
 58 * js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html:
 59 * js/dom/modules/module-execution-order-mixed-with-classic-scripts.html:
 60 * js/dom/modules/module-execution-order-mixed.html:
 61 * js/dom/modules/module-inline-dynamic.html:
 62 * js/dom/modules/module-inline-simple.html:
 63 * js/dom/modules/module-load-event-with-src.html:
 64 * js/dom/modules/module-load-same-module-from-different-entry-point-dynamic.html:
 65 * js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html:
 66 * js/dom/modules/module-load-same-module-from-different-entry-point.html:
 67 * js/dom/modules/module-not-found-error-event-with-src-and-import.html:
 68 * js/dom/modules/module-src-current-script.html:
 69 * js/dom/modules/module-src-dynamic.html:
 70 * js/dom/modules/module-src-simple.html:
 71 * js/dom/modules/module-type-case-insensitive.html:
 72 * js/dom/modules/module-will-fire-beforeload.html:
 73 * js/dom/modules/nomodule-dynamic-classic-src.html:
 74 * js/dom/modules/nomodule-has-no-effect-on-module-inline.html:
 75 * js/dom/modules/nomodule-has-no-effect-on-module-src.html:
 76 * js/dom/modules/nomodule-prevents-execution-classic-script-src.html:
 77 * js/dom/modules/nomodule-reflect.html:
 78 * js/dom/modules/resources/error-classic-script.js: Renamed from LayoutTests/js/dom/modules/script-tests/error-classic-script.js.
 79 * js/dom/modules/resources/import-from-loaded-classic-finish.js: Added.
 80 * js/dom/modules/resources/import-from-loaded-classic.js: Added.
 81 * js/dom/modules/resources/import-from-loaded-module-finish.js: Added.
 82 * js/dom/modules/resources/import-from-loaded-module.js: Added.
 83 * js/dom/modules/resources/module-document-write-src.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-document-write-src.js.
 84 * js/dom/modules/resources/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror-throw.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror-throw.js.
 85 * js/dom/modules/resources/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js.
 86 * js/dom/modules/resources/module-execution-order-mixed-2.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-2.js.
 87 * js/dom/modules/resources/module-execution-order-mixed-cappuccino.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-cappuccino.js.
 88 * js/dom/modules/resources/module-execution-order-mixed-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-cocoa.js.
 89 * js/dom/modules/resources/module-execution-order-mixed-matcha.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-matcha.js.
 90 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-2.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-2.js.
 91 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-cappuccino.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-cappuccino.js.
 92 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-cocoa.js.
 93 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-matcha.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-matcha.js.
 94 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts.js.
 95 * js/dom/modules/resources/module-execution-order-mixed.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed.js.
 96 * js/dom/modules/resources/module-inline-dynamic.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-inline-dynamic.js.
 97 * js/dom/modules/resources/module-inline-simple.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-inline-simple.js.
 98 * js/dom/modules/resources/module-load-event-with-src.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-load-event-with-src.js.
 99 * js/dom/modules/resources/module-load-same-module-from-different-entry-point.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-load-same-module-from-different-entry-point.js.
 100 * js/dom/modules/resources/module-not-found-error-event-with-src-and-import.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-not-found-error-event-with-src-and-import.js.
 101 * js/dom/modules/resources/module-src-current-script.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-current-script.js.
 102 * js/dom/modules/resources/module-src-dynamic-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-dynamic-cocoa.js.
 103 * js/dom/modules/resources/module-src-dynamic.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-dynamic.js.
 104 * js/dom/modules/resources/module-src-simple-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-simple-cocoa.js.
 105 * js/dom/modules/resources/module-src-simple.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-simple.js.
 106 * js/dom/modules/resources/module-will-fire-beforeload.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-will-fire-beforeload.js.
 107
11082017-01-26 Antoine Quint <graouts@apple.com>
2109
3110 [Modern Media Controls] Hiding controls, changing their width and showing them again shows an incorrect layout

LayoutTests/http/tests/misc/import-absolute-url-expected.txt

 1Test modules with absolute URLs.
 2http://127.0.0.1:8000/misc/resources/module-absolute-url2.js
 3http://127.0.0.1:8000/misc/resources/module-absolute-url.js
 4PASS successfullyParsed is true
 5
 6TEST COMPLETE
 7

LayoutTests/http/tests/misc/import-absolute-url.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<meta charset="UTF-8">
 5<script src="../../js-test-resources/js-test-pre.js"></script>
 6</head>
 7<body>
 8Test modules with absolute URLs.<hr>
 9<div id="console"></div>
 10<script>
 11var jsTestIsAsync = true;
 12</script>
 13<script>
 14import("http://127.0.0.1:8000/misc/resources/module-absolute-url.js").then(finishJSTest);
 15</script>
 16<script src="../../js-test-resources/js-test-post.js"></script>
 17</body>
 18</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/import-scriptnonce-expected.txt

 1CONSOLE MESSAGE: line 37: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.
 2CONSOLE MESSAGE: line 43: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.
 3CONSOLE MESSAGE: line 49: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.
 4CONSOLE MESSAGE: line 55: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.
 5CONSOLE MESSAGE: line 61: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.
 6CONSOLE MESSAGE: line 67: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.
 7ALERT: 1,2,3,4,5,6
 8This tests the effect of a script-nonce value.
 9
 10PASS

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/import-scriptnonce.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-Security-Policy" content="script-src 'nonce-noncynonce' 'nonce-noncy+/=nonce'">
 5 <script nonce="noncynonce">
 6 if (window.testRunner) {
 7 testRunner.dumpAsText();
 8 testRunner.waitUntilDone();
 9 }
 10
 11 var array = [];
 12 var count = 0;
 13 function ok(num)
 14 {
 15 array.push(num);
 16 if (array.length === 6) {
 17 alert(array.sort().toString());
 18 done("PASS");
 19 }
 20 }
 21
 22 function error(num)
 23 {
 24 alert(`FAIL (#{num})`);
 25 }
 26
 27 function done(msg) {
 28 document.querySelector("pre").innerHTML = msg;
 29 if (window.testRunner)
 30 testRunner.notifyDone();
 31 }
 32 </script>
 33
 34 <script type="module" nonce="noncynonce">
 35 import("./resources/import-scriptnonce-allowed1.js");
 36 </script>
 37 <script type="module" nonce="noncynonce noncynonce">
 38 import("./resources/import-scriptnonce-blocked1.js");
 39 </script>
 40 <script type="module" nonce="noncynonce">
 41 import("./resources/import-scriptnonce-allowed2.js");
 42 </script>
 43 <script type="module">
 44 import("./resources/import-scriptnonce-blocked2.js");
 45 </script>
 46 <script type="module" nonce="noncy+/=nonce">
 47 import("./resources/import-scriptnonce-allowed3.js");
 48 </script>
 49 <script type="module" nonce="noncynonceno?">
 50 import("./resources/import-scriptnonce-blocked3.js");
 51 </script>
 52 <script nonce="noncynonce">
 53 import("./resources/import-scriptnonce-allowed4.js");
 54 </script>
 55 <script nonce="noncynonce noncynonce">
 56 import("./resources/import-scriptnonce-blocked4.js");
 57 </script>
 58 <script nonce="noncynonce">
 59 import("./resources/import-scriptnonce-allowed5.js");
 60 </script>
 61 <script>
 62 import("./resources/import-scriptnonce-blocked5.js");
 63 </script>
 64 <script nonce="noncy+/=nonce">
 65 import("./resources/import-scriptnonce-allowed6.js");
 66 </script>
 67 <script nonce="noncynonceno?">
 68 import("./resources/import-scriptnonce-blocked6.js");
 69 </script>
 70 </head>
 71 <body>
 72 <p>
 73 This tests the effect of a script-nonce value.
 74 </p>
 75 <pre></pre>
 76 </body>
 77</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed1.js

 1ok(1);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed2.js

 1ok(2);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed3.js

 1ok(3);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed4.js

 1ok(4);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed5.js

 1ok(5);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed6.js

 1ok(6);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked1.js

 1error(1);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked2.js

 1error(2);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked3.js

 1error(3);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked4.js

 1error(4);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked5.js

 1error(5);

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked6.js

 1error(6);

LayoutTests/http/tests/security/import-module-crossorigin-loads-error-expected.txt

 1CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
 2This test passes if the module script does not load.
 3
 4PASS

LayoutTests/http/tests/security/import-module-crossorigin-loads-error-src-expected.txt

 1CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
 2This test passes if the module script does not load.
 3
 4PASS

LayoutTests/http/tests/security/import-module-crossorigin-loads-error-src.html

 1<body>
 2<p>This test passes if the module script does not load.</p>
 3<pre></pre>
 4<script>
 5if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.waitUntilDone();
 8}
 9
 10function done(msg) {
 11 document.querySelector("pre").innerHTML = msg;
 12 if (window.testRunner)
 13 testRunner.notifyDone();
 14}
 15</script>
 16<script type="module" src="./resources/import-module-crossorigin-loads-error-src.js"></script>

LayoutTests/http/tests/security/import-module-crossorigin-loads-error.html

 1<body>
 2<p>This test passes if the module script does not load.</p>
 3<pre></pre>
 4<script>
 5if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.waitUntilDone();
 8}
 9
 10function done(msg) {
 11 document.querySelector("pre").innerHTML = msg;
 12 if (window.testRunner)
 13 testRunner.notifyDone();
 14}
 15</script>
 16<script type="module">
 17import("http://localhost:8000/security/resources/cors-deny.php?credentials=true").then(
 18 function() { done("FAIL");},
 19 function() { done("PASS"); });
 20</script>

LayoutTests/http/tests/security/import-module-crossorigin-loads-expected.txt

 1ALERT: script ran.
 2This test passes if the module script loads.
 3
 4PASS

LayoutTests/http/tests/security/import-module-crossorigin-loads-src-expected.txt

 1ALERT: script ran.
 2This test passes if the module script loads.
 3
 4PASS

LayoutTests/http/tests/security/import-module-crossorigin-loads-src.html

 1<body>
 2<p>This test passes if the module script loads.</p>
 3<pre></pre>
 4<script>
 5if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.waitUntilDone();
 8}
 9
 10function done(msg) {
 11 document.querySelector("pre").innerHTML = msg;
 12 if (window.testRunner)
 13 testRunner.notifyDone();
 14}
 15</script>
 16<script type="module" src="./resources/import-module-crossorigin-loads-src.js"></script>

LayoutTests/http/tests/security/import-module-crossorigin-loads.html

 1<body>
 2<p>This test passes if the module script loads.</p>
 3<pre></pre>
 4<script>
 5if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.waitUntilDone();
 8}
 9
 10function done(msg) {
 11 document.querySelector("pre").innerHTML = msg;
 12 if (window.testRunner)
 13 testRunner.notifyDone();
 14}
 15</script>
 16<script type="module">
 17// Executed with "omit".
 18// https://github.com/tc39/proposal-dynamic-import/blob/master/HTML%20Integration.md
 19import("http://localhost:8000/security/resources/cors-script.php?credentials=false").then(
 20 function() { done("PASS");},
 21 function() { done("FAIL"); });
 22</script>

LayoutTests/http/tests/security/import-script-crossorigin-loads-error-expected.txt

 1CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
 2This test passes if the module script does not load.
 3
 4PASS

LayoutTests/http/tests/security/import-script-crossorigin-loads-error.html

 1<body>
 2<p>This test passes if the module script does not load.</p>
 3<pre></pre>
 4<script crossorigin="use-credentials">
 5if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.waitUntilDone();
 8}
 9
 10function done(msg) {
 11 document.querySelector("pre").innerHTML = msg;
 12 if (window.testRunner)
 13 testRunner.notifyDone();
 14}
 15
 16// Executed with "omit".
 17// https://github.com/tc39/proposal-dynamic-import/blob/master/HTML%20Integration.md
 18import("http://localhost:8000/security/resources/cors-deny.php?credentials=true").then(
 19 function() { done("FAIL");},
 20 function() { done("PASS"); });
 21</script>

LayoutTests/http/tests/security/import-script-crossorigin-loads-omit-expected.txt

 1ALERT: script ran.
 2This test passes if the module script loads.
 3
 4PASS

LayoutTests/http/tests/security/import-script-crossorigin-loads-omit.html

 1<body>
 2<p>This test passes if the module script loads.</p>
 3<pre></pre>
 4<script crossorigin="use-credentials">
 5if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.waitUntilDone();
 8}
 9
 10function done(msg) {
 11 document.querySelector("pre").innerHTML = msg;
 12 if (window.testRunner)
 13 testRunner.notifyDone();
 14}
 15
 16// Executed with "omit".
 17// https://github.com/tc39/proposal-dynamic-import/blob/master/HTML%20Integration.md
 18import("http://localhost:8000/security/resources/cors-script.php?credentials=false").then(
 19 function() { done("PASS");},
 20 function() { done("FAIL"); });
 21</script>

LayoutTests/http/tests/security/resources/cors-deny.php

 1<?php
 2header("Access-Control-Allow-Origin: http://example.org/");
 3header("Content-Type: application/javascript");
 4
 5if (isset($_GET["credentials"])) {
 6 if (strtolower($_GET["credentials"]) == "true")
 7 header("Access-Control-Allow-Credentials: true");
 8 else
 9 header("Access-Control-Allow-Credentials: false");
 10}
 11
 12if (strtolower($_GET["fail"]) == "true")
 13 echo "throw({toString: function(){ return 'SomeError' }});";
 14else
 15 echo "alert('script ran.');";
 16?>

LayoutTests/http/tests/security/resources/import-module-crossorigin-loads-error-src.js

 1import("http://localhost:8000/security/resources/cors-deny.php?credentials=true").then(
 2 function() { done("FAIL");},
 3 function() { done("PASS"); });

LayoutTests/http/tests/security/resources/import-module-crossorigin-loads-src.js

 1// Executed with "omit".
 2// https://github.com/tc39/proposal-dynamic-import/blob/master/HTML%20Integration.md
 3import("http://localhost:8000/security/resources/cors-script.php?credentials=false").then(
 4 function() { done("PASS");},
 5 function() { done("FAIL"); });
 6

LayoutTests/js/dom/modules/import-execution-order-expected.txt

 1Test import execution order.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6Module is not executed yet.
 7PASS count++ is 0
 8PASS count++ is 1
 9PASS count++ is 2
 10PASS count++ is 3
 11PASS count++ is 4
 12PASS count++ is 5
 13PASS count++ is 6
 14PASS successfullyParsed is true
 15
 16TEST COMPLETE
 17

LayoutTests/js/dom/modules/import-execution-order.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<script src="../../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<script>
 8description('Test import execution order.');
 9window.count = 0;
 10
 11// Module will be executed asynchronously.
 12window.jsTestIsAsync = true;
 13debug('Module is not executed yet.');
 14</script>
 15<script src="../../../resources/js-test-post.js"></script>
 16<script>
 17(async function () {
 18 await import(`./resources/module-execution-order-mixed.js`);
 19 shouldBe("count++", "4");
 20 await import(`./resources/module-execution-order-mixed-2.js`);
 21 shouldBe("count++", "6");
 22 finishJSTest();
 23}());
 24</script>
 25</body>
 26</html>

LayoutTests/js/dom/modules/import-from-handler-expected.txt

 1Test import from handler.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6Module is not executed yet.
 7Module execution is confined in the module environment.
 8PASS typeof cocoa is "undefined"
 9PASS typeof exportedCocoa is "object"
 10PASS exportedCocoa.taste() is "nice"
 11PASS successfullyParsed is true
 12
 13TEST COMPLETE
 14MODULE

LayoutTests/js/dom/modules/import-from-handler.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<script src="../../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<script>
 8description('Test import from handler.');
 9
 10// Module will be executed asynchronously.
 11window.jsTestIsAsync = true;
 12</script>
 13<script>
 14</script>
 15<script src="../../../resources/js-test-post.js"></script>
 16<a id="target" onclick="(import(`./resources/module-src-simple.js`)).then(() => finishJSTest())">MODULE</a>
 17<script type="module">
 18debug('Module is not executed yet.');
 19let anchor = document.getElementById('target');
 20anchor.dispatchEvent(new MouseEvent('click'));
 21</script>
 22</body>
 23</html>

LayoutTests/js/dom/modules/import-from-javascript-url-expected.txt

 1Test import from javascript URL.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6Module is not executed yet.
 7Module execution is confined in the module environment.
 8PASS typeof cocoa is "undefined"
 9PASS typeof exportedCocoa is "object"
 10PASS exportedCocoa.taste() is "nice"
 11PASS successfullyParsed is true
 12
 13TEST COMPLETE
 14MODULE

LayoutTests/js/dom/modules/import-from-javascript-url.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<script src="../../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<script>
 8description('Test import from javascript URL.');
 9
 10// Module will be executed asynchronously.
 11window.jsTestIsAsync = true;
 12</script>
 13<script>
 14</script>
 15<script src="../../../resources/js-test-post.js"></script>
 16<a id="target" href="javascript:void((import(`./resources/module-src-simple.js`)).then(() => finishJSTest()))">MODULE</a>
 17<script type="module">
 18debug('Module is not executed yet.');
 19let anchor = document.getElementById('target');
 20anchor.dispatchEvent(new MouseEvent('click'));
 21</script>
 22</body>
 23</html>

LayoutTests/js/dom/modules/import-from-loaded-classic-expected.txt

 1Test import from loaded classic.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6import from loaded classic
 7import from loaded classic finish
 8PASS successfullyParsed is true
 9
 10TEST COMPLETE
 11

LayoutTests/js/dom/modules/import-from-loaded-classic.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<script src="../../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<script>
 8description('Test import from loaded classic.');
 9
 10// Module will be executed asynchronously.
 11window.jsTestIsAsync = true;
 12</script>
 13<script>
 14</script>
 15<script src="../../../resources/js-test-post.js"></script>
 16<script src="./resources/import-from-loaded-classic.js"></script>
 17</body>
 18</html>

LayoutTests/js/dom/modules/import-from-loaded-module-expected.txt

 1Test import from loaded module.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6import from loaded module
 7import from loaded module finish
 8PASS successfullyParsed is true
 9
 10TEST COMPLETE
 11

LayoutTests/js/dom/modules/import-from-loaded-module.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<script src="../../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<script>
 8description('Test import from loaded module.');
 9
 10// Module will be executed asynchronously.
 11window.jsTestIsAsync = true;
 12</script>
 13<script>
 14</script>
 15<script src="../../../resources/js-test-post.js"></script>
 16<script type="module" src="./resources/import-from-loaded-module.js"></script>
 17</body>
 18</html>

LayoutTests/js/dom/modules/import-from-module-expected.txt

 1Test import from module script.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6Module is not executed yet.
 7Module execution is confined in the module environment.
 8PASS typeof cocoa is "undefined"
 9PASS typeof exportedCocoa is "object"
 10PASS exportedCocoa.taste() is "nice"
 11PASS successfullyParsed is true
 12
 13TEST COMPLETE
 14

LayoutTests/js/dom/modules/import-from-module.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<script src="../../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<script>
 8description('Test import from module script.');
 9
 10// Module will be executed asynchronously.
 11window.jsTestIsAsync = true;
 12</script>
 13<script>
 14</script>
 15<script src="../../../resources/js-test-post.js"></script>
 16<script type="module">
 17(async function() {
 18 debug('Module is not executed yet.');
 19 await import(`./resources/module-src-simple.js`);
 20 finishJSTest();
 21}());
 22</script>
 23</body>
 24</html>

LayoutTests/js/dom/modules/import-incorrect-relative-specifier-expected.txt

 1Test import rejects the incorrect relative specifiers.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS import("incorrect") rejected promise with TypeError: Module specifier does not start with "/", "./", or "../"..
 7PASS import("$hello") rejected promise with TypeError: Module specifier does not start with "/", "./", or "../"..
 8PASS import(".../test") rejected promise with TypeError: Module specifier does not start with "/", "./", or "../"..
 9PASS successfullyParsed is true
 10
 11TEST COMPLETE
 12

LayoutTests/js/dom/modules/import-incorrect-relative-specifier.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<script src="../../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<script>
 8description('Test import rejects the incorrect relative specifiers.');
 9// Module will be executed asynchronously.
 10window.jsTestIsAsync = true;
 11</script>
 12<script src="../../../resources/js-test-post.js"></script>
 13<script>
 14(async function () {
 15 await shouldReject(`import("incorrect")`);
 16 await shouldReject(`import("$hello")`);
 17 await shouldReject(`import(".../test")`);
 18 finishJSTest();
 19}());
 20</script>
 21</body>
 22</html>

LayoutTests/js/dom/modules/import-simple-expected.txt

 1Test import simple.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6Module is not executed yet.
 7Module execution is confined in the module environment.
 8PASS typeof cocoa is "undefined"
 9PASS typeof exportedCocoa is "object"
 10PASS exportedCocoa.taste() is "nice"
 11PASS successfullyParsed is true
 12
 13TEST COMPLETE
 14

LayoutTests/js/dom/modules/import-simple.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<script src="../../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<script>
 8description('Test import simple.');
 9
 10// Module will be executed asynchronously.
 11window.jsTestIsAsync = true;
 12</script>
 13<script>
 14</script>
 15<script src="../../../resources/js-test-post.js"></script>
 16<script>
 17(async function() {
 18 debug('Module is not executed yet.');
 19 await import(`./resources/module-src-simple.js`);
 20 finishJSTest();
 21}());
 22</script>
 23</body>
 24</html>

LayoutTests/js/dom/modules/module-document-write-src.html

1414debug('Module is not executed yet.');
1515</script>
1616<script src="../../../resources/js-test-post.js"></script>
17 <script type="module" src="script-tests/module-document-write-src.js"></script>
 17<script type="module" src="resources/module-document-write-src.js"></script>
1818</body>
1919</html>

LayoutTests/js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html

1515</script>
1616<script src="../../../resources/js-test-post.js"></script>
1717<script type="module">
18 import "./script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js"
 18import "./resources/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js"
1919testFailed("executed");
2020</script>
2121</body>

LayoutTests/js/dom/modules/module-execution-order-mixed-with-classic-scripts.html

2020<script>
2121shouldBe("count++", "1");
2222</script>
23 <script type="module" src="script-tests/module-execution-order-mixed-with-classic-scripts.js"></script>
 23<script type="module" src="resources/module-execution-order-mixed-with-classic-scripts.js"></script>
2424<script>
2525shouldBe("count++", "2");
2626</script>

3030<script>
3131shouldBe("count++", "3");
3232</script>
33 <script type="module" src="script-tests/module-execution-order-mixed-with-classic-scripts-2.js"></script>
 33<script type="module" src="resources/module-execution-order-mixed-with-classic-scripts-2.js"></script>
3434<script>
3535shouldBe("count++", "4");
3636</script>

LayoutTests/js/dom/modules/module-execution-order-mixed.html

1414debug('Module is not executed yet.');
1515</script>
1616<script src="../../../resources/js-test-post.js"></script>
17 <script type="module" src="script-tests/module-execution-order-mixed.js"></script>
 17<script type="module" src="resources/module-execution-order-mixed.js"></script>
1818<script type="module">
1919shouldBe("count++", "4");
2020</script>
21 <script type="module" src="script-tests/module-execution-order-mixed-2.js"></script>
 21<script type="module" src="resources/module-execution-order-mixed-2.js"></script>
2222<script type="module">
2323shouldBe("count++", "6");
2424finishJSTest();

LayoutTests/js/dom/modules/module-inline-dynamic.html

1616(function () {
1717 var element = document.createElement("script");
1818 element.textContent = `
19  import Cocoa from "./script-tests/module-inline-dynamic.js";
 19 import Cocoa from "./resources/module-inline-dynamic.js";
2020 var cocoa = new Cocoa();
2121
2222 debug("Module execution is confined in the module environment.");

LayoutTests/js/dom/modules/module-inline-simple.html

1515</script>
1616<script src="../../../resources/js-test-post.js"></script>
1717<script type="module">
18 import Cocoa from "./script-tests/module-inline-simple.js";
 18import Cocoa from "./resources/module-inline-simple.js";
1919var cocoa = new Cocoa();
2020
2121debug("Module execution is confined in the module environment.");

LayoutTests/js/dom/modules/module-load-event-with-src.html

1616}
1717</script>
1818<script src="../../../resources/js-test-post.js"></script>
19 <script type="module" onload="onLoad()" src="script-tests/module-load-event-with-src.js"></script>
 19<script type="module" onload="onLoad()" src="resources/module-load-event-with-src.js"></script>
2020</body>
2121</html>

LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-dynamic.html

2020</script>
2121<script src="../../../resources/js-test-post.js"></script>
2222<script type="module">
23 import "./script-tests/module-load-same-module-from-different-entry-point.js"
 23import "./resources/module-load-same-module-from-different-entry-point.js"
2424debug('Executing the module.');
2525shouldBe(`window.moduleExecutedCount`, `1`);
2626var element = document.createElement("script");
2727element.type = "module";
28 element.innerText = `import "./script-tests/module-load-same-module-from-different-entry-point.js"`;
 28element.innerText = `import "./resources/module-load-same-module-from-different-entry-point.js"`;
2929element.onload = onLoad;
3030document.body.appendChild(element);
3131</script>

LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html

2222
2323</script>
2424<script src="../../../resources/js-test-post.js"></script>
25 <script type="module" src="./script-tests/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script>
26 <script type="module" src="./script-tests/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script>
 25<script type="module" src="./resources/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script>
 26<script type="module" src="./resources/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script>
2727<script type="module">
2828finish();
2929</script>

LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point.html

2424</script>
2525<script src="../../../resources/js-test-post.js"></script>
2626<script type="module" onload="onLoad()">
27 import "./script-tests/module-load-same-module-from-different-entry-point.js"
 27import "./resources/module-load-same-module-from-different-entry-point.js"
2828debug('Executing the module.');
2929window.firstModuleIsExecuted = true;
3030</script>
3131<script type="module" onload="onLoad()">
32 import "./script-tests/module-load-same-module-from-different-entry-point.js"
 32import "./resources/module-load-same-module-from-different-entry-point.js"
3333debug('Executing the module.');
3434window.secondModuleIsExecuted = true;
3535</script>

LayoutTests/js/dom/modules/module-not-found-error-event-with-src-and-import.html

1616}
1717</script>
1818<script src="../../../resources/js-test-post.js"></script>
19 <script type="module" src="script-tests/module-not-found-error-event-with-src-and-import.js" onerror="onError()"></script>
 19<script type="module" src="resources/module-not-found-error-event-with-src-and-import.js" onerror="onError()"></script>
2020<script type="module">
2121shouldNotBe(`error`, `null`);
2222shouldBe(`error.type`, `"error"`);

LayoutTests/js/dom/modules/module-src-current-script.html

1414debug('Module is not executed yet.');
1515</script>
1616<script src="../../../resources/js-test-post.js"></script>
17 <script type="module" src="./script-tests/module-src-current-script.js"></script>
 17<script type="module" src="./resources/module-src-current-script.js"></script>
1818</body>
1919</html>

LayoutTests/js/dom/modules/module-src-dynamic.html

1616(function () {
1717 var element = document.createElement('script');
1818 element.type = 'module';
19  element.src = './script-tests/module-src-dynamic.js';
 19 element.src = './resources/module-src-dynamic.js';
2020 document.body.appendChild(element);
2121}());
2222</script>

LayoutTests/js/dom/modules/module-src-simple.html

1414debug('Module is not executed yet.');
1515</script>
1616<script src="../../../resources/js-test-post.js"></script>
17 <script type="module" src="./script-tests/module-src-simple.js"></script>
 17<script type="module" src="./resources/module-src-simple.js"></script>
1818</body>
1919</html>

LayoutTests/js/dom/modules/module-type-case-insensitive.html

2626<script src="../../../resources/js-test-post.js"></script>
2727
2828<script type="MoDuLe">
29 import Cocoa from "./script-tests/module-inline-simple.js";
 29import Cocoa from "./resources/module-inline-simple.js";
3030window.resolve1();
3131</script>
3232
3333<script type="MODULE">
34 import Cocoa from "./script-tests/module-inline-simple.js";
 34import Cocoa from "./resources/module-inline-simple.js";
3535window.resolve2();
3636</script>
3737

LayoutTests/js/dom/modules/module-will-fire-beforeload.html

1111debug('Module is not executed yet.');
1212</script>
1313<script src="../../../resources/js-test-post.js"></script>
14 <script type="module" onbeforeload="finishJSTest()" src="script-tests/module-will-fire-beforeload.js"></script>
 14<script type="module" onbeforeload="finishJSTest()" src="resources/module-will-fire-beforeload.js"></script>
1515</body>
1616</html>

LayoutTests/js/dom/modules/nomodule-dynamic-classic-src.html

1616(function () {
1717 var element = document.createElement('script');
1818 element.noModule = true;
19  element.src = './script-tests/error-classic-script.js';
 19 element.src = './resources/error-classic-script.js';
2020 document.body.appendChild(element);
2121 setTimeout(function () {
2222 shouldBeFalse(`executed`);

LayoutTests/js/dom/modules/nomodule-has-no-effect-on-module-inline.html

1515</script>
1616<script src="../../../resources/js-test-post.js"></script>
1717<script nomodule type="module">
18 import Cocoa from "./script-tests/module-inline-simple.js";
 18import Cocoa from "./resources/module-inline-simple.js";
1919var cocoa = new Cocoa();
2020
2121debug("Module execution is confined in the module environment.");

LayoutTests/js/dom/modules/nomodule-has-no-effect-on-module-src.html

1414debug('Module is not executed yet.');
1515</script>
1616<script src="../../../resources/js-test-post.js"></script>
17 <script nomodule type="module" src="./script-tests/module-src-simple.js"></script>
 17<script nomodule type="module" src="./resources/module-src-simple.js"></script>
1818</body>
1919</html>

LayoutTests/js/dom/modules/nomodule-prevents-execution-classic-script-src.html

88description('Test nomodule prevents execution of classic script.');
99window.executed = false;
1010</script>
11 <script nomodule src="./script-tests/module-src-simple.js"></script>
 11<script nomodule src="./resources/module-src-simple.js"></script>
1212<script>
1313shouldBeFalse(`executed`);
1414</script>

LayoutTests/js/dom/modules/nomodule-reflect.html

1313window.jsTestIsAsync = true;
1414</script>
1515<script src="../../../resources/js-test-post.js"></script>
16 <script id="target" src="./script-tests/error-classic-script.js" nomodule></script>
 16<script id="target" src="./resources/error-classic-script.js" nomodule></script>
1717<script id="target2">
1818window.executed2 = true;
1919</script>

LayoutTests/js/dom/modules/resources/error-classic-script.js

 1window.executed = true;
 2testFailed("error");
 3

LayoutTests/js/dom/modules/resources/import-from-loaded-classic-finish.js

 1debug("import from loaded classic finish");
 2finishJSTest();

LayoutTests/js/dom/modules/resources/import-from-loaded-classic.js

 1debug("import from loaded classic");
 2(import("./import-from-loaded-classic-finish.js"));

LayoutTests/js/dom/modules/resources/import-from-loaded-module-finish.js

 1debug("import from loaded module finish");
 2finishJSTest();

LayoutTests/js/dom/modules/resources/import-from-loaded-module.js

 1debug("import from loaded module");
 2(import("./import-from-loaded-module-finish.js"));

LayoutTests/js/dom/modules/resources/module-document-write-src.js

 1document.write("TEST FAILED");
 2finishJSTest();

LayoutTests/js/dom/modules/resources/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror-throw.js

 1debug("Executing the dependent module");
 2throw new Error("out");

LayoutTests/js/dom/modules/resources/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js

 1import "./module-execution-error-inside-dependent-module-should-be-propagated-to-onerror-throw.js"
 2testFailed("executed");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-2.js

 1shouldBe("count++", "5");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-cappuccino.js

 1import "./module-execution-order-mixed-matcha.js"
 2
 3shouldBe("count++", "2");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-cocoa.js

 1import "./module-execution-order-mixed-matcha.js";
 2
 3shouldBe("count++", "1");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-matcha.js

 1shouldBe("count++", "0");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-2.js

 1shouldBe("count++", "11");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-cappuccino.js

 1import "./module-execution-order-mixed-with-classic-scripts-matcha.js"
 2
 3shouldBe("count++", "8");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-cocoa.js

 1import "./module-execution-order-mixed-with-classic-scripts-matcha.js";
 2
 3shouldBe("count++", "7");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-matcha.js

 1shouldBe("count++", "6");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts.js

 1import "./module-execution-order-mixed-with-classic-scripts-cocoa.js"
 2import "./module-execution-order-mixed-with-classic-scripts-cappuccino.js"
 3
 4shouldBe("count++", "9");

LayoutTests/js/dom/modules/resources/module-execution-order-mixed.js

 1import "./module-execution-order-mixed-cocoa.js"
 2import "./module-execution-order-mixed-cappuccino.js"
 3
 4shouldBe("count++", "3");

LayoutTests/js/dom/modules/resources/module-inline-dynamic.js

 1export default class Cocoa {
 2 taste() {
 3 return "awesome";
 4 }
 5};

LayoutTests/js/dom/modules/resources/module-inline-simple.js

 1export default class Cocoa {
 2 taste() {
 3 return "awesome";
 4 }
 5};

LayoutTests/js/dom/modules/resources/module-load-event-with-src.js

 1debug('Executing a module with src attribute.');
 2window.moduleExecuted = true;

LayoutTests/js/dom/modules/resources/module-load-same-module-from-different-entry-point.js

 1debug('Executing module-load-same-module-from-different-entry-point.js.');
 2window.moduleExecutedCount++;

LayoutTests/js/dom/modules/resources/module-not-found-error-event-with-src-and-import.js

 1import "./not-found.js"

LayoutTests/js/dom/modules/resources/module-src-current-script.js

 1debug("Module execution is confined in the module environment.");
 2shouldBe("document.currentScript", "null");
 3finishJSTest();

LayoutTests/js/dom/modules/resources/module-src-dynamic-cocoa.js

 1class Cocoa {
 2 taste() {
 3 return "nice";
 4 }
 5}
 6
 7export default Cocoa;

LayoutTests/js/dom/modules/resources/module-src-dynamic.js

 1import Cocoa from "./module-src-dynamic-cocoa.js";
 2var cocoa = new Cocoa();
 3
 4debug("Module execution is confined in the module environment.");
 5shouldBeEqualToString("typeof cocoa", "undefined");
 6
 7window.exportedCocoa = cocoa;
 8shouldBeEqualToString("typeof exportedCocoa", "object");
 9shouldBeEqualToString("exportedCocoa.taste()", "nice");
 10finishJSTest();

LayoutTests/js/dom/modules/resources/module-src-simple-cocoa.js

 1class Cocoa {
 2 taste() {
 3 return "nice";
 4 }
 5}
 6
 7export default Cocoa;

LayoutTests/js/dom/modules/resources/module-src-simple.js

 1import Cocoa from "./module-src-simple-cocoa.js";
 2var cocoa = new Cocoa();
 3
 4debug("Module execution is confined in the module environment.");
 5shouldBeEqualToString("typeof cocoa", "undefined");
 6
 7window.exportedCocoa = cocoa;
 8shouldBeEqualToString("typeof exportedCocoa", "object");
 9shouldBeEqualToString("exportedCocoa.taste()", "nice");
 10finishJSTest();

LayoutTests/js/dom/modules/resources/module-will-fire-beforeload.js

 1testFailed("executed");

LayoutTests/js/dom/modules/script-tests/error-classic-script.js

1 window.executed = true;
2 testFailed("error");
3 

LayoutTests/js/dom/modules/script-tests/module-document-write-src.js

1 document.write("TEST FAILED");
2 finishJSTest();

LayoutTests/js/dom/modules/script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror-throw.js

1 debug("Executing the dependent module");
2 throw new Error("out");

LayoutTests/js/dom/modules/script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js

1 import "./module-execution-error-inside-dependent-module-should-be-propagated-to-onerror-throw.js"
2 testFailed("executed");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-2.js

1 shouldBe("count++", "5");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-cappuccino.js

1 import "./module-execution-order-mixed-matcha.js"
2 
3 shouldBe("count++", "2");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-cocoa.js

1 import "./module-execution-order-mixed-matcha.js";
2 
3 shouldBe("count++", "1");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-matcha.js

1 shouldBe("count++", "0");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-2.js

1 shouldBe("count++", "11");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-cappuccino.js

1 import "./module-execution-order-mixed-with-classic-scripts-matcha.js"
2 
3 shouldBe("count++", "8");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-cocoa.js

1 import "./module-execution-order-mixed-with-classic-scripts-matcha.js";
2 
3 shouldBe("count++", "7");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-matcha.js

1 shouldBe("count++", "6");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts.js

1 import "./module-execution-order-mixed-with-classic-scripts-cocoa.js"
2 import "./module-execution-order-mixed-with-classic-scripts-cappuccino.js"
3 
4 shouldBe("count++", "9");

LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed.js

1 import "./module-execution-order-mixed-cocoa.js"
2 import "./module-execution-order-mixed-cappuccino.js"
3 
4 shouldBe("count++", "3");

LayoutTests/js/dom/modules/script-tests/module-inline-dynamic.js

1 export default class Cocoa {
2  taste() {
3  return "awesome";
4  }
5 };

LayoutTests/js/dom/modules/script-tests/module-inline-simple.js

1 export default class Cocoa {
2  taste() {
3  return "awesome";
4  }
5 };

LayoutTests/js/dom/modules/script-tests/module-load-event-with-src.js

1 debug('Executing a module with src attribute.');
2 window.moduleExecuted = true;

LayoutTests/js/dom/modules/script-tests/module-load-same-module-from-different-entry-point.js

1 debug('Executing module-load-same-module-from-different-entry-point.js.');
2 window.moduleExecutedCount++;

LayoutTests/js/dom/modules/script-tests/module-not-found-error-event-with-src-and-import.js

1 import "./not-found.js"

LayoutTests/js/dom/modules/script-tests/module-src-current-script.js

1 debug("Module execution is confined in the module environment.");
2 shouldBe("document.currentScript", "null");
3 finishJSTest();

LayoutTests/js/dom/modules/script-tests/module-src-dynamic-cocoa.js

1 class Cocoa {
2  taste() {
3  return "nice";
4  }
5 }
6 
7 export default Cocoa;

LayoutTests/js/dom/modules/script-tests/module-src-dynamic.js

1 import Cocoa from "./module-src-dynamic-cocoa.js";
2 var cocoa = new Cocoa();
3 
4 debug("Module execution is confined in the module environment.");
5 shouldBeEqualToString("typeof cocoa", "undefined");
6 
7 window.exportedCocoa = cocoa;
8 shouldBeEqualToString("typeof exportedCocoa", "object");
9 shouldBeEqualToString("exportedCocoa.taste()", "nice");
10 finishJSTest();

LayoutTests/js/dom/modules/script-tests/module-src-simple-cocoa.js

1 class Cocoa {
2  taste() {
3  return "nice";
4  }
5 }
6 
7 export default Cocoa;

LayoutTests/js/dom/modules/script-tests/module-src-simple.js

1 import Cocoa from "./module-src-simple-cocoa.js";
2 var cocoa = new Cocoa();
3 
4 debug("Module execution is confined in the module environment.");
5 shouldBeEqualToString("typeof cocoa", "undefined");
6 
7 window.exportedCocoa = cocoa;
8 shouldBeEqualToString("typeof exportedCocoa", "object");
9 shouldBeEqualToString("exportedCocoa.taste()", "nice");
10 finishJSTest();

LayoutTests/js/dom/modules/script-tests/module-will-fire-beforeload.js

1 testFailed("executed");