<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[235140] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/235140">235140</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2018-08-21 14:17:25 -0700 (Tue, 21 Aug 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsmacLimitTitleSizemm">trunk/Tools/TestWebKitAPI/Tests/mac/LimitTitleSize.mm</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitLimitTitleSizecpp">trunk/Tools/TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (235139 => 235140)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2018-08-21 21:14:36 UTC (rev 235139)
+++ trunk/Tools/ChangeLog       2018-08-21 21:17:25 UTC (rev 235140)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2018-08-21  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><ins>+        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  <achristensen@webkit.org>
+
</ins><span class="cx">         Remove unused shouldKeepCurrentBackForwardListItemInList check
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=188805
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (235139 => 235140)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -313,7 +313,6 @@
</span><span class="cx">          7A0509411FB9F06400B33FB8 /* JSONValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A0509401FB9F04400B33FB8 /* JSONValue.cpp */; };
</span><span class="cx">          7A1458FC1AD5C07000E06772 /* mouse-button-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */; };
</span><span class="cx">          7A32D74A1F02151500162C44 /* FileMonitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A32D7491F02151500162C44 /* FileMonitor.cpp */; };
</span><del>-               7A66BDB61EAF14EF00CCC924 /* LimitTitleSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A66BDB51EAF14D000CCC924 /* LimitTitleSize.cpp */; };
</del><span class="cx">           7A66BDB81EAF18D500CCC924 /* set-long-title.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A66BDB71EAF150100CCC924 /* set-long-title.html */; };
</span><span class="cx">          7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */; };
</span><span class="cx">          7A6A2C721DCCFB5200C0D085 /* LocalStorageQuirkEnabled.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A6A2C711DCCFB0200C0D085 /* LocalStorageQuirkEnabled.html */; };
</span><span class="lines">@@ -1607,7 +1606,6 @@
</span><span class="cx">          7A32D7491F02151500162C44 /* FileMonitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileMonitor.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashCountedSet.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7A5623101AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MenuTypesForMouseEvents.cpp; sourceTree = "<group>"; };
</span><del>-               7A66BDB51EAF14D000CCC924 /* LimitTitleSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LimitTitleSize.cpp; sourceTree = "<group>"; };
</del><span class="cx">           7A66BDB71EAF150100CCC924 /* set-long-title.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "set-long-title.html"; sourceTree = "<group>"; };
</span><span class="cx">          7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageQuirkTest.mm; sourceTree = "<group>"; };
</span><span class="cx">          7A6A2C711DCCFB0200C0D085 /* LocalStorageQuirkEnabled.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LocalStorageQuirkEnabled.html; sourceTree = "<group>"; };
</span><span class="lines">@@ -2892,7 +2890,6 @@
</span><span class="cx">                          9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */,
</span><span class="cx">                          4135FB832011FAA300332139 /* InjectInternals_Bundle.cpp */,
</span><span class="cx">                          93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */,
</span><del>-                               7A66BDB51EAF14D000CCC924 /* LimitTitleSize.cpp */,
</del><span class="cx">                           52CB47401448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp */,
</span><span class="cx">                          33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */,
</span><span class="cx">                          33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */,
</span><span class="lines">@@ -3829,7 +3826,6 @@
</span><span class="cx">                          7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,
</span><span class="cx">                          7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */,
</span><span class="cx">                          F4BFA68E1E4AD08000154298 /* LegacyDragAndDropTests.mm in Sources */,
</span><del>-                               7A66BDB61EAF14EF00CCC924 /* LimitTitleSize.cpp in Sources */,
</del><span class="cx">                           7A7B0E7F1EAFE4C3006AB8AE /* LimitTitleSize.mm in Sources */,
</span><span class="cx">                          C25CCA061E51380B0026CB8A /* LineBreaking.mm in Sources */,
</span><span class="cx">                          37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitLimitTitleSizecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Tools/TestWebKitAPI/Tests/WebKit/LimitTitleSize.cpp (235139 => 235140)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,79 +0,0 @@
</span><del>-/*
- * 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
</del></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacLimitTitleSizemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/mac/LimitTitleSize.mm (235139 => 235140)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -56,8 +56,6 @@
</span><span class="cx"> }
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-namespace TestWebKitAPI {
-
</del><span class="cx"> TEST(WebKitLegacy, LimitTitleSize)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
</span><span class="lines">@@ -67,7 +65,35 @@
</span><span class="cx">     [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle]
</span><span class="cx">         URLForResource:@"set-long-title" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
</span><span class="cx"> 
</span><del>-    Util::run(&didFinishLoad);
</del><ins>+    TestWebKitAPI::Util::run(&didFinishLoad);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-} // namespace TestWebKitAPI
</del><ins>+#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
</ins></span></pre>
</div>
</div>

</body>
</html>