WebKit Bugzilla
Attachment 347682 Details for
Bug 188810
: Translate WebKit.LimitTitleSize API test into ObjC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188810-20180821133412.patch (text/plain), 9.75 KB, created by
Alex Christensen
on 2018-08-21 13:34:12 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2018-08-21 13:34:12 PDT
Size:
9.75 KB
patch
obsolete
>Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 235131) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,20 @@ >+2018-08-21 Alex Christensen <achristensen@webkit.org> >+ >+ Translate WebKit.LimitTitleSize into ObjC >+ https://bugs.webkit.org/show_bug.cgi?id=188810 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 Andy VanWagoner <andy@vanwagoner.family> > > Unreviewed, add myself to committers list. >Index: Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >=================================================================== >--- Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (revision 235090) >+++ Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (working copy) >@@ -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 */; }; >@@ -1609,7 +1608,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>"; }; >@@ -2894,7 +2892,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 */, >@@ -3832,7 +3829,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 */, >Index: Tools/TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp >=================================================================== >--- Tools/TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp (revision 235117) >+++ Tools/TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp (nonexistent) >@@ -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 >Index: Tools/TestWebKitAPI/Tests/mac/LimitTitleSize.mm >=================================================================== >--- Tools/TestWebKitAPI/Tests/mac/LimitTitleSize.mm (revision 235090) >+++ Tools/TestWebKitAPI/Tests/mac/LimitTitleSize.mm (working copy) >@@ -56,8 +56,6 @@ - (void)webView:(WebView *)sender didFin > } > @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,31 @@ TEST(WebKitLegacy, LimitTitleSize) > [[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 >+@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); >+}
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188810
:
347682
|
347685