Title: [235140] trunk/Tools
Revision
235140
Author
[email protected]
Date
2018-08-21 14:17:25 -0700 (Tue, 21 Aug 2018)

Log Message

Translate WebKit.LimitTitleSize API test into ObjC
https://bugs.webkit.org/show_bug.cgi?id=188810

Reviewed by Andy Estes.

It uses WKPageLoaderClient.didReceiveTitleForFrame which has been replaced by KVO.
I'm translating the test into ObjC rather than introducing a new callback to WKPageNavigationClient.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp: Removed.
* TestWebKitAPI/Tests/mac/LimitTitleSize.mm:
(TEST):
(-[LimitTitleSizeTestObserver observeValueForKeyPath:ofObject:change:context:]):
(TestWebKitAPI::TEST): Deleted.

Modified Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (235139 => 235140)


--- trunk/Tools/ChangeLog	2018-08-21 21:14:36 UTC (rev 235139)
+++ trunk/Tools/ChangeLog	2018-08-21 21:17:25 UTC (rev 235140)
@@ -1,5 +1,22 @@
 2018-08-21  Alex Christensen  <[email protected]>
 
+        Translate WebKit.LimitTitleSize API test into ObjC
+        https://bugs.webkit.org/show_bug.cgi?id=188810
+
+        Reviewed by Andy Estes.
+
+        It uses WKPageLoaderClient.didReceiveTitleForFrame which has been replaced by KVO.
+        I'm translating the test into ObjC rather than introducing a new callback to WKPageNavigationClient.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp: Removed.
+        * TestWebKitAPI/Tests/mac/LimitTitleSize.mm:
+        (TEST):
+        (-[LimitTitleSizeTestObserver observeValueForKeyPath:ofObject:change:context:]):
+        (TestWebKitAPI::TEST): Deleted.
+
+2018-08-21  Alex Christensen  <[email protected]>
+
         Remove unused shouldKeepCurrentBackForwardListItemInList check
         https://bugs.webkit.org/show_bug.cgi?id=188805
 

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (235139 => 235140)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-08-21 21:14:36 UTC (rev 235139)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-08-21 21:17:25 UTC (rev 235140)
@@ -313,7 +313,6 @@
 		7A0509411FB9F06400B33FB8 /* JSONValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A0509401FB9F04400B33FB8 /* JSONValue.cpp */; };
 		7A1458FC1AD5C07000E06772 /* mouse-button-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */; };
 		7A32D74A1F02151500162C44 /* FileMonitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A32D7491F02151500162C44 /* FileMonitor.cpp */; };
-		7A66BDB61EAF14EF00CCC924 /* LimitTitleSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A66BDB51EAF14D000CCC924 /* LimitTitleSize.cpp */; };
 		7A66BDB81EAF18D500CCC924 /* set-long-title.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A66BDB71EAF150100CCC924 /* set-long-title.html */; };
 		7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */; };
 		7A6A2C721DCCFB5200C0D085 /* LocalStorageQuirkEnabled.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A6A2C711DCCFB0200C0D085 /* LocalStorageQuirkEnabled.html */; };
@@ -1607,7 +1606,6 @@
 		7A32D7491F02151500162C44 /* FileMonitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileMonitor.cpp; sourceTree = "<group>"; };
 		7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashCountedSet.cpp; sourceTree = "<group>"; };
 		7A5623101AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MenuTypesForMouseEvents.cpp; sourceTree = "<group>"; };
-		7A66BDB51EAF14D000CCC924 /* LimitTitleSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LimitTitleSize.cpp; sourceTree = "<group>"; };
 		7A66BDB71EAF150100CCC924 /* set-long-title.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "set-long-title.html"; sourceTree = "<group>"; };
 		7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageQuirkTest.mm; sourceTree = "<group>"; };
 		7A6A2C711DCCFB0200C0D085 /* LocalStorageQuirkEnabled.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LocalStorageQuirkEnabled.html; sourceTree = "<group>"; };
@@ -2892,7 +2890,6 @@
 				9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */,
 				4135FB832011FAA300332139 /* InjectInternals_Bundle.cpp */,
 				93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */,
-				7A66BDB51EAF14D000CCC924 /* LimitTitleSize.cpp */,
 				52CB47401448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp */,
 				33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */,
 				33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */,
@@ -3829,7 +3826,6 @@
 				7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,
 				7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */,
 				F4BFA68E1E4AD08000154298 /* LegacyDragAndDropTests.mm in Sources */,
-				7A66BDB61EAF14EF00CCC924 /* LimitTitleSize.cpp in Sources */,
 				7A7B0E7F1EAFE4C3006AB8AE /* LimitTitleSize.mm in Sources */,
 				C25CCA061E51380B0026CB8A /* LineBreaking.mm in Sources */,
 				37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */,

Deleted: trunk/Tools/TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp (235139 => 235140)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp	2018-08-21 21:14:36 UTC (rev 235139)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp	2018-08-21 21:17:25 UTC (rev 235140)
@@ -1,79 +0,0 @@
-/*
- * 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"
-
-#if WK_HAVE_C_SPI
-
-#include "PlatformUtilities.h"
-#include "PlatformWebView.h"
-#include "Test.h"
-#include <WebKit/WKRetainPtr.h>
-
-namespace TestWebKitAPI {
-
-static bool waitUntilLongTitleReceived = false;
-static bool didFinishLoad = false;
-static size_t maxTitleLength = 4096;
-
-static void didFinishLoadForFrame(WKPageRef page, WKFrameRef, WKTypeRef userData, const void* clientInfo)
-{
-    didFinishLoad = true;
-}
-
-static void didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef, WKTypeRef, const void*)
-{
-    WKStringRef titleString = (WKStringRef)title;
-    
-    if (WKStringIsEqualToUTF8CString(titleString, "Original Short Title"))
-        return;
-
-    EXPECT_LE(WKStringGetLength(titleString), maxTitleLength);
-    waitUntilLongTitleReceived = true;
-}
-
-TEST(WebKit, LimitTitleSize)
-{
-    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
-    PlatformWebView webView(context.get());
-
-    WKPageLoaderClientV0 loaderClient;
-    memset(&loaderClient, 0, sizeof(loaderClient));
-
-    loaderClient.base.version = 0;
-    loaderClient.didReceiveTitleForFrame = didReceiveTitleForFrame;
-    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
-
-    WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);
-
-    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("set-long-title", "html"));
-
-    WKPageLoadURL(webView.page(), url.get());
-    Util::run(&waitUntilLongTitleReceived);
-}
-
-} // namespace TestWebKitAPI
-
-#endif

Modified: trunk/Tools/TestWebKitAPI/Tests/mac/LimitTitleSize.mm (235139 => 235140)


--- trunk/Tools/TestWebKitAPI/Tests/mac/LimitTitleSize.mm	2018-08-21 21:14:36 UTC (rev 235139)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/LimitTitleSize.mm	2018-08-21 21:17:25 UTC (rev 235140)
@@ -56,8 +56,6 @@
 }
 @end
 
-namespace TestWebKitAPI {
-
 TEST(WebKitLegacy, LimitTitleSize)
 {
     RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
@@ -67,7 +65,35 @@
     [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle]
         URLForResource:@"set-long-title" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
 
-    Util::run(&didFinishLoad);
+    TestWebKitAPI::Util::run(&didFinishLoad);
 }
 
-} // namespace TestWebKitAPI
+#if WK_API_ENABLED
+
+@interface LimitTitleSizeTestObserver : NSObject
+@end
+
+@implementation LimitTitleSizeTestObserver
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void*)context
+{
+    if ([[object title] isEqualToString:@"Original Short Title"])
+        return;
+    EXPECT_LE([object title].length, maxTitleLength);
+    waitUntilLongTitleReceived = true;
+}
+
+@end
+
+TEST(WebKit, LimitTitleSize)
+{
+    auto webView = adoptNS([[WKWebView alloc] init]);
+    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"set-long-title" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+    
+    auto observer = adoptNS([LimitTitleSizeTestObserver new]);
+    [webView addObserver:observer.get() forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:nil];
+    
+    TestWebKitAPI::Util::run(&waitUntilLongTitleReceived);
+}
+
+#endif // WK_API_ENABLED
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to