Changeset 221778 in webkit


Ignore:
Timestamp:
Sep 7, 2017 11:21:29 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

WebKit should claim that it can show responses for a broader range of JSON MIMETypes
https://bugs.webkit.org/show_bug.cgi?id=176252
<rdar://problem/34212885>

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2017-09-07
Reviewed by Ryosuke Niwa.

Source/WebCore:

  • platform/MIMETypeRegistry.h:
  • platform/MIMETypeRegistry.cpp:

(WebCore::MIMETypeRegistry::canShowMIMEType):
Extend this to support JavaScript and JSON MIMETypes that WebKit
knows how to treat as text.

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm: Added.

(-[WKNavigationResponseTestNavigationDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]):
(-[WKNavigationResponseTestNavigationDelegate webView:didCommitNavigation:]):
(-[WKNavigationResponseTestSchemeHandler webView:startURLSchemeTask:]):
(-[WKNavigationResponseTestSchemeHandler webView:stopURLSchemeTask:]):
(TEST):
Test for canShowMIMEType with multiple JSON mime types and a garbage mime type.
Previously canShowMIMEType would have been YES for "application/json" but
NO for "application/vnd.api+json". Now it shows YES for both.

  • TestWebKitAPI/PlatformGTK.cmake:
  • TestWebKitAPI/PlatformWPE.cmake:
  • TestWebKitAPI/PlatformWin.cmake:
  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebCore/MIMETypeRegistry.cpp: Added.

(TestWebKitAPI::TEST):
Tests for MIMETypeRegistry's dynamic JSON mime type detection.

Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r221773 r221778  
     12017-09-07  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        WebKit should claim that it can show responses for a broader range of JSON MIMETypes
     4        https://bugs.webkit.org/show_bug.cgi?id=176252
     5        <rdar://problem/34212885>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * platform/MIMETypeRegistry.h:
     10        * platform/MIMETypeRegistry.cpp:
     11        (WebCore::MIMETypeRegistry::canShowMIMEType):
     12        Extend this to support JavaScript and JSON MIMETypes that WebKit
     13        knows how to treat as text.
     14
    1152017-09-07  Andy Estes  <aestes@apple.com>
    216
  • trunk/Source/WebCore/platform/MIMETypeRegistry.cpp

    r219595 r221778  
    103103    // But Mail relies on at least image/tif reported as being supported (should be image/tiff).
    104104    // This can be removed when Mail addresses:
    105     // <rdar://problem/7879510> Mail should use standard image mimetypes 
     105    // <rdar://problem/7879510> Mail should use standard image mimetypes
    106106    // and we fix sniffing so that it corrects items such as image/jpg -> image/jpeg.
    107107    static const char* const malformedMIMETypes[] = {
     
    638638{
    639639    if (isSupportedImageMIMEType(mimeType) || isSupportedNonImageMIMEType(mimeType) || isSupportedMediaMIMEType(mimeType))
     640        return true;
     641
     642    if (isSupportedJavaScriptMIMEType(mimeType) || isSupportedJSONMIMEType(mimeType))
    640643        return true;
    641644
  • trunk/Source/WebCore/platform/MIMETypeRegistry.h

    r217247 r221778  
    5959
    6060    // Check to see if a MIME type is suitable for being loaded as a JavaScript or JSON resource.
    61     static bool isSupportedJavaScriptMIMEType(const String& mimeType);
    62     static bool isSupportedJSONMIMEType(const String& mimeType);
     61    WEBCORE_EXPORT static bool isSupportedJavaScriptMIMEType(const String& mimeType);
     62    WEBCORE_EXPORT static bool isSupportedJSONMIMEType(const String& mimeType);
    6363
    6464    // Check to see if a MIME type is suitable for being loaded as a style sheet.
     
    6969
    7070    // Check to see if a non-image MIME type is suitable for being loaded as a
    71     // document in a frame. Includes supported JavaScript MIME types.
     71    // document in a frame. Does not include supported JavaScript and JSON MIME types.
    7272    WEBCORE_EXPORT static bool isSupportedNonImageMIMEType(const String& mimeType);
    7373
     
    8989
    9090    // Check to see if a MIME type is suitable for being shown inside a page.
    91     // Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(), or
    92     // isSupportedMediaMIMEType() returns true or if the given MIME type begins with
    93     // "text/" and isUnsupportedTextMIMEType() returns false.
     91    // Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(),
     92    // isSupportedMediaMIMEType(), isSupportedJavaScriptMIMEType(), isSupportedJSONMIMEType(),
     93    // returns true or if the given MIME type begins with "text/" and
     94    // isUnsupportedTextMIMEType() returns false.
    9495    WEBCORE_EXPORT static bool canShowMIMEType(const String& mimeType);
    9596
  • trunk/Tools/ChangeLog

    r221777 r221778  
     12017-09-07  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        WebKit should claim that it can show responses for a broader range of JSON MIMETypes
     4        https://bugs.webkit.org/show_bug.cgi?id=176252
     5        <rdar://problem/34212885>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     10        * TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm: Added.
     11        (-[WKNavigationResponseTestNavigationDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]):
     12        (-[WKNavigationResponseTestNavigationDelegate webView:didCommitNavigation:]):
     13        (-[WKNavigationResponseTestSchemeHandler webView:startURLSchemeTask:]):
     14        (-[WKNavigationResponseTestSchemeHandler webView:stopURLSchemeTask:]):
     15        (TEST):
     16        Test for canShowMIMEType with multiple JSON mime types and a garbage mime type.
     17        Previously canShowMIMEType would have been YES for "application/json" but
     18        NO for "application/vnd.api+json". Now it shows YES for both.
     19
     20        * TestWebKitAPI/PlatformGTK.cmake:
     21        * TestWebKitAPI/PlatformWPE.cmake:
     22        * TestWebKitAPI/PlatformWin.cmake:
     23        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     24        * TestWebKitAPI/Tests/WebCore/MIMETypeRegistry.cpp: Added.
     25        (TestWebKitAPI::TEST):
     26        Tests for MIMETypeRegistry's dynamic JSON mime type detection.
     27
    1282017-09-07  Matthew Stewart  <matthew_r_stewart@apple.com>
    229
  • trunk/Tools/TestWebKitAPI/PlatformGTK.cmake

    r221219 r221778  
    137137    ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
    138138    ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
     139    ${TESTWEBKITAPI_DIR}/Tests/WebCore/MIMETypeRegistry.cpp
    139140    ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
    140141    ${TESTWEBKITAPI_DIR}/Tests/WebCore/SecurityOrigin.cpp
  • trunk/Tools/TestWebKitAPI/PlatformWPE.cmake

    r221069 r221778  
    4646    ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
    4747    ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
     48    ${TESTWEBKITAPI_DIR}/Tests/WebCore/MIMETypeRegistry.cpp
    4849    ${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
    4950    ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
  • trunk/Tools/TestWebKitAPI/PlatformWin.cmake

    r221463 r221778  
    5858    ${TESTWEBKITAPI_DIR}/Tests/WebCore/IntSize.cpp
    5959    ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
     60    ${TESTWEBKITAPI_DIR}/Tests/WebCore/MIMETypeRegistry.cpp
    6061    ${TESTWEBKITAPI_DIR}/Tests/WebCore/ParsedContentRange.cpp
    6162    ${TESTWEBKITAPI_DIR}/Tests/WebCore/SecurityOrigin.cpp
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r221751 r221778  
    570570                A57D54F61F3395D000A97AA7 /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57D54F41F3395D000A97AA7 /* Logger.cpp */; };
    571571                A57D54F91F3397B400A97AA7 /* LifecycleLogger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57D54F71F3397B400A97AA7 /* LifecycleLogger.cpp */; };
     572                A5A729F11F622AA700DE5A28 /* WKNavigationResponse.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5A729F01F622A9A00DE5A28 /* WKNavigationResponse.mm */; };
     573                A5B149DE1F5A19EA00C6DAFF /* MIMETypeRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5B149DD1F5A19DC00C6DAFF /* MIMETypeRegistry.cpp */; };
    572574                A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
    573575                AD57AC201DA7465000FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD57AC1E1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp */; };
     
    15131515                A57D54F71F3397B400A97AA7 /* LifecycleLogger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LifecycleLogger.cpp; sourceTree = "<group>"; };
    15141516                A57D54F81F3397B400A97AA7 /* LifecycleLogger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LifecycleLogger.h; sourceTree = "<group>"; };
     1517                A5A729F01F622A9A00DE5A28 /* WKNavigationResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNavigationResponse.mm; sourceTree = "<group>"; };
     1518                A5B149DD1F5A19DC00C6DAFF /* MIMETypeRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MIMETypeRegistry.cpp; sourceTree = "<group>"; };
    15151519                A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WindowlessWebViewWithMedia.html; sourceTree = "<group>"; };
    15161520                A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowlessWebViewWithMedia.mm; sourceTree = "<group>"; };
     
    19911995                                370CE2291F57343400E7410B /* WKContentViewTargetForAction.mm */,
    19921996                                51D124971E763AF8002B2820 /* WKHTTPCookieStore.mm */,
     1997                                A5A729F01F622A9A00DE5A28 /* WKNavigationResponse.mm */,
    19931998                                375E0E151D66674400EFEC2C /* WKNSNumber.mm */,
    19941999                                37B47E2E1D64E7CA005F4EFF /* WKObject.mm */,
     
    20682073                                14464012167A8305000BD218 /* LayoutUnit.cpp */,
    20692074                                076E507E1F45031E006E9F5A /* Logging.cpp */,
     2075                                A5B149DD1F5A19DC00C6DAFF /* MIMETypeRegistry.cpp */,
    20702076                                CD225C071C45A69200140761 /* ParsedContentRange.cpp */,
    20712077                                CDCFA7A91E45122F00C2433D /* SampleMap.cpp */,
     
    32653271                                7C83E0B71D0A64B800FEBCF3 /* MenuTypesForMouseEvents.cpp in Sources */,
    32663272                                5C0BF8941DD599C900B00328 /* MenuTypesForMouseEvents.mm in Sources */,
     3273                                A5B149DE1F5A19EA00C6DAFF /* MIMETypeRegistry.cpp in Sources */,
    32673274                                51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */,
    32683275                                7C83E0B61D0A64B300FEBCF3 /* ModalAlertsSPI.cpp in Sources */,
     
    34013408                                51D124981E763B02002B2820 /* WKHTTPCookieStore.mm in Sources */,
    34023409                                7CCE7F1D1A411AE600447C4C /* WKImageCreateCGImageCrash.cpp in Sources */,
     3410                                A5A729F11F622AA700DE5A28 /* WKNavigationResponse.mm in Sources */,
    34033411                                375E0E171D66674400EFEC2C /* WKNSNumber.mm in Sources */,
    34043412                                37B47E301D64E7CA005F4EFF /* WKObject.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.