Title: [224507] trunk
Revision
224507
Author
commit-qu...@webkit.org
Date
2017-11-06 12:32:06 -0800 (Mon, 06 Nov 2017)

Log Message

Uncaught Exception: TypeError: null is not an object (evaluating 'mimeType.endsWith')
https://bugs.webkit.org/show_bug.cgi?id=179325
<rdar://problem/35366896>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2017-11-06
Reviewed by Brian Burg.

Source/WebInspectorUI:

* UserInterface/Base/MIMETypeUtilities.js:
(WI.fileExtensionForMIMEType):
(WI.shouldTreatMIMETypeAsText):
Handle null mime types.

LayoutTests:

* inspector/unit-tests/mimetype-utilities-expected.txt:
* inspector/unit-tests/mimetype-utilities.html:
Add tests for null cases.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224506 => 224507)


--- trunk/LayoutTests/ChangeLog	2017-11-06 20:22:11 UTC (rev 224506)
+++ trunk/LayoutTests/ChangeLog	2017-11-06 20:32:06 UTC (rev 224507)
@@ -1,3 +1,15 @@
+2017-11-06  Joseph Pecoraro  <pecor...@apple.com>
+
+        Uncaught Exception: TypeError: null is not an object (evaluating 'mimeType.endsWith')
+        https://bugs.webkit.org/show_bug.cgi?id=179325
+        <rdar://problem/35366896>
+
+        Reviewed by Brian Burg.
+
+        * inspector/unit-tests/mimetype-utilities-expected.txt:
+        * inspector/unit-tests/mimetype-utilities.html:
+        Add tests for null cases.
+
 2017-11-06  Colin Bendell  <co...@bendell.ca>
 
         Add tests to ensure that <source> tags are only preloaded when the `type`

Modified: trunk/LayoutTests/inspector/unit-tests/mimetype-utilities-expected.txt (224506 => 224507)


--- trunk/LayoutTests/inspector/unit-tests/mimetype-utilities-expected.txt	2017-11-06 20:22:11 UTC (rev 224506)
+++ trunk/LayoutTests/inspector/unit-tests/mimetype-utilities-expected.txt	2017-11-06 20:32:06 UTC (rev 224507)
@@ -1,6 +1,7 @@
 
 == Running test suite: MIMETypeUtilities
 -- Running test case: fileExtensionForURL
+PASS: File extension for null URL should be null.
 PASS: File extension for invalid URL should be null.
 PASS: File extension for URL without last path component should be null.
 PASS: File extension for URL without last path component should be null.
@@ -14,6 +15,7 @@
 PASS: File extension for "script.min.js" should be "js".
 
 -- Running test case: fileExtensionForMIMEType
+PASS: File extension for null mime type should be null.
 PASS: File extension for invalid mime type should be null.
 PASS: File extension for unknown mime type should be null.
 PASS: File extension for "image/jpeg" should be "jpg".

Modified: trunk/LayoutTests/inspector/unit-tests/mimetype-utilities.html (224506 => 224507)


--- trunk/LayoutTests/inspector/unit-tests/mimetype-utilities.html	2017-11-06 20:22:11 UTC (rev 224506)
+++ trunk/LayoutTests/inspector/unit-tests/mimetype-utilities.html	2017-11-06 20:32:06 UTC (rev 224507)
@@ -10,6 +10,7 @@
     suite.addTestCase({
         name: "fileExtensionForURL",
         test() {
+            InspectorTest.expectEqual(WI.fileExtensionForURL(null), null, `File extension for null URL should be null.`);
             InspectorTest.expectEqual(WI.fileExtensionForURL("invalid-url"), null, `File extension for invalid URL should be null.`);
             InspectorTest.expectEqual(WI.fileExtensionForURL("https://example.com"), null, `File extension for URL without last path component should be null.`);
             InspectorTest.expectEqual(WI.fileExtensionForURL("https://example.com/"), null, `File extension for URL without last path component should be null.`);
@@ -31,6 +32,7 @@
     suite.addTestCase({
         name: "fileExtensionForMIMEType",
         test() {
+            InspectorTest.expectEqual(WI.fileExtensionForMIMEType(null), null, `File extension for null mime type should be null.`);
             InspectorTest.expectEqual(WI.fileExtensionForMIMEType("invalid-mimetype"), null, `File extension for invalid mime type should be null.`);
             InspectorTest.expectEqual(WI.fileExtensionForMIMEType("application/unknown"), null, `File extension for unknown mime type should be null.`);
 

Modified: trunk/Source/WebInspectorUI/ChangeLog (224506 => 224507)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-11-06 20:22:11 UTC (rev 224506)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-11-06 20:32:06 UTC (rev 224507)
@@ -1,5 +1,18 @@
 2017-11-06  Joseph Pecoraro  <pecor...@apple.com>
 
+        Uncaught Exception: TypeError: null is not an object (evaluating 'mimeType.endsWith')
+        https://bugs.webkit.org/show_bug.cgi?id=179325
+        <rdar://problem/35366896>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Base/MIMETypeUtilities.js:
+        (WI.fileExtensionForMIMEType):
+        (WI.shouldTreatMIMETypeAsText):
+        Handle null mime types.
+
+2017-11-06  Joseph Pecoraro  <pecor...@apple.com>
+
         Web Inspector: Selecting a DOM Search Result in Search Tab unexpectedly changes Tabs
         https://bugs.webkit.org/show_bug.cgi?id=179223
         <rdar://problem/33949556>

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/MIMETypeUtilities.js (224506 => 224507)


--- trunk/Source/WebInspectorUI/UserInterface/Base/MIMETypeUtilities.js	2017-11-06 20:22:11 UTC (rev 224506)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/MIMETypeUtilities.js	2017-11-06 20:32:06 UTC (rev 224507)
@@ -84,6 +84,9 @@
 
 WI.fileExtensionForMIMEType = function(mimeType)
 {
+    if (!mimeType)
+        return null;
+
     const mimeTypeToExtension = {
         // Document types.
         "text/html": "html",
@@ -134,6 +137,9 @@
 
 WI.shouldTreatMIMETypeAsText = function(mimeType)
 {
+    if (!mimeType)
+        return false;
+
     if (mimeType.startsWith("text/"))
         return true;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to