<!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>[244126] branches/safari-607-branch</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/244126">244126</a></dd>
<dt>Author</dt> <dd>alancoon@apple.com</dd>
<dt>Date</dt> <dd>2019-04-10 10:11:14 -0700 (Wed, 10 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/243848">r243848</a>. rdar://problem/49725697

    The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash
    https://bugs.webkit.org/show_bug.cgi?id=196588
    <rdar://problem/49365787>

    Reviewed by Ryosuke Niwa.

    Source/WebKit:

    The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash.
    This can lead to returning stale frames to the client if it asks for those.

    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::resetState):

    Tools:

    Add API test coverage.

    * TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp:
    (TestWebKitAPI::nullJavaScriptCallback):
    (TestWebKitAPI::didCrashCheckFrames):
    (TestWebKitAPI::TEST):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243848 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari607branchSourceWebKitChangeLog">branches/safari-607-branch/Source/WebKit/ChangeLog</a></li>
<li><a href="#branchessafari607branchSourceWebKitUIProcessWebPageProxycpp">branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#branchessafari607branchToolsChangeLog">branches/safari-607-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari607branchToolsTestWebKitAPITestsWebKitReloadPageAfterCrashcpp">branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari607branchSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (244125 => 244126)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Source/WebKit/ChangeLog       2019-04-10 17:11:11 UTC (rev 244125)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog  2019-04-10 17:11:14 UTC (rev 244126)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2019-04-09  Alan Coon  <alancoon@apple.com>
+
+        Cherry-pick r243848. rdar://problem/49725697
+
+    The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash
+    https://bugs.webkit.org/show_bug.cgi?id=196588
+    <rdar://problem/49365787>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebKit:
+    
+    The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash.
+    This can lead to returning stale frames to the client if it asks for those.
+    
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::resetState):
+    
+    Tools:
+    
+    Add API test coverage.
+    
+    * TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp:
+    (TestWebKitAPI::nullJavaScriptCallback):
+    (TestWebKitAPI::didCrashCheckFrames):
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243848 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-04-03  Chris Dumez  <cdumez@apple.com>
+
+            The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash
+            https://bugs.webkit.org/show_bug.cgi?id=196588
+            <rdar://problem/49365787>
+
+            Reviewed by Ryosuke Niwa.
+
+            The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash.
+            This can lead to returning stale frames to the client if it asks for those.
+
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::resetState):
+
</ins><span class="cx"> 2019-03-27  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r243291. rdar://problem/49307996
</span></span></pre></div>
<a id="branchessafari607branchSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (244125 => 244126)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp      2019-04-10 17:11:11 UTC (rev 244125)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-04-10 17:11:14 UTC (rev 244126)
</span><span class="lines">@@ -6617,6 +6617,8 @@
</span><span class="cx"> void WebPageProxy::resetState(ResetStateReason resetStateReason)
</span><span class="cx"> {
</span><span class="cx">     m_mainFrame = nullptr;
</span><ins>+    m_focusedFrame = nullptr;
+    m_frameSetLargestFrame = nullptr;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     m_scrollingPerformanceData = nullptr;
</span></span></pre></div>
<a id="branchessafari607branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/ChangeLog (244125 => 244126)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/ChangeLog       2019-04-10 17:11:11 UTC (rev 244125)
+++ branches/safari-607-branch/Tools/ChangeLog  2019-04-10 17:11:14 UTC (rev 244126)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2019-04-09  Alan Coon  <alancoon@apple.com>
+
+        Cherry-pick r243848. rdar://problem/49725697
+
+    The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash
+    https://bugs.webkit.org/show_bug.cgi?id=196588
+    <rdar://problem/49365787>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebKit:
+    
+    The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash.
+    This can lead to returning stale frames to the client if it asks for those.
+    
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::resetState):
+    
+    Tools:
+    
+    Add API test coverage.
+    
+    * TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp:
+    (TestWebKitAPI::nullJavaScriptCallback):
+    (TestWebKitAPI::didCrashCheckFrames):
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243848 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-04-03  Chris Dumez  <cdumez@apple.com>
+
+            The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash
+            https://bugs.webkit.org/show_bug.cgi?id=196588
+            <rdar://problem/49365787>
+
+            Reviewed by Ryosuke Niwa.
+
+            Add API test coverage.
+
+            * TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp:
+            (TestWebKitAPI::nullJavaScriptCallback):
+            (TestWebKitAPI::didCrashCheckFrames):
+            (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2019-04-05  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(AppleWebKit/605.1.15): WebDownloadDelegate delegate methods called on non-main thread
</span></span></pre></div>
<a id="branchessafari607branchToolsTestWebKitAPITestsWebKitReloadPageAfterCrashcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp (244125 => 244126)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp     2019-04-10 17:11:11 UTC (rev 244125)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp        2019-04-10 17:11:14 UTC (rev 244126)
</span><span class="lines">@@ -30,12 +30,15 @@
</span><span class="cx"> #include "PlatformUtilities.h"
</span><span class="cx"> #include "PlatformWebView.h"
</span><span class="cx"> #include "Test.h"
</span><ins>+#include <WebKit/WKPagePrivate.h>
</ins><span class="cx"> #include <WebKit/WKRetainPtr.h>
</span><ins>+#include <signal.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx"> 
</span><span class="cx"> static bool loadBeforeCrash = false;
</span><span class="cx"> static bool loadAfterCrash = false;
</span><ins>+static bool calledCrashHandler = false;
</ins><span class="cx"> 
</span><span class="cx"> static void didFinishLoad(WKPageRef page, WKNavigationRef, WKTypeRef userData, const void* clientInfo)
</span><span class="cx"> {
</span><span class="lines">@@ -88,6 +91,83 @@
</span><span class="cx">     Util::run(&loadAfterCrash);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void nullJavaScriptCallback(WKSerializedScriptValueRef, WKErrorRef, void*)
+{
+}
+
+static void didCrashCheckFrames(WKPageRef page, const void*)
+{
+    // Test if first load actually worked.
+    EXPECT_TRUE(loadBeforeCrash);
+
+    EXPECT_TRUE(!WKPageGetMainFrame(page));
+    EXPECT_TRUE(!WKPageGetFocusedFrame(page));
+    EXPECT_TRUE(!WKPageGetFrameSetLargestFrame(page));
+
+    calledCrashHandler = true;
+}
+
+TEST(WebKit, FocusedFrameAfterCrash)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreateWithConfiguration(nullptr));
+    PlatformWebView webView(context.get());
+
+    WKPageNavigationClientV0 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 0;
+    loaderClient.didFinishNavigation = didFinishLoad;
+    loaderClient.webProcessDidCrash = didCrashCheckFrames;
+
+    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
+
+    WKRetainPtr<WKURLRef> url = adoptWK(Util::createURLForResource("many-iframes", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+    Util::run(&loadBeforeCrash);
+
+    EXPECT_FALSE(!WKPageGetMainFrame(webView.page()));
+
+    WKRetainPtr<WKStringRef> javaScriptString(AdoptWK, WKStringCreateWithUTF8CString("frames[2].focus()"));
+    WKPageRunJavaScriptInMainFrame(webView.page(), javaScriptString.get(), 0, nullJavaScriptCallback);
+
+    while (!WKPageGetFocusedFrame(webView.page()))
+        Util::spinRunLoop(10);
+
+    kill(WKPageGetProcessIdentifier(webView.page()), 9);
+
+    Util::run(&calledCrashHandler);
+}
+
+TEST(WebKit, FrameSetLargestFramAfterCrash)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreateWithConfiguration(nullptr));
+    PlatformWebView webView(context.get());
+
+    WKPageNavigationClientV0 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 0;
+    loaderClient.didFinishNavigation = didFinishLoad;
+    loaderClient.webProcessDidCrash = didCrashCheckFrames;
+
+    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
+
+    WKRetainPtr<WKURLRef> baseURL = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
+    WKRetainPtr<WKStringRef> htmlString = Util::toWK("<frameset cols='25%,*,25%'><frame src='about:blank'><frame src='about:blank'><frame src='about:blank'></frameset>");
+
+    WKPageLoadHTMLString(webView.page(), htmlString.get(), baseURL.get());
+    Util::run(&loadBeforeCrash);
+
+    EXPECT_FALSE(!WKPageGetMainFrame(webView.page()));
+
+    while (!WKPageGetFrameSetLargestFrame(webView.page()))
+        Util::spinRunLoop(10);
+
+    kill(WKPageGetProcessIdentifier(webView.page()), 9);
+
+    Util::run(&calledCrashHandler);
+}
+
</ins><span class="cx"> } // namespace TestWebKitAPI
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>