<!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>[244361] 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/244361">244361</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2019-04-16 16:07:35 -0700 (Tue, 16 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>URL set by document.open() is not communicated to the UIProcess
https://bugs.webkit.org/show_bug.cgi?id=196941
<rdar://problem/49237544>

Reviewed by Geoff Garen.

Source/WebCore:

Notify the FrameLoaderClient whenever an explicit open was done and provide it with
the latest document URL.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didExplicitOpen):
* loader/FrameLoaderClient.h:

Source/WebKit:

Whenever the UIProcess is notified of an explicit document.open() call, update the
PageLoadState to make sure the URL is up-to-date. Also make sure the page / process
knows it committed a load (i.e. It is no longer showing the initially empty document).

* UIProcess/PageLoadState.cpp:
(WebKit::PageLoadState::didExplicitOpen):
* UIProcess/PageLoadState.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didExplicitOpenForFrame):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidExplicitOpen):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

Tools:

Add API test coverage.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/open-window-then-write-to-it.html: Added.
* TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm:
(-[OpenWindowThenDocumentOpenUIDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
(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="#trunkSourceWebCoreloaderFrameLoaderClienth">trunk/Source/WebCore/loader/FrameLoaderClient.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessPageLoadStatecpp">trunk/Source/WebKit/UIProcess/PageLoadState.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessPageLoadStateh">trunk/Source/WebKit/UIProcess/PageLoadState.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxymessagesin">trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebFrameLoaderClientcpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebFrameLoaderClienth">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h</a></li>
<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="#trunkToolsTestWebKitAPITestsWebKitCocoaOpenAndCloseWindowmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitopenwindowthenwritetoithtml">trunk/Tools/TestWebKitAPI/Tests/WebKit/open-window-then-write-to-it.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebCore/ChangeLog      2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2019-04-16  Chris Dumez  <cdumez@apple.com>
+
+        URL set by document.open() is not communicated to the UIProcess
+        https://bugs.webkit.org/show_bug.cgi?id=196941
+        <rdar://problem/49237544>
+
+        Reviewed by Geoff Garen.
+
+        Notify the FrameLoaderClient whenever an explicit open was done and provide it with
+        the latest document URL.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::didExplicitOpen):
+        * loader/FrameLoaderClient.h:
+
</ins><span class="cx"> 2019-04-16  Timothy Hatcher  <timothy@apple.com>
</span><span class="cx"> 
</span><span class="cx">         FrameView base background color always starts white.
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp      2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -592,6 +592,8 @@
</span><span class="cx">     // Calling document.open counts as committing the first real document load.
</span><span class="cx">     if (!m_stateMachine.committedFirstRealDocumentLoad())
</span><span class="cx">         m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocumentPostCommit);
</span><ins>+
+    m_client.dispatchDidExplicitOpen(m_frame.document() ? m_frame.document()->url() : URL());
</ins><span class="cx">     
</span><span class="cx">     // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
</span><span class="cx">     // from a subsequent window.document.open / window.document.write call. 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoaderClient.h  2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h     2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -181,6 +181,7 @@
</span><span class="cx">     virtual void dispatchDidFailLoad(const ResourceError&) = 0;
</span><span class="cx">     virtual void dispatchDidFinishDocumentLoad() = 0;
</span><span class="cx">     virtual void dispatchDidFinishLoad() = 0;
</span><ins>+    virtual void dispatchDidExplicitOpen(const URL&) { }
</ins><span class="cx"> #if ENABLE(DATA_DETECTION)
</span><span class="cx">     virtual void dispatchDidFinishDataDetection(NSArray *detectionResults) = 0;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebKit/ChangeLog       2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -1,5 +1,28 @@
</span><span class="cx"> 2019-04-16  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><ins>+        URL set by document.open() is not communicated to the UIProcess
+        https://bugs.webkit.org/show_bug.cgi?id=196941
+        <rdar://problem/49237544>
+
+        Reviewed by Geoff Garen.
+
+        Whenever the UIProcess is notified of an explicit document.open() call, update the
+        PageLoadState to make sure the URL is up-to-date. Also make sure the page / process
+        knows it committed a load (i.e. It is no longer showing the initially empty document).
+
+        * UIProcess/PageLoadState.cpp:
+        (WebKit::PageLoadState::didExplicitOpen):
+        * UIProcess/PageLoadState.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didExplicitOpenForFrame):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidExplicitOpen):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+
+2019-04-16  Chris Dumez  <cdumez@apple.com>
+
</ins><span class="cx">         Show prompt for device orientation access if the client does not implement the corresponding API delegate
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=196971
</span><span class="cx">         <rdar://problem/49945840>
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessPageLoadStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/PageLoadState.cpp (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/PageLoadState.cpp  2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebKit/UIProcess/PageLoadState.cpp     2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -246,6 +246,14 @@
</span><span class="cx">     m_uncommittedState.pendingAPIRequestURL = String();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageLoadState::didExplicitOpen(const Transaction::Token& token, const String& url)
+{
+    ASSERT_UNUSED(token, &token.m_pageLoadState == this);
+
+    m_uncommittedState.url = url;
+    m_uncommittedState.provisionalURL = String();
+}
+
</ins><span class="cx"> void PageLoadState::didStartProvisionalLoad(const Transaction::Token& token, const String& url, const String& unreachableURL)
</span><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(token, &token.m_pageLoadState == this);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessPageLoadStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/PageLoadState.h (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/PageLoadState.h    2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebKit/UIProcess/PageLoadState.h       2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -143,6 +143,7 @@
</span><span class="cx">     void clearPendingAPIRequestURL(const Transaction::Token&);
</span><span class="cx"> 
</span><span class="cx">     void didStartProvisionalLoad(const Transaction::Token&, const String& url, const String& unreachableURL);
</span><ins>+    void didExplicitOpen(const Transaction::Token&, const String& url);
</ins><span class="cx">     void didReceiveServerRedirectForProvisionalLoad(const Transaction::Token&, const String& url);
</span><span class="cx">     void didFailProvisionalLoad(const Transaction::Token&);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -3922,6 +3922,23 @@
</span><span class="cx">         m_navigationClient->didStartProvisionalNavigation(*this, navigation.get(), process->transformHandlesToObjects(userData.object()).get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::didExplicitOpenForFrame(uint64_t frameID, URL&& url)
+{
+    auto* frame = m_process->webFrame(frameID);
+    MESSAGE_CHECK(m_process, frame);
+    MESSAGE_CHECK_URL(m_process, url);
+
+    auto transaction = m_pageLoadState.transaction();
+
+    if (frame->isMainFrame())
+        m_pageLoadState.didExplicitOpen(transaction, url);
+
+    m_hasCommittedAnyProvisionalLoads = true;
+    m_process->didCommitProvisionalLoad();
+
+    m_pageLoadState.commitChanges();
+}
+
</ins><span class="cx"> void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, ResourceRequest&& request, const UserData& userData)
</span><span class="cx"> {
</span><span class="cx">     didReceiveServerRedirectForProvisionalLoadForFrameShared(m_process.copyRef(), frameID, navigationID, WTFMove(request), userData);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -1591,6 +1591,7 @@
</span><span class="cx">     void didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const WebCore::ResourceError&, const UserData&);
</span><span class="cx">     void didSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t sameDocumentNavigationType, URL&&, const UserData&);
</span><span class="cx">     void didChangeMainDocument(uint64_t frameID);
</span><ins>+    void didExplicitOpenForFrame(uint64_t frameID, URL&&);
</ins><span class="cx"> 
</span><span class="cx">     void didReceiveTitleForFrame(uint64_t frameID, const String&, const UserData&);
</span><span class="cx">     void didFirstLayoutForFrame(uint64_t frameID, const UserData&);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in   2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in      2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -140,7 +140,8 @@
</span><span class="cx">     DidRunInsecureContentForFrame(uint64_t frameID, WebKit::UserData userData)
</span><span class="cx">     DidDetectXSSForFrame(uint64_t frameID, WebKit::UserData userData)
</span><span class="cx">     DidSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t type, URL url, WebKit::UserData userData)
</span><del>-    DidChangeMainDocument(uint64_t frameID);
</del><ins>+    DidChangeMainDocument(uint64_t frameID)
+    DidExplicitOpenForFrame(uint64_t frameID, URL url)
</ins><span class="cx">     DidDestroyNavigation(uint64_t navigationID)
</span><span class="cx"> 
</span><span class="cx">     HasInsecureContent() -> (enum:bool WebCore::HasInsecureContent hasInsecureContent) Synchronous
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebFrameLoaderClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp   2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp      2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -458,6 +458,16 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebFrameLoaderClient::dispatchDidExplicitOpen(const URL& url)
+{
+    auto* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    // Notify the UIProcess.
+    webPage->send(Messages::WebPageProxy::DidExplicitOpenForFrame(m_frame->frameID(), url));
+}
+
</ins><span class="cx"> void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
</span><span class="cx"> {
</span><span class="cx">     WebPage* webPage = m_frame->page();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebFrameLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h     2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h        2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -116,6 +116,7 @@
</span><span class="cx">     void dispatchDidFailLoad(const WebCore::ResourceError&) final;
</span><span class="cx">     void dispatchDidFinishDocumentLoad() final;
</span><span class="cx">     void dispatchDidFinishLoad() final;
</span><ins>+    void dispatchDidExplicitOpen(const URL&) final;
</ins><span class="cx"> 
</span><span class="cx">     void dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone>) final;
</span><span class="cx">     void dispatchDidLayout() final;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Tools/ChangeLog       2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2019-04-16  Chris Dumez  <cdumez@apple.com>
+
+        URL set by document.open() is not communicated to the UIProcess
+        https://bugs.webkit.org/show_bug.cgi?id=196941
+        <rdar://problem/49237544>
+
+        Reviewed by Geoff Garen.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/open-window-then-write-to-it.html: Added.
+        * TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm:
+        (-[OpenWindowThenDocumentOpenUIDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
+        (TEST):
+
</ins><span class="cx"> 2019-04-16  Commit Queue  <commit-queue@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r244321.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -188,6 +188,7 @@
</span><span class="cx">          466C3843210637DE006A88DE /* notify-resourceLoadObserver.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 466C3842210637CE006A88DE /* notify-resourceLoadObserver.html */; };
</span><span class="cx">          467C565321B5ED130057516D /* GetSessionCookie.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 467C565121B5ECDF0057516D /* GetSessionCookie.html */; };
</span><span class="cx">          467C565421B5ED130057516D /* SetSessionCookie.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 467C565221B5ECDF0057516D /* SetSessionCookie.html */; };
</span><ins>+               468BC45522653A1000A36C96 /* open-window-then-write-to-it.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 468BC454226539C800A36C96 /* open-window-then-write-to-it.html */; };
</ins><span class="cx">           46918EFC2237283C00468DFE /* DeviceOrientation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46918EFB2237283500468DFE /* DeviceOrientation.mm */; };
</span><span class="cx">          46A911592108E6780078D40D /* CustomUserAgent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A911582108E66B0078D40D /* CustomUserAgent.mm */; };
</span><span class="cx">          46AE5A3720F9066D00E0873E /* SimpleServiceWorkerRegistrations-4.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4656A75720F9054F0002E21F /* SimpleServiceWorkerRegistrations-4.sqlite3 */; };
</span><span class="lines">@@ -1243,6 +1244,7 @@
</span><span class="cx">                          074994421EA5034B000DA44F /* ondevicechange.html in Copy Resources */,
</span><span class="cx">                          CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */,
</span><span class="cx">                          7CCB99231D3B4A46003922F6 /* open-multiple-external-url.html in Copy Resources */,
</span><ins>+                               468BC45522653A1000A36C96 /* open-window-then-write-to-it.html in Copy Resources */,
</ins><span class="cx">                           290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */,
</span><span class="cx">                          83148B09202AC78D00BADE99 /* override-builtins-test.html in Copy Resources */,
</span><span class="cx">                          CEBCA1391E3A807A00C73293 /* page-with-csp-iframe.html in Copy Resources */,
</span><span class="lines">@@ -1576,6 +1578,7 @@
</span><span class="cx">          466C3842210637CE006A88DE /* notify-resourceLoadObserver.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "notify-resourceLoadObserver.html"; sourceTree = "<group>"; };
</span><span class="cx">          467C565121B5ECDF0057516D /* GetSessionCookie.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = GetSessionCookie.html; sourceTree = "<group>"; };
</span><span class="cx">          467C565221B5ECDF0057516D /* SetSessionCookie.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = SetSessionCookie.html; sourceTree = "<group>"; };
</span><ins>+               468BC454226539C800A36C96 /* open-window-then-write-to-it.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "open-window-then-write-to-it.html"; sourceTree = "<group>"; };
</ins><span class="cx">           46918EFB2237283500468DFE /* DeviceOrientation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceOrientation.mm; sourceTree = "<group>"; };
</span><span class="cx">          46A911582108E66B0078D40D /* CustomUserAgent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomUserAgent.mm; sourceTree = "<group>"; };
</span><span class="cx">          46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageNullEntries.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -3418,6 +3421,7 @@
</span><span class="cx">                          C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */,
</span><span class="cx">                          4A410F4D19AF7BEF002EBAB6 /* ondevicechange.html */,
</span><span class="cx">                          CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */,
</span><ins>+                               468BC454226539C800A36C96 /* open-window-then-write-to-it.html */,
</ins><span class="cx">                           83148B08202AC76800BADE99 /* override-builtins-test.html */,
</span><span class="cx">                          0EBBCC651FFF9DCE00FA42AB /* pop-up-check.html */,
</span><span class="cx">                          F6FDDDD514241C48004F1729 /* push-state.html */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitopenwindowthenwritetoithtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/open-window-then-write-to-it.html (0 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit/open-window-then-write-to-it.html                         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/open-window-then-write-to-it.html    2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script>
+onload = () => {
+    w = window.open("#", "name", "width=400,height=400")
+    w.document.open();
+    w.document.write("TEST");
+    w.document.close();
+};
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaOpenAndCloseWindowmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm (244360 => 244361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm        2019-04-16 22:43:55 UTC (rev 244360)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm   2019-04-16 23:07:35 UTC (rev 244361)
</span><span class="lines">@@ -282,3 +282,38 @@
</span><span class="cx">     EXPECT_FALSE([openWindowFeatures _fullscreenDisplay].boolValue);
</span><span class="cx">     openWindowFeatures = nullptr;
</span><span class="cx"> }
</span><ins>+
+@interface OpenWindowThenDocumentOpenUIDelegate : NSObject <WKUIDelegate>
+@end
+
+@implementation OpenWindowThenDocumentOpenUIDelegate
+
+- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
+{
+    openedWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
+    [openedWebView setUIDelegate:sharedUIDelegate.get()];
+    return openedWebView.get();
+}
+
+@end
+
+TEST(WebKit, OpenWindowThenDocumentOpen)
+{
+    resetToConsistentState();
+
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto uiDelegate = adoptNS([[OpenWindowThenDocumentOpenUIDelegate alloc] init]);
+    [webView setUIDelegate:uiDelegate.get()];
+    [webView configuration].preferences.javaScriptCanOpenWindowsAutomatically = YES;
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"open-window-then-write-to-it" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    while (!openedWebView)
+        TestWebKitAPI::Util::sleep(0.1);
+
+    // Both WebViews should have the same URL because of document.open().
+    while (![[[openedWebView URL] absoluteString] isEqualToString:[[webView URL] absoluteString]])
+        TestWebKitAPI::Util::sleep(0.1);
+}
</ins></span></pre>
</div>
</div>

</body>
</html>