Diff
Modified: trunk/Source/WebCore/ChangeLog (273619 => 273620)
--- trunk/Source/WebCore/ChangeLog 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Source/WebCore/ChangeLog 2021-02-27 08:04:31 UTC (rev 273620)
@@ -1,3 +1,17 @@
+2021-02-27 Megan Gardner <[email protected]>
+
+ API test for AppHighlights
+ https://bugs.webkit.org/show_bug.cgi?id=222408
+
+ Reviewed by Tim Horton.
+
+ Test: TestWebKitAPI.AppHighlights.AppHighlightCreateAndRestore
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::numberOfAppHighlights):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2021-02-26 Chris Dumez <[email protected]>
Reduce explicit usage of [objC retain] in WebKit
Modified: trunk/Source/WebCore/testing/Internals.cpp (273619 => 273620)
--- trunk/Source/WebCore/testing/Internals.cpp 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Source/WebCore/testing/Internals.cpp 2021-02-27 08:04:31 UTC (rev 273620)
@@ -101,6 +101,7 @@
#include "HTMLSelectElement.h"
#include "HTMLTextAreaElement.h"
#include "HTMLVideoElement.h"
+#include "HighlightRegister.h"
#include "HistoryController.h"
#include "HistoryItem.h"
#include "HitTestResult.h"
@@ -5913,6 +5914,22 @@
}
#endif
+#if ENABLE(APP_HIGHLIGHTS)
+unsigned Internals::numberOfAppHighlights()
+{
+ Document* document = contextDocument();
+ if (!document)
+ return 0;
+ auto appHighlightRegister = document->appHighlightRegisterIfExists();
+ if (!appHighlightRegister)
+ return 0;
+ unsigned numHighlights = 0;
+ for (auto& highlight : appHighlightRegister->map())
+ numHighlights += highlight.value->rangesData().size();
+ return numHighlights;
+}
+#endif
+
bool Internals::supportsPictureInPicture()
{
return WebCore::supportsPictureInPicture();
Modified: trunk/Source/WebCore/testing/Internals.h (273619 => 273620)
--- trunk/Source/WebCore/testing/Internals.h 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Source/WebCore/testing/Internals.h 2021-02-27 08:04:31 UTC (rev 273620)
@@ -1047,6 +1047,10 @@
unsigned createSleepDisabler(const String& reason, bool display);
bool destroySleepDisabler(unsigned identifier);
+
+#if ENABLE(APP_HIGHLIGHTS)
+ unsigned numberOfAppHighlights();
+#endif
#if ENABLE(WEBXR)
ExceptionOr<RefPtr<WebXRTest>> xrTest();
Modified: trunk/Source/WebCore/testing/Internals.idl (273619 => 273620)
--- trunk/Source/WebCore/testing/Internals.idl 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Source/WebCore/testing/Internals.idl 2021-02-27 08:04:31 UTC (rev 273620)
@@ -957,6 +957,8 @@
unsigned long createSleepDisabler(DOMString reason, boolean display);
boolean destroySleepDisabler(unsigned long identifier);
+
+ [Conditional=APP_HIGHLIGHTS] unsigned long numberOfAppHighlights();
[Conditional=WEBXR, MayThrowException] readonly attribute WebXRTest xrTest;
Modified: trunk/Tools/ChangeLog (273619 => 273620)
--- trunk/Tools/ChangeLog 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Tools/ChangeLog 2021-02-27 08:04:31 UTC (rev 273620)
@@ -1,3 +1,21 @@
+2021-02-27 Megan Gardner <[email protected]>
+
+ API test for AppHighlights
+ https://bugs.webkit.org/show_bug.cgi?id=222408
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/PlatformUtilities.h:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/WKAppHighlights.mm: Added.
+ (-[AppHighlightDelegate _webView:storeAppHighlight:inNewGroup:]):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
+ (TEST):
+ (waitForConditionWithLogging): Deleted.
+ * TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm:
+ (TestWebKitAPI::Util::waitForConditionWithLogging):
+
2021-02-26 Carlos Garcia Campos <[email protected]>
[GTK][WPE] Add a script to show a list of bugs closed since a given revision
Modified: trunk/Tools/TestWebKitAPI/PlatformUtilities.h (273619 => 273620)
--- trunk/Tools/TestWebKitAPI/PlatformUtilities.h 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Tools/TestWebKitAPI/PlatformUtilities.h 2021-02-27 08:04:31 UTC (rev 273620)
@@ -35,6 +35,7 @@
#if USE(FOUNDATION)
OBJC_CLASS NSString;
OBJC_CLASS NSDictionary;
+typedef double NSTimeInterval;
#endif
namespace TestWebKitAPI {
@@ -44,6 +45,7 @@
#if USE(FOUNDATION)
std::string toSTD(NSString *);
bool jsonMatchesExpectedValues(NSString *jsonString, NSDictionary *expected);
+void waitForConditionWithLogging(std::function<bool()>&&, NSTimeInterval loggingTimeout, NSString *message, ...);
#endif
#if WK_HAVE_C_SPI
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (273619 => 273620)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-02-27 08:04:31 UTC (rev 273620)
@@ -249,6 +249,7 @@
44817A2F1F0486BF00003810 /* WKRequestActivatedElementInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44817A2E1F0486BF00003810 /* WKRequestActivatedElementInfo.mm */; };
448D7E471EA6C55500ECC756 /* EnvironmentUtilitiesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 448D7E451EA6C55500ECC756 /* EnvironmentUtilitiesTest.cpp */; };
44AC8BC621D0245A00CAFB34 /* RetainPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC029B161486AD6400817DA9 /* RetainPtr.cpp */; };
+ 44C2FBE225E7592C00ABC72F /* WKAppHighlights.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44C2FBE125E7592C00ABC72F /* WKAppHighlights.mm */; };
44CF31FD249941E8009CB6CB /* ContextMenuAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 44CF31FB24993F66009CB6CB /* ContextMenuAction.cpp */; };
4612C2B9210A6ACE00B788A6 /* LoadFileThenReload.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4612C2B8210A6ABF00B788A6 /* LoadFileThenReload.mm */; };
4628C8E92367ABD100B073F0 /* WKSecurityOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4628C8E82367ABBC00B073F0 /* WKSecurityOrigin.cpp */; };
@@ -2009,6 +2010,7 @@
44817A2E1F0486BF00003810 /* WKRequestActivatedElementInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRequestActivatedElementInfo.mm; sourceTree = "<group>"; };
448D7E451EA6C55500ECC756 /* EnvironmentUtilitiesTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnvironmentUtilitiesTest.cpp; sourceTree = "<group>"; };
44A622C114A0E2B60048515B /* WTFStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFStringUtilities.h; sourceTree = "<group>"; };
+ 44C2FBE125E7592C00ABC72F /* WKAppHighlights.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKAppHighlights.mm; sourceTree = "<group>"; };
44CF31FB24993F66009CB6CB /* ContextMenuAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContextMenuAction.cpp; sourceTree = "<group>"; };
4612C2B8210A6ABF00B788A6 /* LoadFileThenReload.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadFileThenReload.mm; sourceTree = "<group>"; };
4628C8E82367ABBC00B073F0 /* WKSecurityOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKSecurityOrigin.cpp; sourceTree = "<group>"; };
@@ -3493,6 +3495,7 @@
5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */,
5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */,
931C281C22BC55A7001D98C4 /* WebSQLBasics.mm */,
+ 44C2FBE125E7592C00ABC72F /* WKAppHighlights.mm */,
2E5C77061FA70136005932C3 /* WKAttachmentTests.mm */,
1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */,
5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */,
@@ -5670,6 +5673,7 @@
7CCE7F1C1A411AE600447C4C /* WillSendSubmitEvent.cpp in Sources */,
7CCE7ED81A411A7E00447C4C /* WillSendSubmitEvent.mm in Sources */,
7CCE7ED91A411A7E00447C4C /* WindowlessWebViewWithMedia.mm in Sources */,
+ 44C2FBE225E7592C00ABC72F /* WKAppHighlights.mm in Sources */,
2E5C77071FA70136005932C3 /* WKAttachmentTests.mm in Sources */,
1F83571B1D3FFB2300E3967B /* WKBackForwardList.mm in Sources */,
7CCE7F2E1A411B1000447C4C /* WKBrowsingContextGroupTest.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAppHighlights.mm (0 => 273620)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAppHighlights.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAppHighlights.mm 2021-02-27 08:04:31 UTC (rev 273620)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2021 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 "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebViewPrivateForTesting.h>
+#import <WebKit/_WKAppHighlight.h>
+#import <WebKit/_WKAppHighlightDelegate.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/Vector.h>
+
+#if ENABLE(APP_HIGHLIGHTS)
+
+@interface AppHighlightDelegate : NSObject <_WKAppHighlightDelegate>
+@property (nonatomic, copy) void (^storeAppHighlightCallback)(WKWebView *, _WKAppHighlight *, BOOL);
+@end
+
+@implementation AppHighlightDelegate
+- (void)_webView:(WKWebView *)webView storeAppHighlight:(_WKAppHighlight *)highlight inNewGroup:(BOOL)inNewGroup
+{
+ if (_storeAppHighlightCallback)
+ _storeAppHighlightCallback(webView, highlight, inNewGroup);
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(AppHighlights, AppHighlightCreateAndRestore)
+{
+ WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES];
+ auto delegate = adoptNS([[AppHighlightDelegate alloc] init]);
+ auto webViewCreate = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration]);
+ auto webViewRestore = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration]);
+ [webViewCreate _setAppHighlightDelegate:delegate.get()];
+ [webViewCreate synchronouslyLoadHTMLString:@"Test"];
+ [webViewCreate stringByEvaluatingJavaScript:@"document.execCommand('SelectAll')"];
+ __block bool finished = NO;
+ [delegate setStoreAppHighlightCallback:^(WKWebView *delegateWebView, _WKAppHighlight *highlight, BOOL inNewGroup) {
+ EXPECT_EQ(delegateWebView, webViewCreate.get());
+ EXPECT_NOT_NULL(highlight);
+ EXPECT_WK_STREQ(highlight.text, @"Test");
+ EXPECT_NOT_NULL(highlight.highlight);
+
+ [webViewRestore synchronouslyLoadHTMLString:@"Test"];
+ [webViewRestore _restoreAppHighlights:@[ highlight.highlight ]];
+
+ TestWebKitAPI::Util::waitForConditionWithLogging([&] () -> bool {
+ return [webViewRestore stringByEvaluatingJavaScript:@"internals.numberOfAppHighlights()"].intValue == 1;
+ }, 2, @"Expected Highlights to be populated.");
+
+ finished = YES;
+ }];
+ [webViewCreate _addAppHighlight];
+ TestWebKitAPI::Util::run(&finished);
+}
+
+}
+
+#endif
Modified: trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm (273619 => 273620)
--- trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm 2021-02-27 08:04:31 UTC (rev 273620)
@@ -34,25 +34,6 @@
#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
-static void waitForConditionWithLogging(BOOL(^condition)(), NSTimeInterval loggingTimeout, NSString *message, ...)
-{
- NSDate *startTime = [NSDate date];
- BOOL exceededLoggingTimeout = NO;
- while ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]) {
- if (condition())
- break;
-
- if (exceededLoggingTimeout || [[NSDate date] timeIntervalSinceDate:startTime] < loggingTimeout)
- continue;
-
- va_list args;
- va_start(args, message);
- NSLogv(message, args);
- va_end(args);
- exceededLoggingTimeout = YES;
- }
-}
-
TEST(DragAndDropTests, NumberOfValidItemsForDrop)
{
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
@@ -101,7 +82,7 @@
[webView synchronouslyLoadTestPageNamed:@"image-and-file-upload"];
[simulator runFrom:NSMakePoint(100, 100) to:NSMakePoint(100, 300)];
- waitForConditionWithLogging([&] () -> BOOL {
+ TestWebKitAPI::Util::waitForConditionWithLogging([&] () -> bool {
return [webView stringByEvaluatingJavaScript:@"imageload.textContent"].boolValue;
}, 2, @"Expected image to finish loading.");
EXPECT_EQ(1, [webView stringByEvaluatingJavaScript:@"filecount.textContent"].integerValue);
@@ -117,7 +98,7 @@
[simulator writePromisedFiles:@[ imageURL ]];
[simulator runFrom:NSMakePoint(100, 100) to:NSMakePoint(100, 300)];
- waitForConditionWithLogging([&] () -> BOOL {
+ TestWebKitAPI::Util::waitForConditionWithLogging([&] () -> bool {
return [webView stringByEvaluatingJavaScript:@"imageload.textContent"].boolValue;
}, 2, @"Expected image to finish loading.");
EXPECT_EQ(1, [webView stringByEvaluatingJavaScript:@"filecount.textContent"].integerValue);
@@ -133,7 +114,7 @@
[simulator writeFiles:@[ imageURL ]];
[simulator runFrom:NSMakePoint(100, 100) to:NSMakePoint(100, 300)];
- waitForConditionWithLogging([&] () -> BOOL {
+ TestWebKitAPI::Util::waitForConditionWithLogging([&] () -> bool {
return [webView stringByEvaluatingJavaScript:@"imageload.textContent"].boolValue;
}, 2, @"Expected image to finish loading.");
EXPECT_EQ(1, [webView stringByEvaluatingJavaScript:@"filecount.textContent"].integerValue);
Modified: trunk/Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm (273619 => 273620)
--- trunk/Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm 2021-02-27 07:29:05 UTC (rev 273619)
+++ trunk/Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm 2021-02-27 08:04:31 UTC (rev 273620)
@@ -54,6 +54,25 @@
return [expected isEqualToDictionary:result];
}
+void waitForConditionWithLogging(std::function<bool()>&& condition, NSTimeInterval loggingTimeout, NSString *message, ...)
+{
+ NSDate *startTime = [NSDate date];
+ BOOL exceededLoggingTimeout = NO;
+ while ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]) {
+ if (condition())
+ break;
+
+ if (exceededLoggingTimeout || [[NSDate date] timeIntervalSinceDate:startTime] < loggingTimeout)
+ continue;
+
+ va_list args;
+ va_start(args, message);
+ NSLogv(message, args);
+ va_end(args);
+ exceededLoggingTimeout = YES;
+ }
+}
+
NSString * const TestPlugInClassNameParameter = @"TestPlugInPrincipalClassName";
} // namespace Util