<!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>[186579] trunk</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/186579">186579</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2015-07-08 21:47:09 -0700 (Wed, 08 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Crash calling [WebView close] in didFinishLoadForFrame callback.
<rdar://problem/21690765> and https://bugs.webkit.org/show_bug.cgi?id=146773
Reviewed by David Kilzer.
Source/WebCore:
Added API Test "WebViewCloseInsideDidFinishLoadForFrame"
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::checkLoadCompleteForThisFrame): After the delegate callback,
don't use the local Page* variable from earlier, but instead refetch it from m_frame.
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/WebViewCloseInsideDidFinishLoadForFrame.mm: Added.
(-[WebViewCloseFrameLoadDelegate webView:didFinishLoadForFrame:]):
(TestWebKitAPI::TEST):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsmacWebViewCloseInsideDidFinishLoadForFramemm">trunk/Tools/TestWebKitAPI/Tests/mac/WebViewCloseInsideDidFinishLoadForFrame.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (186578 => 186579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-07-09 04:31:41 UTC (rev 186578)
+++ trunk/Source/WebCore/ChangeLog        2015-07-09 04:47:09 UTC (rev 186579)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-07-08 Brady Eidson <beidson@apple.com>
+
+ Crash calling [WebView close] in didFinishLoadForFrame callback.
+ <rdar://problem/21690765> and https://bugs.webkit.org/show_bug.cgi?id=146773
+
+ Reviewed by David Kilzer.
+
+ Added API Test "WebViewCloseInsideDidFinishLoadForFrame"
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::checkLoadCompleteForThisFrame): After the delegate callback,
+ don't use the local Page* variable from earlier, but instead refetch it from m_frame.
+
</ins><span class="cx"> 2015-07-08 Daniel Bates <dabates@apple.com>
</span><span class="cx">
</span><span class="cx"> Cleanup: Make ContentSecurityPolicy::ReportingStatus an enum class
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (186578 => 186579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2015-07-09 04:31:41 UTC (rev 186578)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2015-07-09 04:47:09 UTC (rev 186579)
</span><span class="lines">@@ -2280,8 +2280,13 @@
</span><span class="cx"> if (AXObjectCache* cache = m_frame.document()->existingAXObjectCache())
</span><span class="cx"> cache->frameLoadingEventNotification(&m_frame, loadingEvent);
</span><span class="cx">
</span><del>- if (page && m_frame.isMainFrame())
- page->mainFrame().diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageLoadedKey(), emptyString(), error.isNull() ? DiagnosticLoggingResultPass : DiagnosticLoggingResultFail, ShouldSample::Yes);
</del><ins>+ // The above calls to dispatchDidFinishLoad() might have detached the Frame
+ // from its Page and also might have caused Page to be deleted.
+ // Don't assume 'page' is still available to use.
+ if (m_frame.isMainFrame() && m_frame.page()) {
+ ASSERT(&m_frame.page()->mainFrame() == &m_frame);
+ m_frame.page()->mainFrame().diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageLoadedKey(), emptyString(), error.isNull() ? DiagnosticLoggingResultPass : DiagnosticLoggingResultFail, ShouldSample::Yes);
+ }
</ins><span class="cx">
</span><span class="cx"> return;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (186578 => 186579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-07-09 04:31:41 UTC (rev 186578)
+++ trunk/Tools/ChangeLog        2015-07-09 04:47:09 UTC (rev 186579)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-07-08 Brady Eidson <beidson@apple.com>
+
+ Crash calling [WebView close] in didFinishLoadForFrame callback.
+ <rdar://problem/21690765> and https://bugs.webkit.org/show_bug.cgi?id=146773
+
+ Reviewed by David Kilzer.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+ * TestWebKitAPI/Tests/mac/WebViewCloseInsideDidFinishLoadForFrame.mm: Added.
+ (-[WebViewCloseFrameLoadDelegate webView:didFinishLoadForFrame:]):
+ (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2015-07-08 Hyungwook Lee <hyungwook.lee@navercorp.com>
</span><span class="cx">
</span><span class="cx"> Fix ASSERTION FAILED: !m_pendingNavigationID in WebPage::reload().
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (186578 => 186579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2015-07-09 04:31:41 UTC (rev 186578)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2015-07-09 04:47:09 UTC (rev 186579)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx">                 51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */; };
</span><span class="cx">                 5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */; };
</span><span class="cx">                 517E7E04151119C100D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */; };
</span><ins>+                51B454EC1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B454EB1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm */; };
</ins><span class="cx">                 51CB4AD81B3A079C00C1B1C6 /* ModalAlertsSPI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51CB4AD71B3A079C00C1B1C6 /* ModalAlertsSPI.cpp */; };
</span><span class="cx">                 51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */; };
</span><span class="cx">                 51CD1C721B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */; };
</span><span class="lines">@@ -521,6 +522,7 @@
</span><span class="cx">                 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContextMenuCanCopyURL.html; sourceTree = "<group>"; };
</span><span class="cx">                 517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCachePruneWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
</span><span class="cx">                 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCachePruneWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
</span><ins>+                51B454EB1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewCloseInsideDidFinishLoadForFrame.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 51CB4AD71B3A079C00C1B1C6 /* ModalAlertsSPI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModalAlertsSPI.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModalAlerts.mm; sourceTree = "<group>"; };
</span><span class="cx">                 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "modal-alerts-in-new-about-blank-window.html"; sourceTree = "<group>"; };
</span><span class="lines">@@ -1243,6 +1245,7 @@
</span><span class="cx">                                 E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */,
</span><span class="cx">                                 51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */,
</span><span class="cx">                                 C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */,
</span><ins>+                                51B454EB1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm */,
</ins><span class="cx">                                 37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */,
</span><span class="cx">                                 CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */,
</span><span class="cx">                                 1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */,
</span><span class="lines">@@ -1625,6 +1628,7 @@
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="cx">                         files = (
</span><span class="cx">                                 2D9A53AF1B31FA8D0074D5AA /* ShrinkToFit.mm in Sources */,
</span><ins>+                                51B454EC1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */,
</ins><span class="cx">                                 7AA021BB1AB09EA70052953F /* DateMath.cpp in Sources */,
</span><span class="cx">                                 2D1FE0B01AD465C1006CD9E6 /* FixedLayoutSize.mm in Sources */,
</span><span class="cx">                                 1CB9BC381A67482300FE5678 /* WeakPtr.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacWebViewCloseInsideDidFinishLoadForFramemm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/WebViewCloseInsideDidFinishLoadForFrame.mm (0 => 186579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/WebViewCloseInsideDidFinishLoadForFrame.mm         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/WebViewCloseInsideDidFinishLoadForFrame.mm        2015-07-09 04:47:09 UTC (rev 186579)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 <WebKit/WebFrameLoadDelegate.h>
+#import <WebKit/WebView.h>
+#import <wtf/RetainPtr.h>
+
+static bool didFinishLoad = false;
+
+@interface WebViewCloseFrameLoadDelegate : NSObject <WebFrameLoadDelegate>
+@end
+
+@implementation WebViewCloseFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ // With this bug, the following line crashes. With a fix for this bug, it will not.
+ [sender close];
+
+ didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, WebViewCloseInsideDidFinishLoadForFrame)
+{
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+ RetainPtr<WebViewCloseFrameLoadDelegate> frameLoadDelegate = adoptNS([[WebViewCloseFrameLoadDelegate alloc] init]);
+
+ webView.get().frameLoadDelegate = frameLoadDelegate.get();
+ [webView.get().mainFrame loadHTMLString:@"<html></html>" baseURL:nil];
+
+ Util::run(&didFinishLoad);
+ }
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>
</body>
</html>