WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
bug-176585-20170908095433.patch (text/plain), 28.01 KB, created by
Frédéric Wang Nélar
on 2017-09-08 00:54:35 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Frédéric Wang Nélar
Created:
2017-09-08 00:54:35 PDT
Size:
28.01 KB
patch
obsolete
>Subversion Revision: 221779 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 3b11c7b81d701e6afb2eb948ef456d38d4066fe8..44b829d60bb63ad6b612109a51e7d1a2bd24dc5a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2017-09-08 Frederic Wang <fwang@igalia.com> >+ >+ Use RenderLayerBacking::renderer() when possible >+ https://bugs.webkit.org/show_bug.cgi?id=176585 >+ >+ The private member renderer() is a shorthand for m_owningLayer.renderer(). This patch uses >+ it in RenderLayerBacking when possible. >+ >+ Reviewed by Carlos Garcia Campos. >+ >+ No new tests, behavior not changed. >+ >+ * rendering/RenderLayerBacking.cpp: >+ (WebCore::RenderLayerBacking::updateGeometry): >+ (WebCore::RenderLayerBacking::setContentsNeedDisplay): >+ (WebCore::RenderLayerBacking::setContentsNeedDisplayInRect): >+ >+2017-09-07 Joseph Pecoraro <pecoraro@apple.com> >+ >+ 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> >+ >+ Reviewed by Ryosuke Niwa. >+ >+ * 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. >+ > 2017-09-07 Andy Estes <aestes@apple.com> > > [Mac] Upstream QTKit-related WebKitSystemInterface functions >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index fb28b5dc5991d876b8612c0a81dc9572e2a1304f..88730311c70f9d13c1c84e4910cc4bc62e860b4f 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,18 @@ >+2017-09-07 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK][WPE] UI process crash in WebBackForwardList::restoreFromState >+ https://bugs.webkit.org/show_bug.cgi?id=176303 >+ >+ Reviewed by Michael Catanzaro. >+ >+ Ensure the current index provided by the session state is not out of actual item list bounds. This is a bug in >+ the session state decoder, but WebBackForwardList::backForwardListState() is already doing the check and using >+ the last item index instead, so it's not easy to know where the actual problem is. In any case we should >+ still protect the decoder. >+ >+ * UIProcess/API/glib/WebKitWebViewSessionState.cpp: >+ (decodeSessionState): >+ > 2017-09-07 Andy Estes <aestes@apple.com> > > [Mac] Upstream QTKit-related WebKitSystemInterface functions >diff --git a/Source/WebCore/platform/MIMETypeRegistry.cpp b/Source/WebCore/platform/MIMETypeRegistry.cpp >index a2a4d038d5d8e6b4ab5e14925cf46ca5a8933a6e..97d9ef2d6ee7f468d26b5cc193162081b57f31d0 100644 >--- a/Source/WebCore/platform/MIMETypeRegistry.cpp >+++ b/Source/WebCore/platform/MIMETypeRegistry.cpp >@@ -102,7 +102,7 @@ static void initializeSupportedImageMIMETypes() > // These were removed for <rdar://problem/6564538> Re-enable UTI code in WebCore now that MobileCoreServices exists > // But Mail relies on at least image/tif reported as being supported (should be image/tiff). > // This can be removed when Mail addresses: >- // <rdar://problem/7879510> Mail should use standard image mimetypes >+ // <rdar://problem/7879510> Mail should use standard image mimetypes > // and we fix sniffing so that it corrects items such as image/jpg -> image/jpeg. > static const char* const malformedMIMETypes[] = { > // JPEG (image/jpeg) >@@ -639,6 +639,9 @@ bool MIMETypeRegistry::canShowMIMEType(const String& mimeType) > if (isSupportedImageMIMEType(mimeType) || isSupportedNonImageMIMEType(mimeType) || isSupportedMediaMIMEType(mimeType)) > return true; > >+ if (isSupportedJavaScriptMIMEType(mimeType) || isSupportedJSONMIMEType(mimeType)) >+ return true; >+ > if (mimeType.startsWith("text/", false)) > return !isUnsupportedTextMIMEType(mimeType); > >diff --git a/Source/WebCore/platform/MIMETypeRegistry.h b/Source/WebCore/platform/MIMETypeRegistry.h >index 0664a48cc869f8d57c901f4c13678302add46ce6..a686f30d95e2959e3ba080c3cca81be1f2749ab8 100644 >--- a/Source/WebCore/platform/MIMETypeRegistry.h >+++ b/Source/WebCore/platform/MIMETypeRegistry.h >@@ -58,8 +58,8 @@ public: > static bool isSupportedImageMIMETypeForEncoding(const String& mimeType); > > // Check to see if a MIME type is suitable for being loaded as a JavaScript or JSON resource. >- static bool isSupportedJavaScriptMIMEType(const String& mimeType); >- static bool isSupportedJSONMIMEType(const String& mimeType); >+ WEBCORE_EXPORT static bool isSupportedJavaScriptMIMEType(const String& mimeType); >+ WEBCORE_EXPORT static bool isSupportedJSONMIMEType(const String& mimeType); > > // Check to see if a MIME type is suitable for being loaded as a style sheet. > static bool isSupportedStyleSheetMIMEType(const String& mimeType); >@@ -68,7 +68,7 @@ public: > static bool isSupportedFontMIMEType(const String& mimeType); > > // Check to see if a non-image MIME type is suitable for being loaded as a >- // document in a frame. Includes supported JavaScript MIME types. >+ // document in a frame. Does not include supported JavaScript and JSON MIME types. > WEBCORE_EXPORT static bool isSupportedNonImageMIMEType(const String& mimeType); > > // Check to see if a MIME type is suitable for being loaded using <video> and <audio>. >@@ -88,9 +88,10 @@ public: > static bool isPDFMIMEType(const String& mimeType); > > // Check to see if a MIME type is suitable for being shown inside a page. >- // Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(), or >- // isSupportedMediaMIMEType() returns true or if the given MIME type begins with >- // "text/" and isUnsupportedTextMIMEType() returns false. >+ // Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(), >+ // isSupportedMediaMIMEType(), isSupportedJavaScriptMIMEType(), isSupportedJSONMIMEType(), >+ // returns true or if the given MIME type begins with "text/" and >+ // isUnsupportedTextMIMEType() returns false. > WEBCORE_EXPORT static bool canShowMIMEType(const String& mimeType); > > // Check to see if a MIME type is one where an XML document should be created >diff --git a/Source/WebCore/rendering/RenderLayerBacking.cpp b/Source/WebCore/rendering/RenderLayerBacking.cpp >index 3fa7540a13f511695c73fb4a0aa789ef5ba19235..a6e7df2e033137afa90fa43fec155304ca96d5d3 100644 >--- a/Source/WebCore/rendering/RenderLayerBacking.cpp >+++ b/Source/WebCore/rendering/RenderLayerBacking.cpp >@@ -1052,7 +1052,7 @@ void RenderLayerBacking::updateGeometry() > if (m_maskLayer) > updateMaskingLayerGeometry(); > >- if (m_owningLayer.renderer().hasTransformRelatedProperty()) { >+ if (renderer().hasTransformRelatedProperty()) { > // Update properties that depend on layer dimensions. > FloatPoint3D transformOrigin = computeTransformOriginForPainting(downcast<RenderBox>(renderer()).borderBoxRect()); > FloatPoint layerOffset = roundPointToDevicePixels(toLayoutPoint(rendererOffset.fromParentGraphicsLayer()), deviceScaleFactor()); >@@ -2433,7 +2433,7 @@ void RenderLayerBacking::setContentsNeedDisplay(GraphicsLayer::ShouldClipToLayer > { > ASSERT(!paintsIntoCompositedAncestor()); > >- FrameView& frameView = owningLayer().renderer().view().frameView(); >+ FrameView& frameView = renderer().view().frameView(); > if (m_isMainFrameRenderViewLayer && frameView.isTrackingRepaints()) > frameView.addTrackedRepaintRect(owningLayer().absoluteBoundingBoxForPainting()); > >@@ -2468,7 +2468,7 @@ void RenderLayerBacking::setContentsNeedDisplayInRect(const LayoutRect& r, Graph > ASSERT(!paintsIntoCompositedAncestor()); > > FloatRect pixelSnappedRectForPainting = snapRectToDevicePixels(r, deviceScaleFactor()); >- FrameView& frameView = owningLayer().renderer().view().frameView(); >+ FrameView& frameView = renderer().view().frameView(); > if (m_isMainFrameRenderViewLayer && frameView.isTrackingRepaints()) > frameView.addTrackedRepaintRect(pixelSnappedRectForPainting); > >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebViewSessionState.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebViewSessionState.cpp >index 4bea267dbc2a98b07826d78826687c59cae9efc5..9cb5d9335505a838b9049e446803e41429bcb820 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitWebViewSessionState.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebViewSessionState.cpp >@@ -369,7 +369,7 @@ static bool decodeSessionState(GBytes* data, SessionState& sessionState) > decodeBackForwardListItemState(backForwardListStateIter.get(), sessionState.backForwardListState); > > if (hasCurrentIndex) >- sessionState.backForwardListState.currentIndex = currentIndex; >+ sessionState.backForwardListState.currentIndex = std::min<uint32_t>(currentIndex, sessionState.backForwardListState.items.size() - 1); > return true; > } > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 07c2a52c3206f783b8e59286d3f2f404450dd800..f6590a03a26142da9b7eb309747528a796d08d3c 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,30 @@ >+2017-09-07 Joseph Pecoraro <pecoraro@apple.com> >+ >+ 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> >+ >+ Reviewed by Ryosuke Niwa. >+ >+ * 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. >+ > 2017-09-07 Matthew Stewart <matthew_r_stewart@apple.com> > > Add Live PLT implemented with WebDriver >diff --git a/Tools/TestWebKitAPI/PlatformGTK.cmake b/Tools/TestWebKitAPI/PlatformGTK.cmake >index 1be3dd5287fb5f9340cf9c1afe88a3913874d56e..510c1c368638ef87ac33427c98855243cd1323df 100644 >--- a/Tools/TestWebKitAPI/PlatformGTK.cmake >+++ b/Tools/TestWebKitAPI/PlatformGTK.cmake >@@ -136,6 +136,7 @@ add_executable(TestWebCore > ${TESTWEBKITAPI_DIR}/Tests/WebCore/GridPosition.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp >+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/MIMETypeRegistry.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/SecurityOrigin.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp >diff --git a/Tools/TestWebKitAPI/PlatformWPE.cmake b/Tools/TestWebKitAPI/PlatformWPE.cmake >index 118cd12ee730eaab3462a3847d65c4812104d1db..ad582436b5a3df5de05792b136638296341116af 100644 >--- a/Tools/TestWebKitAPI/PlatformWPE.cmake >+++ b/Tools/TestWebKitAPI/PlatformWPE.cmake >@@ -45,6 +45,7 @@ add_executable(TestWebCore > ${TESTWEBKITAPI_DIR}/TestsController.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp >+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/MIMETypeRegistry.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBufferTest.cpp >diff --git a/Tools/TestWebKitAPI/PlatformWin.cmake b/Tools/TestWebKitAPI/PlatformWin.cmake >index 6ab56ffd3e210f501cb5d9f161b5fac58cbaed54..e2ca32651fde5780a2fcf51b8bc0c8e6844c3c64 100644 >--- a/Tools/TestWebKitAPI/PlatformWin.cmake >+++ b/Tools/TestWebKitAPI/PlatformWin.cmake >@@ -57,6 +57,7 @@ set(TestWebCoreLib_SOURCES > ${TESTWEBKITAPI_DIR}/Tests/WebCore/IntPoint.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/IntSize.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp >+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/MIMETypeRegistry.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/ParsedContentRange.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/SecurityOrigin.cpp > ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 558e1efacf723b0d93ffd550d3d710b088d4509a..ccc3c3be738803c4251dbd6ee0452357c9ba1394 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -569,6 +569,8 @@ > A57D54F31F338C3600A97AA7 /* NeverDestroyed.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57D54F21F338C3600A97AA7 /* NeverDestroyed.cpp */; }; > A57D54F61F3395D000A97AA7 /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57D54F41F3395D000A97AA7 /* Logger.cpp */; }; > A57D54F91F3397B400A97AA7 /* LifecycleLogger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57D54F71F3397B400A97AA7 /* LifecycleLogger.cpp */; }; >+ A5A729F11F622AA700DE5A28 /* WKNavigationResponse.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5A729F01F622A9A00DE5A28 /* WKNavigationResponse.mm */; }; >+ A5B149DE1F5A19EA00C6DAFF /* MIMETypeRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5B149DD1F5A19DC00C6DAFF /* MIMETypeRegistry.cpp */; }; > A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; }; > AD57AC201DA7465000FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD57AC1E1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp */; }; > AD57AC211DA7465B00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD57AC1F1DA7464D00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp */; }; >@@ -1512,6 +1514,8 @@ > A57D54F51F3395D000A97AA7 /* Logger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Logger.h; sourceTree = "<group>"; }; > A57D54F71F3397B400A97AA7 /* LifecycleLogger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LifecycleLogger.cpp; sourceTree = "<group>"; }; > A57D54F81F3397B400A97AA7 /* LifecycleLogger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LifecycleLogger.h; sourceTree = "<group>"; }; >+ A5A729F01F622A9A00DE5A28 /* WKNavigationResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNavigationResponse.mm; sourceTree = "<group>"; }; >+ A5B149DD1F5A19DC00C6DAFF /* MIMETypeRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MIMETypeRegistry.cpp; sourceTree = "<group>"; }; > A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WindowlessWebViewWithMedia.html; sourceTree = "<group>"; }; > A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowlessWebViewWithMedia.mm; sourceTree = "<group>"; }; > A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CheckedArithmeticOperations.cpp; sourceTree = "<group>"; }; >@@ -1990,6 +1994,7 @@ > 2D838B1E1EEF3A5B009B980E /* WKContentViewEditingActions.mm */, > 370CE2291F57343400E7410B /* WKContentViewTargetForAction.mm */, > 51D124971E763AF8002B2820 /* WKHTTPCookieStore.mm */, >+ A5A729F01F622A9A00DE5A28 /* WKNavigationResponse.mm */, > 375E0E151D66674400EFEC2C /* WKNSNumber.mm */, > 37B47E2E1D64E7CA005F4EFF /* WKObject.mm */, > A14AAB611E78D7DE00C1ADC2 /* WKPDFView.mm */, >@@ -2067,6 +2072,7 @@ > 7A909A751D877475007E10F8 /* IntSize.cpp */, > 14464012167A8305000BD218 /* LayoutUnit.cpp */, > 076E507E1F45031E006E9F5A /* Logging.cpp */, >+ A5B149DD1F5A19DC00C6DAFF /* MIMETypeRegistry.cpp */, > CD225C071C45A69200140761 /* ParsedContentRange.cpp */, > CDCFA7A91E45122F00C2433D /* SampleMap.cpp */, > CE06DF9A1E1851F200E570C9 /* SecurityOrigin.cpp */, >@@ -3264,6 +3270,7 @@ > 5C0BF88D1DD5964D00B00328 /* MemoryPressureHandler.mm in Sources */, > 7C83E0B71D0A64B800FEBCF3 /* MenuTypesForMouseEvents.cpp in Sources */, > 5C0BF8941DD599C900B00328 /* MenuTypesForMouseEvents.mm in Sources */, >+ A5B149DE1F5A19EA00C6DAFF /* MIMETypeRegistry.cpp in Sources */, > 51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */, > 7C83E0B61D0A64B300FEBCF3 /* ModalAlertsSPI.cpp in Sources */, > 7CCE7F011A411AE600447C4C /* MouseMoveAfterCrash.cpp in Sources */, >@@ -3400,6 +3407,7 @@ > 370CE22A1F57343400E7410B /* WKContentViewTargetForAction.mm in Sources */, > 51D124981E763B02002B2820 /* WKHTTPCookieStore.mm in Sources */, > 7CCE7F1D1A411AE600447C4C /* WKImageCreateCGImageCrash.cpp in Sources */, >+ A5A729F11F622AA700DE5A28 /* WKNavigationResponse.mm in Sources */, > 375E0E171D66674400EFEC2C /* WKNSNumber.mm in Sources */, > 37B47E301D64E7CA005F4EFF /* WKObject.mm in Sources */, > 7C89D2AC1A69B80D003A5FDE /* WKPageConfiguration.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/MIMETypeRegistry.cpp b/Tools/TestWebKitAPI/Tests/WebCore/MIMETypeRegistry.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..65307dd30b5b53a129c1f80fe7a6ec29b67a2d5d >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebCore/MIMETypeRegistry.cpp >@@ -0,0 +1,83 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#include <WebCore/MIMETypeRegistry.h> >+ >+using namespace WebCore; >+ >+namespace TestWebKitAPI { >+ >+TEST(MIMETypeRegistry, JSONMIMETypes) >+{ >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJSONMIMEType("application/json")); >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJSONMIMEType("APPLICATION/JSON")); >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJSONMIMEType("application/vnd.api+json")); >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJSONMIMEType("anything/something+json")); >+ >+ ASSERT_FALSE(MIMETypeRegistry::isSupportedJSONMIMEType("text/plain")); >+ ASSERT_FALSE(MIMETypeRegistry::isSupportedJSONMIMEType("text/json")); >+ ASSERT_FALSE(MIMETypeRegistry::isSupportedJSONMIMEType("text/javascript")); >+} >+ >+TEST(MIMETypeRegistry, JavaScriptMIMETypes) >+{ >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("text/javascript")); >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("TEXT/JAVASCRIPT")); >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("application/javascript")); >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("application/ecmascript")); >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("application/x-javascript")); >+ ASSERT_TRUE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("application/x-ecmascript")); >+ >+ ASSERT_FALSE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("text/plain")); >+ ASSERT_FALSE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("application/json")); >+ ASSERT_FALSE(MIMETypeRegistry::isSupportedJavaScriptMIMEType("foo/javascript")); >+} >+ >+TEST(MIMETypeRegistry, CanShowMIMEType) >+{ >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("text/plain")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("text/html")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("text/xml")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("text/foo")); >+ >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("application/json")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("APPLICATION/JSON")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("application/vnd.api+json")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("anything/something+json")); >+ >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("text/javascript")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("TEXT/JAVASCRIPT")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("application/javascript")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("application/ecmascript")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("application/x-javascript")); >+ ASSERT_TRUE(MIMETypeRegistry::canShowMIMEType("application/x-ecmascript")); >+ >+ ASSERT_FALSE(MIMETypeRegistry::canShowMIMEType("foo/bar")); >+ ASSERT_FALSE(MIMETypeRegistry::canShowMIMEType("text/vcard")); >+} >+ >+} // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..995ed86cd7b8be334fbcacfe169eeb59a713e71b >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm >@@ -0,0 +1,127 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+ >+#if WK_API_ENABLED >+ >+#import "Utilities.h" >+#import <WebKit/WebKit.h> >+#import <wtf/RetainPtr.h> >+ >+static bool isDone; >+ >+@interface WKNavigationResponseTestNavigationDelegate : NSObject <WKNavigationDelegate> >+@property (nonatomic) BOOL expectation; >+@end >+ >+@implementation WKNavigationResponseTestNavigationDelegate >+ >+- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler >+{ >+ EXPECT_EQ(navigationResponse.canShowMIMEType, self.expectation); >+ decisionHandler(WKNavigationResponsePolicyAllow); >+} >+ >+- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation >+{ >+ isDone = true; >+} >+ >+@end >+ >+@interface WKNavigationResponseTestSchemeHandler : NSObject <WKURLSchemeHandler> >+@property (nonatomic, copy) NSString *mimeType; >+@end >+ >+@implementation WKNavigationResponseTestSchemeHandler >+ >+- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task >+{ >+ RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:[NSURL URLWithString:@"test:///json-response"] MIMEType:self.mimeType expectedContentLength:1 textEncodingName:nil]); >+ [task didReceiveResponse:response.get()]; >+ [task didReceiveData:[@"{\"data\":1234}" dataUsingEncoding:NSUTF8StringEncoding]]; >+ [task didFinish]; >+} >+ >+- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask { } >+ >+@end >+ >+TEST(WebKit, WKNavigationResponseJSONMIMEType) >+{ >+ isDone = false; >+ auto schemeHandler = adoptNS([[WKNavigationResponseTestSchemeHandler alloc] init]); >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ [configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"test"]; >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]); >+ auto navigationDelegate = adoptNS([[WKNavigationResponseTestNavigationDelegate alloc] init]); >+ webView.get().navigationDelegate = navigationDelegate.get(); >+ >+ schemeHandler.get().mimeType = @"application/json"; >+ navigationDelegate.get().expectation = YES; >+ >+ NSURL *testURL = [NSURL URLWithString:@"test:///json-response"]; >+ [webView loadRequest:[NSURLRequest requestWithURL:testURL]]; >+ TestWebKitAPI::Util::run(&isDone); >+} >+ >+TEST(WebKit, WKNavigationResponseJSONMIMEType2) >+{ >+ isDone = false; >+ auto schemeHandler = adoptNS([[WKNavigationResponseTestSchemeHandler alloc] init]); >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ [configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"test"]; >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]); >+ auto navigationDelegate = adoptNS([[WKNavigationResponseTestNavigationDelegate alloc] init]); >+ webView.get().navigationDelegate = navigationDelegate.get(); >+ >+ schemeHandler.get().mimeType = @"application/vnd.api+json"; >+ navigationDelegate.get().expectation = YES; >+ >+ NSURL *testURL = [NSURL URLWithString:@"test:///json-response"]; >+ [webView loadRequest:[NSURLRequest requestWithURL:testURL]]; >+ TestWebKitAPI::Util::run(&isDone); >+} >+ >+TEST(WebKit, WKNavigationResponseUnknownMIMEType) >+{ >+ isDone = false; >+ auto schemeHandler = adoptNS([[WKNavigationResponseTestSchemeHandler alloc] init]); >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ [configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"test"]; >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]); >+ auto navigationDelegate = adoptNS([[WKNavigationResponseTestNavigationDelegate alloc] init]); >+ webView.get().navigationDelegate = navigationDelegate.get(); >+ >+ schemeHandler.get().mimeType = @"garbage/json"; >+ navigationDelegate.get().expectation = NO; >+ >+ NSURL *testURL = [NSURL URLWithString:@"test:///json-response"]; >+ [webView loadRequest:[NSURLRequest requestWithURL:testURL]]; >+ TestWebKitAPI::Util::run(&isDone); >+} >+ >+#endif // WK_API_ENABLED
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
commit-queue
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 176585
:
320245
|
320248
|
320252