Changeset 211280 in webkit


Ignore:
Timestamp:
Jan 27, 2017 2:49:23 AM (7 years ago)
Author:
Yusuke Suzuki
Message:

Implement dynamic-import for WebCore
https://bugs.webkit.org/show_bug.cgi?id=166926

Reviewed by Ryosuke Niwa.

Source/WebCore:

This patch introduces browser side dynamic-import implementation.
The dynamic-import is new ES feature which is now stage 3.
The JSC shell already implements it.

The dynamic-import allows us to kick module loading in a dynamic manner.
For example, you can write,

await module = import(${HOST}/hello.js);

The dynamic import operator (this is not a function) returns a promise with
module namespace object if the module loading succeeds. Otherwise, it returns
a rejected promise.

And importantly, this feature allows us to kick module loading from classic script.
Previously, module loading can be only used from <script type="module"> tag. And
all the module loading is done statically.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/CachedModuleScriptLoader.cpp:

(WebCore::CachedModuleScriptLoader::load):

  • bindings/js/CachedScriptFetcher.cpp:

(WebCore::CachedScriptFetcher::create):
(WebCore::CachedScriptFetcher::requestModuleScript):
requestModuleScript function is used only when loading a new module script.
So, LoadableClassicScript should use requestScriptWithCache to load itself.
We pass String() for cross origin mode for null cross origin attribute as
specified.

(WebCore::CachedScriptFetcher::requestScriptWithCache):

  • bindings/js/CachedScriptFetcher.h:

(WebCore::CachedScriptFetcher::CachedScriptFetcher):

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::moduleLoaderImportModule):

  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSLazyEventListener.cpp:

(WebCore::JSLazyEventListener::initializeJSFunction):

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::executeScript):

  • bindings/js/ScriptModuleLoader.cpp:

(WebCore::resolveModuleSpecifier):
Extract the part of resolving module specifier to a static function to use
it in ScriptModuleLoader::resolve and ScriptModuleLoader::importModule.

(WebCore::ScriptModuleLoader::resolve):
(WebCore::rejectPromise):
(WebCore::ScriptModuleLoader::importModule):
New hook moduleLoaderImportModule is implemented. This hook is called when
import operator is used. This hook is responsible to

  1. resolve the module name to obtain module specifier. (like, resolve the

relative URL to get absolute URL.)

  1. kick module loading with the resolved specifier.

When resolving the module name, the referrer information is needed.
For example, "./script.js" will be resolved to "http://example.com/script.js" if
the referrer module specifier is "http://example.com/".
If import("./script.js") is executed in the classic script
src="http://example.com/test.js", it starts loading "http://example.com/script.js".
So the information of the caller of import operator is necessary here.
This appropriate referrer is propagated by SourceOrigin.

  • bindings/js/ScriptModuleLoader.h:
  • dom/InlineClassicScript.h:
  • dom/LoadableClassicScript.cpp:

(WebCore::LoadableClassicScript::load):

  • dom/LoadableClassicScript.h:
  • dom/LoadableModuleScript.h:
  • dom/LoadableScript.h:

(WebCore::LoadableScript::LoadableScript):
(WebCore::LoadableScript::isClassicScript): Deleted.
(WebCore::LoadableScript::isModuleScript): Deleted.

  • dom/ScriptElement.h:
  • dom/ScriptElementCachedScriptFetcher.cpp: Copied from Source/WebCore/dom/InlineClassicScript.h.

(WebCore::ScriptElementCachedScriptFetcher::requestModuleScript):
This requestModuleScript will be used when the script tag (or modules imported from the script tag) uses import operator.
In classic scripts, crossorigin mode always becomes "omit" while module scripts
propagate the original crossorigin value.

  • dom/ScriptElementCachedScriptFetcher.h: Copied from Source/WebCore/bindings/js/CachedScriptFetcher.h.

(WebCore::ScriptElementCachedScriptFetcher::crossOriginMode):
(WebCore::ScriptElementCachedScriptFetcher::ScriptElementCachedScriptFetcher):

LayoutTests:

  • http/tests/misc/import-absolute-url-expected.txt: Added.
  • http/tests/misc/import-absolute-url.html: Added.
  • http/tests/security/contentSecurityPolicy/1.1/import-scriptnonce-expected.txt: Added.
  • http/tests/security/contentSecurityPolicy/1.1/import-scriptnonce.html: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed1.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed2.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed3.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed4.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed5.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed6.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked1.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked2.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked3.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked4.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked5.js: Added.
  • http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked6.js: Added.
  • http/tests/security/import-module-crossorigin-loads-error-expected.txt: Added.
  • http/tests/security/import-module-crossorigin-loads-error-src-expected.txt: Added.
  • http/tests/security/import-module-crossorigin-loads-error-src.html: Added.
  • http/tests/security/import-module-crossorigin-loads-error.html: Added.
  • http/tests/security/import-module-crossorigin-loads-expected.txt: Added.
  • http/tests/security/import-module-crossorigin-loads-src-expected.txt: Added.
  • http/tests/security/import-module-crossorigin-loads-src.html: Added.
  • http/tests/security/import-module-crossorigin-loads.html: Added.
  • http/tests/security/import-script-crossorigin-loads-error-expected.txt: Added.
  • http/tests/security/import-script-crossorigin-loads-error.html: Added.
  • http/tests/security/import-script-crossorigin-loads-omit-expected.txt: Added.
  • http/tests/security/import-script-crossorigin-loads-omit.html: Added.
  • http/tests/security/resources/cors-deny.php: Added.
  • http/tests/security/resources/import-module-crossorigin-loads-error-src.js: Added.

(import.string_appeared_here.then):

  • http/tests/security/resources/import-module-crossorigin-loads-src.js: Added.

(import.string_appeared_here.then):

  • js/dom/modules/import-execution-order-expected.txt: Added.
  • 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.
  • js/dom/modules/import-from-handler-expected.txt: Added.
  • js/dom/modules/import-from-handler.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
  • js/dom/modules/import-from-javascript-url-expected.txt: Added.
  • 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.
  • js/dom/modules/import-from-loaded-classic-expected.txt: Added.
  • js/dom/modules/import-from-loaded-classic.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
  • js/dom/modules/import-from-loaded-module-expected.txt: Added.
  • js/dom/modules/import-from-loaded-module.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
  • js/dom/modules/import-from-module-expected.txt: Added.
  • js/dom/modules/import-from-module.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
  • js/dom/modules/import-incorrect-relative-specifier-expected.txt: Added.
  • js/dom/modules/import-incorrect-relative-specifier.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
  • js/dom/modules/import-simple-expected.txt: Added.
  • js/dom/modules/import-simple.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html.
  • js/dom/modules/module-document-write-src.html:
  • js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html:
  • js/dom/modules/module-execution-order-mixed-with-classic-scripts.html:
  • js/dom/modules/module-execution-order-mixed.html:
  • js/dom/modules/module-inline-dynamic.html:
  • js/dom/modules/module-inline-simple.html:
  • js/dom/modules/module-load-event-with-src.html:
  • js/dom/modules/module-load-same-module-from-different-entry-point-dynamic.html:
  • js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html:
  • js/dom/modules/module-load-same-module-from-different-entry-point.html:
  • js/dom/modules/module-not-found-error-event-with-src-and-import.html:
  • js/dom/modules/module-src-current-script.html:
  • js/dom/modules/module-src-dynamic.html:
  • js/dom/modules/module-src-simple.html:
  • js/dom/modules/module-type-case-insensitive.html:
  • js/dom/modules/module-will-fire-beforeload.html:
  • js/dom/modules/nomodule-dynamic-classic-src.html:
  • js/dom/modules/nomodule-has-no-effect-on-module-inline.html:
  • js/dom/modules/nomodule-has-no-effect-on-module-src.html:
  • js/dom/modules/nomodule-prevents-execution-classic-script-src.html:
  • js/dom/modules/nomodule-reflect.html:
  • js/dom/modules/resources/error-classic-script.js: Renamed from LayoutTests/js/dom/modules/script-tests/error-classic-script.js.
  • js/dom/modules/resources/import-from-loaded-classic-finish.js: Added.
  • js/dom/modules/resources/import-from-loaded-classic.js: Added.
  • js/dom/modules/resources/import-from-loaded-module-finish.js: Added.
  • js/dom/modules/resources/import-from-loaded-module.js: Added.
  • js/dom/modules/resources/module-document-write-src.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-document-write-src.js.
  • 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.
  • 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.
  • js/dom/modules/resources/module-execution-order-mixed-2.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-2.js.
  • js/dom/modules/resources/module-execution-order-mixed-cappuccino.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-cappuccino.js.
  • js/dom/modules/resources/module-execution-order-mixed-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-cocoa.js.
  • js/dom/modules/resources/module-execution-order-mixed-matcha.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-matcha.js.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • js/dom/modules/resources/module-execution-order-mixed.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed.js.
  • js/dom/modules/resources/module-inline-dynamic.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-inline-dynamic.js.
  • js/dom/modules/resources/module-inline-simple.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-inline-simple.js.
  • js/dom/modules/resources/module-load-event-with-src.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-load-event-with-src.js.
  • 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.
  • 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.
  • js/dom/modules/resources/module-src-current-script.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-current-script.js.
  • js/dom/modules/resources/module-src-dynamic-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-dynamic-cocoa.js.
  • js/dom/modules/resources/module-src-dynamic.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-dynamic.js.
  • js/dom/modules/resources/module-src-simple-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-simple-cocoa.js.
  • js/dom/modules/resources/module-src-simple.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-simple.js.
  • js/dom/modules/resources/module-will-fire-beforeload.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-will-fire-beforeload.js.
Location:
trunk
Files:
70 added
41 edited
10 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r211254 r211280  
     12017-01-27  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 Ryosuke Niwa.
     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  Chris Dumez  <cdumez@apple.com>
    2109
  • trunk/LayoutTests/js/dom/modules/import-execution-order.html

    r211277 r211280  
    66<body>
    77<script>
    8 description('Test window.onerror will be fired when the dependent module throw an error.');
     8description('Test import execution order.');
     9window.count = 0;
     10
    911// Module will be executed asynchronously.
    1012window.jsTestIsAsync = true;
    1113debug('Module is not executed yet.');
    12 window.onerror = function () {
    13     finishJSTest();
    14 }
    1514</script>
    1615<script src="../../../resources/js-test-post.js"></script>
    17 <script type="module">
    18 import "./script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js"
    19 testFailed("executed");
     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}());
    2024</script>
    2125</body>
  • trunk/LayoutTests/js/dom/modules/import-from-handler.html

    r211277 r211280  
    66<body>
    77<script>
    8 description('Test module with "src" attribute.');
     8description('Test import from handler.');
    99
    1010// Module will be executed asynchronously.
     
    1212</script>
    1313<script>
    14 debug('Module is not executed yet.');
    1514</script>
    1615<script src="../../../resources/js-test-post.js"></script>
    17 <script type="module" src="./script-tests/module-src-simple.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>
    1822</body>
    1923</html>
  • trunk/LayoutTests/js/dom/modules/import-from-javascript-url.html

    r211277 r211280  
    66<body>
    77<script>
    8 description('Test window.onerror will be fired when the dependent module throw an error.');
     8description('Test import from javascript URL.');
     9
    910// Module will be executed asynchronously.
    1011window.jsTestIsAsync = true;
    11 debug('Module is not executed yet.');
    12 window.onerror = function () {
    13     finishJSTest();
    14 }
     12</script>
     13<script>
    1514</script>
    1615<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>
    1717<script type="module">
    18 import "./script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js"
    19 testFailed("executed");
     18debug('Module is not executed yet.');
     19let anchor = document.getElementById('target');
     20anchor.dispatchEvent(new MouseEvent('click'));
    2021</script>
    2122</body>
  • trunk/LayoutTests/js/dom/modules/import-from-loaded-classic.html

    r211277 r211280  
    66<body>
    77<script>
    8 description('Test nomodule does not have any effect on module script.');
     8description('Test import from loaded classic.');
    99
    1010// Module will be executed asynchronously.
    1111window.jsTestIsAsync = true;
     12
     13function loaded()
     14{
     15    shouldBeTrue(`window.imported`);
     16    finishJSTest();
     17}
    1218</script>
    1319<script>
    14 debug('Module is not executed yet.');
    1520</script>
    1621<script src="../../../resources/js-test-post.js"></script>
    17 <script nomodule type="module" src="./script-tests/module-src-simple.js"></script>
     22<script src="./resources/import-from-loaded-classic.js"></script>
    1823</body>
    1924</html>
  • trunk/LayoutTests/js/dom/modules/import-from-loaded-module.html

    r211277 r211280  
    66<body>
    77<script>
    8 description('Test nomodule does not have any effect on module script.');
     8description('Test import from loaded module.');
    99
    1010// Module will be executed asynchronously.
    1111window.jsTestIsAsync = true;
     12
     13function loaded()
     14{
     15    shouldBeTrue(`window.imported`);
     16    finishJSTest();
     17}
     18
    1219</script>
    1320<script>
    14 debug('Module is not executed yet.');
    1521</script>
    1622<script src="../../../resources/js-test-post.js"></script>
    17 <script nomodule type="module" src="./script-tests/module-src-simple.js"></script>
     23<script type="module" src="./resources/import-from-loaded-module.js"></script>
    1824</body>
    1925</html>
  • trunk/LayoutTests/js/dom/modules/import-incorrect-relative-specifier.html

    r211277 r211280  
    66<body>
    77<script>
    8 description('Test module with "src" attribute.');
    9 
     8description('Test import rejects the incorrect relative specifiers.');
    109// Module will be executed asynchronously.
    1110window.jsTestIsAsync = true;
    1211</script>
     12<script src="../../../resources/js-test-post.js"></script>
    1313<script>
    14 debug('Module is not executed yet.');
     14(async function () {
     15    await shouldReject(`import("incorrect")`);
     16    await shouldReject(`import("$hello")`);
     17    await shouldReject(`import(".../test")`);
     18    finishJSTest();
     19}());
    1520</script>
    16 <script src="../../../resources/js-test-post.js"></script>
    17 <script type="module" src="./script-tests/module-src-simple.js"></script>
    1821</body>
    1922</html>
  • trunk/LayoutTests/js/dom/modules/import-simple.html

    r211277 r211280  
    66<body>
    77<script>
    8 description('Test module with "src" attribute.');
     8description('Test import simple.');
    99
    1010// Module will be executed asynchronously.
     
    1212</script>
    1313<script>
    14 debug('Module is not executed yet.');
    1514</script>
    1615<script src="../../../resources/js-test-post.js"></script>
    17 <script type="module" src="./script-tests/module-src-simple.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>
    1823</body>
    1924</html>
  • trunk/LayoutTests/js/dom/modules/module-document-write-src.html

    r208788 r211280  
    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>
  • trunk/LayoutTests/js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html

    r208788 r211280  
    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>
  • trunk/LayoutTests/js/dom/modules/module-execution-order-mixed-with-classic-scripts.html

    r208788 r211280  
    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");
     
    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");
  • trunk/LayoutTests/js/dom/modules/module-execution-order-mixed.html

    r208788 r211280  
    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");
  • trunk/LayoutTests/js/dom/modules/module-inline-dynamic.html

    r208788 r211280  
    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
  • trunk/LayoutTests/js/dom/modules/module-inline-simple.html

    r208788 r211280  
    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
  • trunk/LayoutTests/js/dom/modules/module-load-event-with-src.html

    r208788 r211280  
    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>
  • trunk/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-dynamic.html

    r208788 r211280  
    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);
  • trunk/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html

    r209172 r211280  
    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();
  • trunk/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point.html

    r208788 r211280  
    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;
  • trunk/LayoutTests/js/dom/modules/module-not-found-error-event-with-src-and-import.html

    r208788 r211280  
    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`);
  • trunk/LayoutTests/js/dom/modules/module-src-current-script.html

    r208788 r211280  
    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>
  • trunk/LayoutTests/js/dom/modules/module-src-dynamic.html

    r208788 r211280  
    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}());
  • trunk/LayoutTests/js/dom/modules/module-src-simple.html

    r208788 r211280  
    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>
  • trunk/LayoutTests/js/dom/modules/module-type-case-insensitive.html

    r208788 r211280  
    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>
  • trunk/LayoutTests/js/dom/modules/module-will-fire-beforeload.html

    r208788 r211280  
    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>
  • trunk/LayoutTests/js/dom/modules/nomodule-dynamic-classic-src.html

    r211078 r211280  
    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 () {
  • trunk/LayoutTests/js/dom/modules/nomodule-has-no-effect-on-module-inline.html

    r211078 r211280  
    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
  • trunk/LayoutTests/js/dom/modules/nomodule-has-no-effect-on-module-src.html

    r211078 r211280  
    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>
  • trunk/LayoutTests/js/dom/modules/nomodule-prevents-execution-classic-script-src.html

    r211078 r211280  
    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`);
  • trunk/LayoutTests/js/dom/modules/nomodule-reflect.html

    r211078 r211280  
    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;
  • trunk/LayoutTests/js/dom/modules/script-tests/error-classic-script.js

    r211078 r211280  
    1 window.executed = true;
    2 testFailed("error");
    3 
  • trunk/Source/WebCore/CMakeLists.txt

    r211161 r211280  
    14761476    dom/ScopedEventQueue.cpp
    14771477    dom/ScriptElement.cpp
     1478    dom/ScriptElementCachedScriptFetcher.cpp
    14781479    dom/ScriptExecutionContext.cpp
    14791480    dom/ScriptRunner.cpp
  • trunk/Source/WebCore/ChangeLog

    r211256 r211280  
     12017-01-27  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 Ryosuke Niwa.
     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        * WebCore.xcodeproj/project.pbxproj:
     27        * bindings/js/CachedModuleScriptLoader.cpp:
     28        (WebCore::CachedModuleScriptLoader::load):
     29        * bindings/js/CachedScriptFetcher.cpp:
     30        (WebCore::CachedScriptFetcher::create):
     31        (WebCore::CachedScriptFetcher::requestModuleScript):
     32        requestModuleScript function is used only when loading a new module script.
     33        So, LoadableClassicScript should use requestScriptWithCache to load itself.
     34        We pass String() for cross origin mode for null cross origin attribute as
     35        specified.
     36
     37        (WebCore::CachedScriptFetcher::requestScriptWithCache):
     38        * bindings/js/CachedScriptFetcher.h:
     39        (WebCore::CachedScriptFetcher::CachedScriptFetcher):
     40        * bindings/js/JSDOMWindowBase.cpp:
     41        (WebCore::JSDOMWindowBase::moduleLoaderImportModule):
     42        * bindings/js/JSDOMWindowBase.h:
     43        * bindings/js/JSLazyEventListener.cpp:
     44        (WebCore::JSLazyEventListener::initializeJSFunction):
     45        * bindings/js/ScriptController.cpp:
     46        (WebCore::ScriptController::executeScript):
     47        * bindings/js/ScriptModuleLoader.cpp:
     48        (WebCore::resolveModuleSpecifier):
     49        Extract the part of resolving module specifier to a static function to use
     50        it in ScriptModuleLoader::resolve and ScriptModuleLoader::importModule.
     51
     52        (WebCore::ScriptModuleLoader::resolve):
     53        (WebCore::rejectPromise):
     54        (WebCore::ScriptModuleLoader::importModule):
     55        New hook moduleLoaderImportModule is implemented. This hook is called when
     56        `import` operator is used. This hook is responsible to
     57            1. resolve the module name to obtain module specifier. (like, resolve the
     58                relative URL to get absolute URL.)
     59            2. kick module loading with the resolved specifier.
     60        When resolving the module name, the referrer information is needed.
     61        For example, "./script.js" will be resolved to "http://example.com/script.js" if
     62        the referrer module specifier is "http://example.com/".
     63        If `import("./script.js")` is executed in the classic script
     64        src="http://example.com/test.js", it starts loading "http://example.com/script.js".
     65        So the information of the caller of `import` operator is necessary here.
     66        This appropriate referrer is propagated by SourceOrigin.
     67
     68        * bindings/js/ScriptModuleLoader.h:
     69        * dom/InlineClassicScript.h:
     70        * dom/LoadableClassicScript.cpp:
     71        (WebCore::LoadableClassicScript::load):
     72        * dom/LoadableClassicScript.h:
     73        * dom/LoadableModuleScript.h:
     74        * dom/LoadableScript.h:
     75        (WebCore::LoadableScript::LoadableScript):
     76        (WebCore::LoadableScript::isClassicScript): Deleted.
     77        (WebCore::LoadableScript::isModuleScript): Deleted.
     78        * dom/ScriptElement.h:
     79        * dom/ScriptElementCachedScriptFetcher.cpp: Copied from Source/WebCore/dom/InlineClassicScript.h.
     80        (WebCore::ScriptElementCachedScriptFetcher::requestModuleScript):
     81        This requestModuleScript will be used when the script tag (or modules imported from the script tag) uses `import` operator.
     82        In classic scripts, `crossorigin` mode always becomes "omit" while module scripts
     83        propagate the original `crossorigin` value.
     84
     85        * dom/ScriptElementCachedScriptFetcher.h: Copied from Source/WebCore/bindings/js/CachedScriptFetcher.h.
     86        (WebCore::ScriptElementCachedScriptFetcher::crossOriginMode):
     87        (WebCore::ScriptElementCachedScriptFetcher::ScriptElementCachedScriptFetcher):
     88
    1892017-01-26  Chris Dumez  <cdumez@apple.com>
    290
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r211255 r211280  
    63286328                E3B7C0631DC34160001FB0B8 /* JSDocumentDOMJIT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B7C0621DC3415A001FB0B8 /* JSDocumentDOMJIT.cpp */; };
    63296329                E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */; };
     6330                E3E4E2A71E3B17100023BB8A /* ScriptElementCachedScriptFetcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3E4E2A51E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.cpp */; };
     6331                E3E4E2A81E3B17100023BB8A /* ScriptElementCachedScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E3E4E2A61E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
    63306332                E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FA38611D716E7600AA5950 /* PendingScriptClient.h */; };
    63316333                E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1437914381                E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITCheckDOM.h; sourceTree = "<group>"; };
    1438014382                E3D049931DADC04500718F3C /* NodeConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeConstants.h; sourceTree = "<group>"; };
     14383                E3E4E2A51E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptElementCachedScriptFetcher.cpp; sourceTree = "<group>"; };
     14384                E3E4E2A61E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptElementCachedScriptFetcher.h; sourceTree = "<group>"; };
    1438114385                E3FA38611D716E7600AA5950 /* PendingScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScriptClient.h; sourceTree = "<group>"; };
    1438214386                E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = "<group>"; };
     
    2441224416                                08A484750E5272C500C3FE76 /* ScriptElement.cpp */,
    2441324417                                08A484760E5272C500C3FE76 /* ScriptElement.h */,
     24418                                E3E4E2A51E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.cpp */,
     24419                                E3E4E2A61E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.h */,
    2441424420                                E11C9DAF0EB3699500E409DB /* ScriptExecutionContext.cpp */,
    2441524421                                E11C9D9A0EB3681200E409DB /* ScriptExecutionContext.h */,
     
    2586425870                                8482B7461198C35400BFB005 /* HashChangeEvent.h in Headers */,
    2586525871                                A8748BE012CBF2DC001FBA41 /* HashTools.h in Headers */,
     25872                                E3E4E2A81E3B17100023BB8A /* ScriptElementCachedScriptFetcher.h in Headers */,
    2586625873                                F55B3DC01251F12D003EF269 /* HiddenInputType.h in Headers */,
    2586725874                                515BE19C1D54F6C100DD7C68 /* HIDGamepad.h in Headers */,
     
    3184831855                                AAA728F816D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.mm in Sources */,
    3184931856                                AA478A8016CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm in Sources */,
     31857                                E3E4E2A71E3B17100023BB8A /* ScriptElementCachedScriptFetcher.cpp in Sources */,
    3185031858                                2D3EF4491917915C00034184 /* WebActionDisablingCALayerDelegate.mm in Sources */,
    3185131859                                120DE3ED1C86CA3E00B6D4DD /* WebAnimation.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp

    r210627 r211280  
    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;
  • trunk/Source/WebCore/bindings/js/CachedScriptFetcher.cpp

    r210627 r211280  
    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();
     
    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));
  • trunk/Source/WebCore/bindings/js/CachedScriptFetcher.h

    r210627 r211280  
    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)
     
    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;
  • trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp

    r211247 r211280  
    6565    &queueTaskToEventLoop,
    6666    &shouldInterruptScriptBeforeTimeout,
    67     nullptr,
     67    &moduleLoaderImportModule,
    6868    &moduleLoaderResolve,
    6969    &moduleLoaderFetch,
     
    333333}
    334334
     335JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderImportModule(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSString* moduleName, const JSC::SourceOrigin& sourceOrigin)
     336{
     337    JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
     338    if (RefPtr<Document> document = thisObject->wrapped().document())
     339        return document->moduleLoader()->importModule(globalObject, exec, moduleLoader, moduleName, sourceOrigin);
     340    JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
     341    return deferred->reject(exec, jsUndefined());
     342}
     343
    335344} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h

    r211247 r211280  
    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;
  • trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp

    r210149 r211280  
    2121#include "JSLazyEventListener.h"
    2222
     23#include "CachedScriptFetcher.h"
    2324#include "ContentSecurityPolicy.h"
    2425#include "Frame.h"
     
    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())) {
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r211247 r211280  
    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
  • trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp

    r211247 r211280  
    2929#include "CachedModuleScriptLoader.h"
    3030#include "CachedScript.h"
     31#include "CachedScriptFetcher.h"
    3132#include "Document.h"
    3233#include "Frame.h"
     
    3637#include "ScriptController.h"
    3738#include "ScriptSourceCode.h"
     39#include <runtime/Completion.h>
    3840#include <runtime/JSInternalPromise.h>
    3941#include <runtime/JSInternalPromiseDeferred.h>
     
    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    URL absoluteURL(URL(), specifier);
     71    if (absoluteURL.isValid())
     72        return absoluteURL;
     73
     74    if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../"))
     75        return makeUnexpected(ASCIILiteral("Module specifier does not start with \"/\", \"./\", or \"../\"."));
     76
     77    auto result = document.completeURL(specifier, baseURL);
     78    if (!result.isValid())
     79        return makeUnexpected(ASCIILiteral("Module name does not resolve to a valid URL."));
     80    return result;
     81}
     82
    6483JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleNameValue, JSC::JSValue importerModuleKey, JSC::JSValue)
    6584{
     
    7695    }
    7796
    78     // https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier
    79 
    8097    if (!moduleNameValue.isString()) {
    81         promise->reject(TypeError, ASCIILiteral("Module specifier is not Symbol or String."));
     98        promise->reject(TypeError, ASCIILiteral("Importer module key is not a Symbol or a String."));
    8299        return jsPromise.promise();
    83100    }
    84101
    85102    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 
     103    URL baseURL;
    105104    if (isRootModule(importerModuleKey))
    106         completedURL = m_document.completeURL(specifier);
    107     else if (importerModuleKey.isString()) {
     105        baseURL = m_document.baseURL();
     106    else {
     107        ASSERT(importerModuleKey.isString());
    108108        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         }
    119 
    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();
    124     }
    125 
    126     if (!completedURL.isValid()) {
    127         promise->reject(TypeError, ASCIILiteral("Module name constructs an invalid URL."));
    128         return jsPromise.promise();
    129     }
    130 
    131     promise->resolve<IDLDOMString>(completedURL.string());
     109        ASSERT_WITH_MESSAGE(importerModuleRequestURL.isValid(), "Invalid module referrer never starts importing dependent modules.");
     110
     111        auto iterator = m_requestURLToResponseURLMap.find(importerModuleRequestURL);
     112        ASSERT_WITH_MESSAGE(iterator != m_requestURLToResponseURLMap.end(), "Module referrer must register itself to the map before starting importing dependent modules.");
     113        baseURL = iterator->value;
     114    }
     115
     116    auto result = resolveModuleSpecifier(m_document, specifier, baseURL);
     117    if (!result) {
     118        promise->reject(TypeError, result.error());
     119        return jsPromise.promise();
     120    }
     121
     122    promise->resolve<IDLDOMString>(result->string());
    132123    return jsPromise.promise();
    133124}
     
    200191}
    201192
     193static JSC::JSInternalPromise* rejectPromise(JSC::ExecState& state, JSDOMGlobalObject& globalObject, ExceptionCode ec, ASCIILiteral message)
     194{
     195    auto& jsPromise = *JSC::JSInternalPromiseDeferred::create(&state, &globalObject);
     196    auto deferred = DeferredPromise::create(globalObject, jsPromise);
     197    deferred->reject(ec, WTFMove(message));
     198    return jsPromise.promise();
     199}
     200
     201JSC::JSInternalPromise* ScriptModuleLoader::importModule(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSString* moduleName, const JSC::SourceOrigin& sourceOrigin)
     202{
     203    auto& state = *exec;
     204    JSC::VM& vm = exec->vm();
     205    auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);
     206
     207    // FIXME: setTimeout and setInterval with "string()" should propagate SourceOrigin.
     208    // https://webkit.org/b/167097
     209    ASSERT_WITH_MESSAGE(!sourceOrigin.isNull(), "If SourceOrigin is null, this function is not invoked.");
     210    if (!sourceOrigin.fetcher())
     211        return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Could not use import operator in this context."));
     212
     213    URL baseURL(URL(), sourceOrigin.string());
     214    if (!baseURL.isValid())
     215        return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not Symbol or String."));
     216
     217    auto specifier = moduleName->value(exec);
     218    auto result = resolveModuleSpecifier(m_document, specifier, baseURL);
     219    if (!result)
     220        return rejectPromise(state, globalObject, TypeError, result.error());
     221
     222    return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, sourceOrigin.fetcher() ));
     223}
     224
    202225void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise)
    203226{
  • trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h

    r210585 r211280  
    3939class JSInternalPromise;
    4040class JSModuleLoader;
     41class SourceOrigin;
    4142
    4243}
     
    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:
  • trunk/Source/WebCore/dom/InlineClassicScript.h

    r210627 r211280  
    2626#pragma once
    2727
    28 #include "CachedScriptFetcher.h"
     28#include "ScriptElementCachedScriptFetcher.h"
    2929
    3030namespace WebCore {
     
    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    }
  • trunk/Source/WebCore/dom/LoadableClassicScript.cpp

    r210627 r211280  
    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;
  • trunk/Source/WebCore/dom/LoadableClassicScript.h

    r210828 r211280  
    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;
  • trunk/Source/WebCore/dom/LoadableModuleScript.h

    r210585 r211280  
    4444
    4545    CachedModuleScript& moduleScript() { return m_moduleScript.get(); }
     46
     47    bool isClassicScript() const final { return false; }
    4648    bool isModuleScript() const final { return true; }
    4749
  • trunk/Source/WebCore/dom/LoadableScript.h

    r210627 r211280  
    2626#pragma once
    2727
    28 #include "CachedScriptFetcher.h"
     28#include "ScriptElementCachedScriptFetcher.h"
    2929#include <runtime/ConsoleTypes.h>
    3030#include <wtf/HashCountedSet.h>
     
    3737class ScriptElement;
    3838
    39 class LoadableScript : public CachedScriptFetcher {
     39class LoadableScript : public ScriptElementCachedScriptFetcher {
    4040public:
    4141    enum class ErrorType {
     
    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    }
  • trunk/Source/WebCore/dom/ScriptElement.h

    r211078 r211280  
    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);
  • trunk/Source/WebCore/dom/ScriptElementCachedScriptFetcher.cpp

    r211277 r211280  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "ScriptElementCachedScriptFetcher.h"
    2728
    28 #include "CachedScriptFetcher.h"
     29#include "Element.h"
     30#include "ScriptElement.h"
    2931
    3032namespace WebCore {
    3133
    32 class ScriptElement;
     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".
    3338
    34 class InlineClassicScript final : public CachedScriptFetcher {
    35 public:
    36     static Ref<InlineClassicScript> create(ScriptElement&);
    37 
    38 private:
    39     InlineClassicScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
    40         : CachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
    41     {
    42     }
    43 };
     39    return requestScriptWithCache(document, sourceURL, isClassicScript() ? ASCIILiteral("omit") : m_crossOriginMode);
     40}
    4441
    4542}
  • trunk/Source/WebCore/dom/ScriptElementCachedScriptFetcher.h

    r211277 r211280  
    2626#pragma once
    2727
    28 #include "CachedResourceHandle.h"
    29 #include <runtime/ScriptFetcher.h>
    30 #include <wtf/text/WTFString.h>
     28#include "CachedScriptFetcher.h"
    3129
    3230namespace WebCore {
    3331
    34 class CachedScript;
    35 class Document;
    36 class URL;
     32class ScriptElementCachedScriptFetcher : public CachedScriptFetcher {
     33public:
     34    virtual CachedResourceHandle<CachedScript> requestModuleScript(Document&, const URL& sourceURL) const;
    3735
    38 class CachedScriptFetcher : public JSC::ScriptFetcher {
    39 public:
    40     CachedResourceHandle<CachedScript> requestScriptWithCache(Document&, const URL& sourceURL) const;
     36    virtual bool isClassicScript() const = 0;
     37    virtual bool isModuleScript() const = 0;
     38
     39    const String& crossOriginMode() const { return m_crossOriginMode; }
    4140
    4241protected:
    43     CachedScriptFetcher(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
    44         : m_nonce(nonce)
     42    ScriptElementCachedScriptFetcher(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
     43        : CachedScriptFetcher(nonce, charset, initiatorName, isInUserAgentShadowTree)
    4544        , m_crossOriginMode(crossOriginMode)
    46         , m_charset(charset)
    47         , m_initiatorName(initiatorName)
    48         , m_isInUserAgentShadowTree(isInUserAgentShadowTree)
    4945    {
    5046    }
    5147
    5248private:
    53     String m_nonce;
    5449    String m_crossOriginMode;
    55     String m_charset;
    56     AtomicString m_initiatorName;
    57     bool m_isInUserAgentShadowTree { false };
    5850};
    5951
Note: See TracChangeset for help on using the changeset viewer.