Use text/javascript as recommended by the HTML specification
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Dec 2018 19:45:45 +0000 (19:45 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Dec 2018 19:45:45 +0000 (19:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192525
<rdar://problem/46569636>

Reviewed by Jon Lee.

The HTML specification says we should use text/javascript for
JavaScript files:
https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages:javascript-mime-type

Source/WebCore:

* loader/cache/CachedScript.cpp: Replace application/javascript with text/javascript.
(WebCore::CachedScript::CachedScript):
* platform/network/ios/WebCoreURLResponseIOS.mm: Ditto.
(WebCore::createExtensionToMIMETypeMap):
* platform/network/mac/WebCoreURLResponse.mm: Ditto.
(WebCore::createExtensionToMIMETypeMap):

Source/WebInspectorUI:

* UserInterface/Base/MIMETypeUtilities.js:
(WI.mimeTypeForFileExtension):
* UserInterface/Views/TextEditor.js:
(WI.TextEditor.prototype._attemptToDetermineMIMEType):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239037 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedScript.cpp
Source/WebCore/platform/network/ios/WebCoreURLResponseIOS.mm
Source/WebCore/platform/network/mac/WebCoreURLResponse.mm
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/MIMETypeUtilities.js
Source/WebInspectorUI/UserInterface/Views/TextEditor.js

index a2c3603..f309cd3 100644 (file)
@@ -1,5 +1,24 @@
 2018-12-10  Dean Jackson  <dino@apple.com>
 
+        Use text/javascript as recommended by the HTML specification
+        https://bugs.webkit.org/show_bug.cgi?id=192525
+        <rdar://problem/46569636>
+
+        Reviewed by Jon Lee.
+
+        The HTML specification says we should use text/javascript for
+        JavaScript files:
+        https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages:javascript-mime-type
+
+        * loader/cache/CachedScript.cpp: Replace application/javascript with text/javascript.
+        (WebCore::CachedScript::CachedScript):
+        * platform/network/ios/WebCoreURLResponseIOS.mm: Ditto.
+        (WebCore::createExtensionToMIMETypeMap):
+        * platform/network/mac/WebCoreURLResponse.mm: Ditto.
+        (WebCore::createExtensionToMIMETypeMap):
+
+2018-12-10  Dean Jackson  <dino@apple.com>
+
         [iOS] Make WebGPU work with remote layer hosting
         https://bugs.webkit.org/show_bug.cgi?id=192508
         <rdar://problem/46560649>
index 515f915..225e91b 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 
 CachedScript::CachedScript(CachedResourceRequest&& request, PAL::SessionID sessionID)
     : CachedResource(WTFMove(request), Type::Script, sessionID)
-    , m_decoder(TextResourceDecoder::create("application/javascript"_s, request.charset()))
+    , m_decoder(TextResourceDecoder::create("text/javascript"_s, request.charset()))
 {
 }
 
index 00b5ab2..4dcace2 100644 (file)
@@ -47,7 +47,7 @@ static CFDictionaryRef createExtensionToMIMETypeMap()
     };
 
     CFStringRef values[] = {
-        CFSTR("application/javascript")
+        CFSTR("text/javascript")
     };
 
     ASSERT(sizeof(keys) == sizeof(values));
index 1471e31..abc3d3b 100644 (file)
@@ -212,7 +212,7 @@ static CFDictionaryRef createExtensionToMIMETypeMap()
         CFSTR("application/x-troff-me"),
         CFSTR("model/mesh"),
         CFSTR("application/vnd.mif"),
-        CFSTR("application/javascript"),
+        CFSTR("text/javascript"),
         CFSTR("video/x-sgi-movie"),
         CFSTR("audio/mpeg"),
         CFSTR("audio/mpeg"),
index 698900f..5937caf 100644 (file)
@@ -1,3 +1,20 @@
+2018-12-10  Dean Jackson  <dino@apple.com>
+
+        Use text/javascript as recommended by the HTML specification
+        https://bugs.webkit.org/show_bug.cgi?id=192525
+        <rdar://problem/46569636>
+
+        Reviewed by Jon Lee.
+
+        The HTML specification says we should use text/javascript for
+        JavaScript files:
+        https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages:javascript-mime-type
+
+        * UserInterface/Base/MIMETypeUtilities.js:
+        (WI.mimeTypeForFileExtension):
+        * UserInterface/Views/TextEditor.js:
+        (WI.TextEditor.prototype._attemptToDetermineMIMEType):
+
 2018-12-06  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: REGRESSION(r238602): Elements: collapsing a DOM node with the left arrow doesn't work
index 87dfa14..ed53a1f 100644 (file)
@@ -48,8 +48,8 @@ WI.mimeTypeForFileExtension = function(extension)
         "xml": "text/xml",
 
         // Script types.
-        "js": "application/javascript",
-        "mjs": "application/javascript",
+        "js": "text/javascript",
+        "mjs": "text/javascript",
         "json": "application/json",
         "clj": "text/x-clojure",
         "coffee": "text/x-coffeescript",
index 3ffe502..8ee382a 100644 (file)
@@ -909,7 +909,7 @@ WI.TextEditor = class TextEditor extends WI.View
             if (!formattedText)
                 return;
 
-            this.mimeType = "application/javascript";
+            this.mimeType = "text/javascript";
 
             if (Date.now() - startTime < 100)
                 this.updateFormattedState(true);