Title: [219149] trunk
Revision
219149
Author
dba...@webkit.org
Date
2017-07-05 13:10:19 -0700 (Wed, 05 Jul 2017)

Log Message

Do not pass API::FrameInfo for source frame or clear out page of target frame on
API navigation
https://bugs.webkit.org/show_bug.cgi?id=174170
<rdar://problem/33140328>

Reviewed by Brady Eidson.

Source/WebKit2:

As a step towards making it straightforward for an embedding client to determine whether
a WebPageProxy::decidePolicyForNavigationAction() callback was initiated from API we
should not pass frame info for the source frame and should not nullify the page pointer
in the target frame info.

Currently we always pass frame info for the source frame and nullify the page pointer
in both the source frame info and target frame info if the navigation was initiated from
API. This seems subtle and error prone. Instead we should not pass frame info for
the source frame and not nullify the page pointer in the target frame info as a step
towards making using this API less error-prone.

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

Tools:

Update tests as needed for the behavior change.

* TestWebKitAPI/Tests/WebKit2Cocoa/DecidePolicyForNavigationAction.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (219148 => 219149)


--- trunk/Source/WebKit2/ChangeLog	2017-07-05 20:07:10 UTC (rev 219148)
+++ trunk/Source/WebKit2/ChangeLog	2017-07-05 20:10:19 UTC (rev 219149)
@@ -1,3 +1,26 @@
+2017-07-05  Daniel Bates  <daba...@apple.com>
+
+        Do not pass API::FrameInfo for source frame or clear out page of target frame on
+        API navigation
+        https://bugs.webkit.org/show_bug.cgi?id=174170
+        <rdar://problem/33140328>
+
+        Reviewed by Brady Eidson.
+
+        As a step towards making it straightforward for an embedding client to determine whether
+        a WebPageProxy::decidePolicyForNavigationAction() callback was initiated from API we
+        should not pass frame info for the source frame and should not nullify the page pointer
+        in the target frame info.
+
+        Currently we always pass frame info for the source frame and nullify the page pointer
+        in both the source frame info and target frame info if the navigation was initiated from
+        API. This seems subtle and error prone. Instead we should not pass frame info for
+        the source frame and not nullify the page pointer in the target frame info as a step
+        towards making using this API less error-prone.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+
 2017-07-05  Chris Dumez  <cdu...@apple.com>
 
         Add a few more WebKit2 owners

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (219148 => 219149)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-07-05 20:07:10 UTC (rev 219148)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-07-05 20:10:19 UTC (rev 219149)
@@ -3639,14 +3639,10 @@
     if (m_navigationClient) {
         RefPtr<API::FrameInfo> destinationFrameInfo = API::FrameInfo::create(*frame, frameSecurityOrigin.securityOrigin());
         RefPtr<API::FrameInfo> sourceFrameInfo;
-        if (originatingFrame == frame)
+        if (!fromAPI && originatingFrame == frame)
             sourceFrameInfo = destinationFrameInfo;
-        else
+        else if (!fromAPI)
             sourceFrameInfo = API::FrameInfo::create(originatingFrameInfoData, m_process->webPage(originatingPageID));
-        if (fromAPI) {
-            sourceFrameInfo->clearPage();
-            destinationFrameInfo->clearPage();
-        }
 
         auto userInitiatedActivity = m_process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
         bool shouldOpenAppLinks = !m_shouldSuppressAppLinksInNextNavigationPolicyDecision && (!destinationFrameInfo || destinationFrameInfo->isMainFrame()) && !hostsAreEqual(URL(ParsedURLString, m_mainFrame->url()), request.url()) && navigationActionData.navigationType != WebCore::NavigationType::BackForward;

Modified: trunk/Tools/ChangeLog (219148 => 219149)


--- trunk/Tools/ChangeLog	2017-07-05 20:07:10 UTC (rev 219148)
+++ trunk/Tools/ChangeLog	2017-07-05 20:10:19 UTC (rev 219149)
@@ -1,3 +1,17 @@
+2017-07-05  Daniel Bates  <daba...@apple.com>
+
+        Do not pass API::FrameInfo for source frame or clear out page of target frame on
+        API navigation
+        https://bugs.webkit.org/show_bug.cgi?id=174170
+        <rdar://problem/33140328>
+
+        Reviewed by Brady Eidson.
+
+        Update tests as needed for the behavior change.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/DecidePolicyForNavigationAction.mm:
+        (TEST):
+
 2017-07-05  Jonathan Bedard  <jbed...@apple.com>
 
         Add WebKitPrivateFrameworkStubs for iOS 11

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DecidePolicyForNavigationAction.mm (219148 => 219149)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DecidePolicyForNavigationAction.mm	2017-07-05 20:07:10 UTC (rev 219148)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DecidePolicyForNavigationAction.mm	2017-07-05 20:10:19 UTC (rev 219149)
@@ -91,10 +91,11 @@
     TestWebKitAPI::Util::run(&decidedPolicy);
 
     EXPECT_EQ(WKNavigationTypeReload, [action navigationType]);
-    EXPECT_TRUE([action sourceFrame] == [action targetFrame]);
+    EXPECT_TRUE([action sourceFrame] != [action targetFrame]);
+    EXPECT_EQ(nil, [action sourceFrame]);
     EXPECT_WK_STREQ(firstURL, [[[action request] URL] absoluteString]);
-    EXPECT_WK_STREQ(firstURL, [[[[action sourceFrame] request] URL] absoluteString]);
-    EXPECT_EQ(nil, [[action sourceFrame] webView]);
+    EXPECT_WK_STREQ(firstURL, [[[[action targetFrame] request] URL] absoluteString]);
+    EXPECT_EQ(webView.get(), [[action targetFrame] webView]);
 
     newWebView = nullptr;
     action = ""
@@ -120,10 +121,11 @@
     TestWebKitAPI::Util::run(&decidedPolicy);
 
     EXPECT_EQ(WKNavigationTypeReload, [action navigationType]);
-    EXPECT_TRUE([action sourceFrame] == [action targetFrame]);
+    EXPECT_TRUE([action sourceFrame] != [action targetFrame]);
+    EXPECT_EQ(nil, [action sourceFrame]);
     EXPECT_WK_STREQ(firstURL, [[[action request] URL] absoluteString]);
-    EXPECT_WK_STREQ(firstURL, [[[[action sourceFrame] request] URL] absoluteString]);
-    EXPECT_EQ(nil, [[action sourceFrame] webView]);
+    EXPECT_WK_STREQ(firstURL, [[[[action targetFrame] request] URL] absoluteString]);
+    EXPECT_EQ(webView.get(), [[action targetFrame] webView]);
 
     newWebView = nullptr;
     action = ""
@@ -153,10 +155,11 @@
     TestWebKitAPI::Util::run(&decidedPolicy);
 
     EXPECT_EQ(WKNavigationTypeBackForward, [action navigationType]);
-    EXPECT_TRUE([action sourceFrame] == [action targetFrame]);
+    EXPECT_TRUE([action sourceFrame] != [action targetFrame]);
+    EXPECT_EQ(nil, [action sourceFrame]);
     EXPECT_WK_STREQ(firstURL, [[[action request] URL] absoluteString]);
-    EXPECT_WK_STREQ(secondURL, [[[[action sourceFrame] request] URL] absoluteString]);
-    EXPECT_EQ(nil, [[action sourceFrame] webView]);
+    EXPECT_WK_STREQ(secondURL, [[[[action targetFrame] request] URL] absoluteString]);
+    EXPECT_EQ(webView.get(), [[action targetFrame] webView]);
 
     newWebView = nullptr;
     action = ""
@@ -190,10 +193,11 @@
     TestWebKitAPI::Util::run(&decidedPolicy);
 
     EXPECT_EQ(WKNavigationTypeBackForward, [action navigationType]);
-    EXPECT_TRUE([action sourceFrame] == [action targetFrame]);
+    EXPECT_TRUE([action sourceFrame] != [action targetFrame]);
+    EXPECT_EQ(nil, [action sourceFrame]);
     EXPECT_WK_STREQ(secondURL, [[[action request] URL] absoluteString]);
-    EXPECT_WK_STREQ(firstURL, [[[[action sourceFrame] request] URL] absoluteString]);
-    EXPECT_EQ(nil, [[action sourceFrame] webView]);
+    EXPECT_WK_STREQ(firstURL, [[[[action targetFrame] request] URL] absoluteString]);
+    EXPECT_EQ(webView.get(), [[action targetFrame] webView]);
 
     newWebView = nullptr;
     action = ""
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to