Title: [258042] trunk
Revision
258042
Author
[email protected]
Date
2020-03-06 17:35:40 -0800 (Fri, 06 Mar 2020)

Log Message

Evaluating _javascript_ in main frame before loading should succeed
https://bugs.webkit.org/show_bug.cgi?id=208733

Patch by Alex Christensen <[email protected]> on 2020-03-06
Reviewed by Tim Horton.

Source/WebKit:

This fixes a bug in the SPI I introduced in r257882 with a test.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _evaluateJavaScript:asAsyncFunction:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:]):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (258041 => 258042)


--- trunk/Source/WebKit/ChangeLog	2020-03-07 01:31:19 UTC (rev 258041)
+++ trunk/Source/WebKit/ChangeLog	2020-03-07 01:35:40 UTC (rev 258042)
@@ -1,3 +1,15 @@
+2020-03-06  Alex Christensen  <[email protected]>
+
+        Evaluating _javascript_ in main frame before loading should succeed
+        https://bugs.webkit.org/show_bug.cgi?id=208733
+
+        Reviewed by Tim Horton.
+
+        This fixes a bug in the SPI I introduced in r257882 with a test.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _evaluateJavaScript:asAsyncFunction:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:]):
+
 2020-03-06  Brent Fulgham  <[email protected]>
 
         Expand the feature flags mechanism with additional default feature preference values

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (258041 => 258042)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-03-07 01:31:19 UTC (rev 258041)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-03-07 01:35:40 UTC (rev 258042)
@@ -920,8 +920,10 @@
     }
     
     Optional<WebCore::FrameIdentifier> frameID;
-    if (frame)
-        frameID = makeObjectIdentifier<WebCore::FrameIdentifierType>(frame._handle.frameID);
+    if (frame) {
+        if (uint64_t identifier = frame._handle.frameID)
+            frameID = makeObjectIdentifier<WebCore::FrameIdentifierType>(identifier);
+    }
 
     _page->runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters { _javascript_String, !!asAsyncFunction, WTFMove(argumentsMap), !!forceUserGesture }, frameID, *world->_contentWorld.get(), [handler](API::SerializedScriptValue* serializedScriptValue, Optional<WebCore::ExceptionDetails> details, WebKit::ScriptValueCallback::Error errorCode) {
         if (!handler)

Modified: trunk/Tools/ChangeLog (258041 => 258042)


--- trunk/Tools/ChangeLog	2020-03-07 01:31:19 UTC (rev 258041)
+++ trunk/Tools/ChangeLog	2020-03-07 01:35:40 UTC (rev 258042)
@@ -1,3 +1,12 @@
+2020-03-06  Alex Christensen  <[email protected]>
+
+        Evaluating _javascript_ in main frame before loading should succeed
+        https://bugs.webkit.org/show_bug.cgi?id=208733
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:
+
 2020-03-06  Ryosuke Niwa  <[email protected]>
 
         TextManipulationController should preserve images

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm (258041 => 258042)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm	2020-03-07 01:31:19 UTC (rev 258041)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm	2020-03-07 01:35:40 UTC (rev 258042)
@@ -31,6 +31,7 @@
 #import "TestNavigationDelegate.h"
 #import "TestURLSchemeHandler.h"
 #import "TestWKWebView.h"
+#import <WebKit/WKErrorPrivate.h>
 #import <WebKit/WKFrameInfoPrivate.h>
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKURLSchemeHandler.h>
@@ -1093,4 +1094,16 @@
         }];
     }];
     TestWebKitAPI::Util::run(&done);
+    
+    done = false;
+    auto emptyWebView = adoptNS([WKWebView new]);
+    [emptyWebView _frames:^(_WKFrameTreeNode *mainFrame) {
+        EXPECT_NOT_NULL(mainFrame._handle);
+        EXPECT_EQ(mainFrame._handle.frameID, 0u);
+        [emptyWebView _evaluateJavaScript:@"window.location.href" inFrame:mainFrame inContentWorld:[WKContentWorld defaultClientWorld] completionHandler:^(id result, NSError *error) {
+            EXPECT_WK_STREQ(result, "about:blank");
+            done = true;
+        }];
+    }];
+    TestWebKitAPI::Util::run(&done);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to