Web Inspector: Uncaught Exception: TypeError: null is not an object (evaluating ...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2020 23:22:14 +0000 (23:22 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2020 23:22:14 +0000 (23:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211593

Reviewed by Joseph Pecoraro.

Source/WebInspectorUI:

* UserInterface/Views/ResourceClusterContentView.js:
(WI.ResourceClusterContentView.prototype._normalizeMIMETypeForDOM):

LayoutTests:

* inspector/unit-tests/mimetype-utilities.html:
* inspector/unit-tests/mimetype-utilities-expected.txt:
Add some tests for `parseMIMEType`.

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

LayoutTests/ChangeLog
LayoutTests/inspector/unit-tests/mimetype-utilities-expected.txt
LayoutTests/inspector/unit-tests/mimetype-utilities.html
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js

index 89c69cd..2275f61 100644 (file)
@@ -1,3 +1,14 @@
+2020-05-07  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Uncaught Exception: TypeError: null is not an object (evaluating 'mimeType.endsWith')
+        https://bugs.webkit.org/show_bug.cgi?id=211593
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/unit-tests/mimetype-utilities.html:
+        * inspector/unit-tests/mimetype-utilities-expected.txt:
+        Add some tests for `parseMIMEType`.
+
 2020-05-07  Eric Carlson  <eric.carlson@apple.com>
 
         Poster set after playback begins should be ignored
index 905cfc3..c36593b 100644 (file)
@@ -1,5 +1,72 @@
 
 == Running test suite: MIMETypeUtilities
+-- Running test case: parseMIMEType
+
+Test null
+PASS: type should be: null
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "a"
+PASS: type should be: "a"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime"
+PASS: type should be: "mime"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime-dash"
+PASS: type should be: "mime-dash"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime/slash"
+PASS: type should be: "mime/slash"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime+plus"
+PASS: type should be: "mime+plus"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime/slash+plus"
+PASS: type should be: "mime/slash+plus"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime/slash ;"
+PASS: type should be: "mime/slash"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime ; semicolon"
+PASS: type should be: "mime"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime/generic ; a = b"
+PASS: type should be: "mime/generic"
+PASS: boundary should be: null
+PASS: encoding should be: null
+
+Test "mime/generic ; boundary = charset"
+PASS: type should be: "mime/generic"
+PASS: boundary should be: "charset"
+PASS: encoding should be: null
+
+Test "mime/generic ; charset = boundary"
+PASS: type should be: "mime/generic"
+PASS: boundary should be: null
+PASS: encoding should be: "boundary"
+
+Test "mime/generic ; boundary = foo ; charset = bar"
+PASS: type should be: "mime/generic"
+PASS: boundary should be: "foo"
+PASS: encoding should be: "bar"
+
 -- Running test case: fileExtensionForFilename
 PASS: File extension for null filename should be null.
 PASS: File extension for filename without a period should be null.
index c181029..619f8c9 100644 (file)
@@ -8,6 +8,112 @@ function test()
     let suite = InspectorTest.createSyncSuite("MIMETypeUtilities");
 
     suite.addTestCase({
+        name: "parseMIMEType",
+        test() {
+            function test(fullMimeType, expected) {
+                InspectorTest.newline();
+                InspectorTest.log(`Test ${JSON.stringify(fullMimeType)}`);
+
+                let {
+                    type: expectedType,
+                    boundary: expectedBoundary,
+                    encoding: expectedEncoding,
+                } = expected;
+
+                let {
+                    type: actualType,
+                    boundary: actualBoundary,
+                    encoding: actualEncoding,
+                } = parseMIMEType(fullMimeType);
+
+                InspectorTest.expectEqual(actualType, expectedType, `type should be: ${JSON.stringify(expectedType)}`);
+                InspectorTest.expectEqual(actualBoundary, expectedBoundary, `boundary should be: ${JSON.stringify(expectedBoundary)}`);
+                InspectorTest.expectEqual(actualEncoding, expectedEncoding, `encoding should be: ${JSON.stringify(expectedEncoding)}`);
+            }
+
+            test(null, {
+                type: null,
+                boundary: null,
+                encoding: null,
+            });
+
+            test("a", {
+                type: "a",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime", {
+                type: "mime",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime-dash", {
+                type: "mime-dash",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime/slash", {
+                type: "mime/slash",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime+plus", {
+                type: "mime+plus",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime/slash+plus", {
+                type: "mime/slash+plus",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime/slash ;", {
+                type: "mime/slash",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime ; semicolon", {
+                type: "mime",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime/generic ; a = b", {
+                type: "mime/generic",
+                boundary: null,
+                encoding: null,
+            });
+
+            test("mime/generic ; boundary = charset", {
+                type: "mime/generic",
+                boundary: "charset",
+                encoding: null,
+            });
+
+            test("mime/generic ; charset = boundary", {
+                type: "mime/generic",
+                boundary: null,
+                encoding: "boundary",
+            });
+
+            test("mime/generic ; boundary = foo ; charset = bar", {
+                type: "mime/generic",
+                boundary: "foo",
+                encoding: "bar",
+            });
+
+            return true;
+        }
+    });
+
+    suite.addTestCase({
         name: "fileExtensionForFilename",
         test() {
             InspectorTest.expectNull(WI.fileExtensionForFilename(null), `File extension for null filename should be null.`);
index 422be83..c73b644 100644 (file)
@@ -1,5 +1,15 @@
 2020-05-07  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Uncaught Exception: TypeError: null is not an object (evaluating 'mimeType.endsWith')
+        https://bugs.webkit.org/show_bug.cgi?id=211593
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/ResourceClusterContentView.js:
+        (WI.ResourceClusterContentView.prototype._normalizeMIMETypeForDOM):
+
+2020-05-07  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Sources: Breakpoints status not remembered/restored correctly
         https://bugs.webkit.org/show_bug.cgi?id=211558
 
index f0bee23..b7fa2a1 100644 (file)
@@ -438,6 +438,9 @@ WI.ResourceClusterContentView = class ResourceClusterContentView extends WI.Clus
     {
         mimeType = parseMIMEType(mimeType).type;
 
+        if (!mimeType)
+            return mimeType;
+
         if (mimeType.endsWith("/html") || mimeType.endsWith("+html"))
             return "text/html";