[ES Modules] Allow .mjs content when loaded from file://
https://bugs.webkit.org/show_bug.cgi?id=192100
<rdar://problem/
46320065>
Reviewed by Sam Weinig.
Source/WebCore:
Node JS requires ES Module files to be identified by the file
extension of ".mjs" (no relation to Maciej Stachowiak). This new
extension causes issues because it isn't recognised as a JavaScript
file. When using the script tag, the author is able to force the type
of the referenced file using an attribute, but this isn't possible
for the import() function or import statement.
Add a new entry into our table that maps file extensions to MIME types
so that when a .mjs file is loaded from a file:// reference it is
identified as JavaScript.
Test: js/dom/modules/import-mjs-module.html
* platform/network/mac/WebCoreURLResponse.mm: Add .mjs to the existing dictionary.
(WebCore::createExtensionToMIMETypeMap):
* platform/network/ios/WebCoreURLResponseIOS.mm: Add code just for .mjs.
(WebCore::createExtensionToMIMETypeMap):
Source/WebInspectorUI:
Add a mapping from .mjs to application/javascript.
* UserInterface/Base/MIMETypeUtilities.js:
(WI.mimeTypeForFileExtension):
LayoutTests:
Test for both import() function and the import statement loading
from .mjs files.
* js/dom/modules/import-mjs-module-expected.txt: Added.
* js/dom/modules/import-mjs-module.html: Added.
* js/dom/modules/resources/module-simple-A.mjs: Added.
* js/dom/modules/resources/module-simple-B.mjs: Added.
* platform/win/TestExpectations: Skip this on Windows. Just wait for Windows
to recognise the extension.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238673
268f45cc-cd09-0410-ab3c-
d52691b4dbfc