- Revision
- 218278
- Author
- [email protected]
- Date
- 2017-06-14 12:17:22 -0700 (Wed, 14 Jun 2017)
Log Message
WKIconLoadingDelegate never gets asked about the default favicon if touch/touch-precomposed icons are in the <head>
<rdar://problem/32614328> and https://bugs.webkit.org/show_bug.cgi?id=173376
Reviewed by Alex Christensen.
Source/WebCore:
Covered by new API test
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startIconLoading): Previously we applied the default favicon if the set of LinkIcons was empty.
Now, apply the default favicon if the set of LinkIcons contains no explicit favicon.
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm: Added.
(-[IconLoadingDelegate webView:shouldLoadIconWithParameters:completionHandler:]):
(-[IconLoadingSchemeHandler initWithData:mimeType:]):
(-[IconLoadingSchemeHandler webView:startURLSchemeTask:]):
(-[IconLoadingSchemeHandler webView:stopURLSchemeTask:]):
(TEST):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (218277 => 218278)
--- trunk/Source/WebCore/ChangeLog 2017-06-14 18:42:15 UTC (rev 218277)
+++ trunk/Source/WebCore/ChangeLog 2017-06-14 19:17:22 UTC (rev 218278)
@@ -1,3 +1,16 @@
+2017-06-14 Brady Eidson <[email protected]>
+
+ WKIconLoadingDelegate never gets asked about the default favicon if touch/touch-precomposed icons are in the <head>
+ <rdar://problem/32614328> and https://bugs.webkit.org/show_bug.cgi?id=173376
+
+ Reviewed by Alex Christensen.
+
+ Covered by new API test
+
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::startIconLoading): Previously we applied the default favicon if the set of LinkIcons was empty.
+ Now, apply the default favicon if the set of LinkIcons contains no explicit favicon.
+
2017-06-14 Jer Noble <[email protected]>
Flaky Test: media/media-source/media-source-unnecessary-seek-seeked.html
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (218277 => 218278)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2017-06-14 18:42:15 UTC (rev 218277)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2017-06-14 19:17:22 UTC (rev 218278)
@@ -1657,7 +1657,15 @@
Vector<LinkIcon> icons = LinkIconCollector { *document }.iconsOfTypes({ LinkIconType::Favicon, LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon });
- if (icons.isEmpty())
+ bool hasFavicon = false;
+ for (auto& icon : icons) {
+ if (icon.type == LinkIconType::Favicon) {
+ hasFavicon = true;
+ break;
+ }
+ }
+
+ if (!hasFavicon)
icons.append({ m_frame->document()->completeURL(ASCIILiteral("/favicon.ico")), LinkIconType::Favicon, String(), std::nullopt });
for (auto& icon : icons) {
Modified: trunk/Tools/ChangeLog (218277 => 218278)
--- trunk/Tools/ChangeLog 2017-06-14 18:42:15 UTC (rev 218277)
+++ trunk/Tools/ChangeLog 2017-06-14 19:17:22 UTC (rev 218278)
@@ -1,3 +1,18 @@
+2017-06-14 Brady Eidson <[email protected]>
+
+ WKIconLoadingDelegate never gets asked about the default favicon if touch/touch-precomposed icons are in the <head>
+ <rdar://problem/32614328> and https://bugs.webkit.org/show_bug.cgi?id=173376
+
+ Reviewed by Alex Christensen.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm: Added.
+ (-[IconLoadingDelegate webView:shouldLoadIconWithParameters:completionHandler:]):
+ (-[IconLoadingSchemeHandler initWithData:mimeType:]):
+ (-[IconLoadingSchemeHandler webView:startURLSchemeTask:]):
+ (-[IconLoadingSchemeHandler webView:stopURLSchemeTask:]):
+ (TEST):
+
2017-06-14 Tim Horton <[email protected]>
WKContentViewEditingActions API test always fails
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (218277 => 218278)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-06-14 18:42:15 UTC (rev 218277)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-06-14 19:17:22 UTC (rev 218278)
@@ -163,6 +163,7 @@
51A5877D1D1B49CD004BA9AF /* IndexedDBMultiProcess-3.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51A5877C1D1B3D8D004BA9AF /* IndexedDBMultiProcess-3.html */; };
51A587851D2739E3004BA9AF /* IndexedDBDatabaseProcessKill-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51A587821D272EB5004BA9AF /* IndexedDBDatabaseProcessKill-1.html */; };
51A587861D273AA9004BA9AF /* IndexedDBDatabaseProcessKill.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */; };
+ 51AF23DF1EF1A3730072F281 /* IconLoadingDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51AF23DE1EF1A3720072F281 /* IconLoadingDelegate.mm */; };
51B1EE961C80FAEF0064FB98 /* IndexedDBPersistence-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51B1EE941C80FADD0064FB98 /* IndexedDBPersistence-1.html */; };
51B1EE971C80FAEF0064FB98 /* IndexedDBPersistence-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51B1EE951C80FADD0064FB98 /* IndexedDBPersistence-2.html */; };
51BCEE4E1C84F53B0042C82E /* IndexedDBMultiProcess-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51BCEE4C1C84F52C0042C82E /* IndexedDBMultiProcess-1.html */; };
@@ -1140,6 +1141,7 @@
51A5877C1D1B3D8D004BA9AF /* IndexedDBMultiProcess-3.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBMultiProcess-3.html"; sourceTree = "<group>"; };
51A587821D272EB5004BA9AF /* IndexedDBDatabaseProcessKill-1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBDatabaseProcessKill-1.html"; sourceTree = "<group>"; };
51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBDatabaseProcessKill.mm; sourceTree = "<group>"; };
+ 51AF23DE1EF1A3720072F281 /* IconLoadingDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IconLoadingDelegate.mm; sourceTree = "<group>"; };
51B1EE8D1C80F5880064FB98 /* IndexedDBPersistence.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBPersistence.mm; sourceTree = "<group>"; };
51B1EE941C80FADD0064FB98 /* IndexedDBPersistence-1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBPersistence-1.html"; sourceTree = "<group>"; };
51B1EE951C80FADD0064FB98 /* IndexedDBPersistence-2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBPersistence-2.html"; sourceTree = "<group>"; };
@@ -1762,6 +1764,7 @@
3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
CDE195B31CFE0ADE0053D256 /* FullscreenTopContentInset.mm */,
631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */,
+ 51AF23DE1EF1A3720072F281 /* IconLoadingDelegate.mm */,
510477751D298E03009747EB /* IDBDeleteRecovery.mm */,
5110FCEF1E01CBAA006F8D0B /* IDBIndexUpgradeToV2.mm */,
51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */,
@@ -3041,6 +3044,7 @@
7CCE7EC71A411A7E00447C4C /* PageVisibilityStateWithWindowChanges.mm in Sources */,
7CCE7F091A411AE600447C4C /* ParentFrame.cpp in Sources */,
7C83E0511D0A641800FEBCF3 /* ParsedContentRange.cpp in Sources */,
+ 51AF23DF1EF1A3730072F281 /* IconLoadingDelegate.mm in Sources */,
7CCE7F0A1A411AE600447C4C /* PasteboardNotifications.mm in Sources */,
7C83E0531D0A643A00FEBCF3 /* PendingAPIRequestURL.cpp in Sources */,
7CCE7EAF1A411A3800447C4C /* PlatformUtilities.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm (0 => 218278)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm 2017-06-14 19:17:22 UTC (rev 218278)
@@ -0,0 +1,133 @@
+/*
+ * 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"
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import <WebKit/WKURLSchemeHandler.h>
+#import <WebKit/WKURLSchemeTask.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/WebKit.h>
+#import <WebKit/_WKIconLoadingDelegate.h>
+#import <WebKit/_WKLinkIconParameters.h>
+#import <wtf/RetainPtr.h>
+
+#if WK_API_ENABLED
+
+static bool doneWithIcons;
+
+@interface IconLoadingDelegate : NSObject <_WKIconLoadingDelegate>
+@end
+
+@implementation IconLoadingDelegate {
+ RetainPtr<_WKLinkIconParameters> favicon;
+ RetainPtr<_WKLinkIconParameters> touch;
+ RetainPtr<_WKLinkIconParameters> touchPrecomposed;
+}
+
+- (void)webView:(WKWebView *)webView shouldLoadIconWithParameters:(_WKLinkIconParameters *)parameters completionHandler:(void (^)(void (^)(NSData*)))completionHandler
+{
+ switch (parameters.iconType) {
+ case WKLinkIconTypeFavicon:
+ favicon = parameters;
+ EXPECT_TRUE([[parameters.url absoluteString] isEqual:@"testing:///favicon.ico"]);
+ break;
+ case WKLinkIconTypeTouchIcon:
+ touch = parameters;
+ break;
+ case WKLinkIconTypeTouchPrecomposedIcon:
+ touchPrecomposed = parameters;
+ }
+
+ if (favicon && touch && touchPrecomposed)
+ doneWithIcons = true;
+
+ completionHandler(nil);
+}
+
+@end
+
+@interface IconLoadingSchemeHandler : NSObject <WKURLSchemeHandler>
+- (instancetype)initWithData:(NSData *)data mimeType:(NSString *)inMIMEType;
+@end
+
+@implementation IconLoadingSchemeHandler {
+ RetainPtr<NSData> resourceData;
+ RetainPtr<NSString> mimeType;
+}
+
+- (instancetype)initWithData:(NSData *)data mimeType:(NSString *)inMIMEType
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ resourceData = data;
+ mimeType = inMIMEType;
+
+ return self;
+}
+
+- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task
+{
+ RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:mimeType.get() expectedContentLength:1 textEncodingName:nil]);
+ [task didReceiveResponse:response.get()];
+ [task didReceiveData:resourceData.get()];
+ [task didFinish];
+}
+
+- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)task
+{
+}
+
+@end
+
+static const char mainBytes[] =
+"<head>" \
+"<link rel=\"apple-touch-icon\" sizes=\"57x57\" href="" \
+"<link rel=\"apple-touch-icon-precomposed\" sizes=\"57x57\" href="" \
+"</head>";
+
+TEST(IconLoading, DefaultFavicon)
+{
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+ RetainPtr<IconLoadingSchemeHandler> handler = adoptNS([[IconLoadingSchemeHandler alloc] initWithData:[NSData dataWithBytesNoCopy:(void*)mainBytes length:sizeof(mainBytes)] mimeType:@"text/html"]);
+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"testing"];
+
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ RetainPtr<IconLoadingDelegate> iconDelegate = adoptNS([[IconLoadingDelegate alloc] init]);
+
+ webView.get()._iconLoadingDelegate = iconDelegate.get();
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"testing:///main"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&doneWithIcons);
+}
+
+#endif