Changeset 239343 in webkit


Ignore:
Timestamp:
Dec 18, 2018 11:18:44 AM (5 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: m3u8 content not shown, it should be text
https://bugs.webkit.org/show_bug.cgi?id=192731
<rdar://problem/46747728>

Reviewed by Devin Rousso.

Source/WebCore:

  • inspector/NetworkResourcesData.cpp:

(WebCore::NetworkResourcesData::setResourceContent):
Don't clobber data if setting empty content on a resource that has content.

  • inspector/agents/InspectorNetworkAgent.cpp:

(WebCore::InspectorNetworkAgent::shouldTreatAsText):
Additional non-"text/" mime types that can be treated as text.

  • platform/MIMETypeRegistry.cpp:

(WebCore::MIMETypeRegistry::isTextMediaPlaylistMIMEType):

  • platform/MIMETypeRegistry.h:

Detect media playlist mime types that are text (m3u8/m3u).

Source/WebInspectorUI:

  • UserInterface/Base/MIMETypeUtilities.js:

(WI.shouldTreatMIMETypeAsText):
Support m3u8/m3u files as text.

LayoutTests:

  • inspector/unit-tests/mimetype-utilities-expected.txt:
  • inspector/unit-tests/mimetype-utilities.html:

Tests for shouldTreatMIMETypeAsText.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r239342 r239343  
     12018-12-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: m3u8 content not shown, it should be text
     4        https://bugs.webkit.org/show_bug.cgi?id=192731
     5        <rdar://problem/46747728>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * inspector/unit-tests/mimetype-utilities-expected.txt:
     10        * inspector/unit-tests/mimetype-utilities.html:
     11        Tests for shouldTreatMIMETypeAsText.
     12
    1132018-12-18  Daniel Bates  <dabates@apple.com>
    214
  • trunk/LayoutTests/inspector/unit-tests/mimetype-utilities-expected.txt

    r224507 r239343  
    2929PASS: File extension for "text/foo+xml" should be "xml".
    3030
     31-- Running test case: shouldTreatMIMETypeAsText
     32PASS: null mime type should not be treated as text.
     33PASS: "application/unknown" should not be treated as text.
     34PASS: "text/plain" should be treated as text.
     35PASS: "text/javascript" should be treated as text.
     36PASS: "application/json" should be treated as text.
     37PASS: "application/vnd.api+json" should be treated as text.
     38PASS: "application/vnd.apple.mpegurl" should be treated as text.
     39PASS: "image/svg+xml" should be treated as text.
     40PASS: "text/x-coffeescript" should be treated as text.
     41PASS: "image/jpeg" should not be treated as text.
     42PASS: "image/png" should not be treated as text.
     43PASS: "image/gif" should not be treated as text.
     44PASS: "font/woff" should not be treated as text.
     45PASS: "video/mpeg" should not be treated as text.
     46PASS: "audio/ogg" should not be treated as text.
     47PASS: "application/pdf" should not be treated as text.
     48
  • trunk/LayoutTests/inspector/unit-tests/mimetype-utilities.html

    r224507 r239343  
    5252    });
    5353
     54    suite.addTestCase({
     55        name: "shouldTreatMIMETypeAsText",
     56        test() {
     57            function expectText(mimeType) {
     58                InspectorTest.expectTrue(WI.shouldTreatMIMETypeAsText(mimeType), `"${mimeType}" should be treated as text.`);
     59            }
     60            function expectNotText(mimeType) {
     61                InspectorTest.expectFalse(WI.shouldTreatMIMETypeAsText(mimeType), `"${mimeType}" should not be treated as text.`);
     62            }
     63
     64            InspectorTest.expectFalse(WI.shouldTreatMIMETypeAsText(null), `null mime type should not be treated as text.`);
     65            expectNotText("application/unknown");
     66
     67            expectText("text/plain");
     68            expectText("text/javascript");
     69            expectText("application/json");
     70            expectText("application/vnd.api+json");
     71            expectText("application/vnd.apple.mpegurl");
     72            expectText("image/svg+xml");
     73            expectText("text/x-coffeescript");
     74
     75            expectNotText("image/jpeg");
     76            expectNotText("image/png");
     77            expectNotText("image/gif");
     78            expectNotText("font/woff");
     79            expectNotText("video/mpeg");
     80            expectNotText("audio/ogg");
     81            expectNotText("application/pdf");
     82
     83            return true;
     84        }
     85    })
     86
    5487    suite.runTestCasesAndFinish();
    5588}
  • trunk/Source/WebCore/ChangeLog

    r239342 r239343  
     12018-12-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: m3u8 content not shown, it should be text
     4        https://bugs.webkit.org/show_bug.cgi?id=192731
     5        <rdar://problem/46747728>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * inspector/NetworkResourcesData.cpp:
     10        (WebCore::NetworkResourcesData::setResourceContent):
     11        Don't clobber data if setting empty content on a resource that has content.
     12
     13        * inspector/agents/InspectorNetworkAgent.cpp:
     14        (WebCore::InspectorNetworkAgent::shouldTreatAsText):
     15        Additional non-"text/" mime types that can be treated as text.
     16
     17        * platform/MIMETypeRegistry.cpp:
     18        (WebCore::MIMETypeRegistry::isTextMediaPlaylistMIMEType):
     19        * platform/MIMETypeRegistry.h:
     20        Detect media playlist mime types that are text (m3u8/m3u).
     21
    1222018-12-18  Daniel Bates  <dabates@apple.com>
    223
  • trunk/Source/WebCore/inspector/NetworkResourcesData.cpp

    r238122 r239343  
    188188void NetworkResourcesData::setResourceContent(const String& requestId, const String& content, bool base64Encoded)
    189189{
     190    if (content.isNull())
     191        return;
     192
    190193    ResourceData* resourceData = resourceDataForRequestId(requestId);
    191194    if (!resourceData)
  • trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp

    r238771 r239343  
    979979        || MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType)
    980980        || MIMETypeRegistry::isSupportedJSONMIMEType(mimeType)
    981         || MIMETypeRegistry::isXMLMIMEType(mimeType);
     981        || MIMETypeRegistry::isXMLMIMEType(mimeType)
     982        || MIMETypeRegistry::isTextMediaPlaylistMIMEType(mimeType);
    982983}
    983984
  • trunk/Source/WebCore/platform/MIMETypeRegistry.cpp

    r238015 r239343  
    498498        || equalLettersIgnoringASCIICase(subtype, "ttf")
    499499        || equalLettersIgnoringASCIICase(subtype, "sfnt");
     500}
     501
     502bool MIMETypeRegistry::isTextMediaPlaylistMIMEType(const String& mimeType)
     503{
     504    if (startsWithLettersIgnoringASCIICase(mimeType, "application/")) {
     505        static const unsigned applicationLength = 12;
     506        auto subtype = StringView { mimeType }.substring(applicationLength);
     507        return equalLettersIgnoringASCIICase(subtype, "vnd.apple.mpegurl")
     508            || equalLettersIgnoringASCIICase(subtype, "mpegurl")
     509            || equalLettersIgnoringASCIICase(subtype, "x-mpegurl");
     510    }
     511
     512    if (startsWithLettersIgnoringASCIICase(mimeType, "audio/")) {
     513        static const unsigned audioLength = 6;
     514        auto subtype = StringView { mimeType }.substring(audioLength);
     515        return equalLettersIgnoringASCIICase(subtype, "mpegurl")
     516            || equalLettersIgnoringASCIICase(subtype, "x-mpegurl");
     517    }
     518
     519    return false;
    500520}
    501521
  • trunk/Source/WebCore/platform/MIMETypeRegistry.h

    r238015 r239343  
    6363    // Check to see if a MIME type is suitable for being loaded as a font.
    6464    static bool isSupportedFontMIMEType(const String& mimeType);
     65
     66    // Check to see if a MIME type is a text media playlist type, such as an m3u8.
     67    static bool isTextMediaPlaylistMIMEType(const String& mimeType);
    6568
    6669    // Check to see if a non-image MIME type is suitable for being loaded as a
  • trunk/Source/WebInspectorUI/ChangeLog

    r239312 r239343  
     12018-12-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: m3u8 content not shown, it should be text
     4        https://bugs.webkit.org/show_bug.cgi?id=192731
     5        <rdar://problem/46747728>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * UserInterface/Base/MIMETypeUtilities.js:
     10        (WI.shouldTreatMIMETypeAsText):
     11        Support m3u8/m3u files as text.
     12
    1132018-12-17  Devin Rousso  <drousso@apple.com>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Base/MIMETypeUtilities.js

    r239037 r239343  
    316316        return true;
    317317
     318    // Various media text mime types.
     319    let extension = WI.fileExtensionForMIMEType(mimeType);
     320    if (extension === "m3u8" || extension === "m3u")
     321        return true;
     322
    318323    // Various script and JSON mime types.
     324    if (extension === "js" || extension === "json")
     325        return true;
    319326    if (mimeType.startsWith("application/"))
    320327        return mimeType.endsWith("script") || mimeType.endsWith("json");
  • trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js

    r226153 r239343  
    113113
    114114    expectThat(actual, message)
     115    {
     116        this._expect(TestHarness.ExpectationType.True, !!actual, message, actual);
     117    }
     118
     119    expectTrue(actual, message)
    115120    {
    116121        this._expect(TestHarness.ExpectationType.True, !!actual, message, actual);
Note: See TracChangeset for help on using the changeset viewer.