Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (281227 => 281228)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm 2021-08-19 08:40:05 UTC (rev 281227)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm 2021-08-19 08:46:05 UTC (rev 281228)
@@ -432,6 +432,7 @@
[[configuration preferences] _setEnabled:YES forExperimentalFeature:webAuthenticationExperimentalFeature()];
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Succeeded!"];
@@ -446,6 +447,7 @@
[[configuration preferences] _setEnabled:YES forExperimentalFeature:webAuthenticationExperimentalFeature()];
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Succeeded!"];
@@ -463,6 +465,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -485,6 +488,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -513,6 +517,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsRacy:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -537,6 +542,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsRacy:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -560,6 +566,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -583,6 +590,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -603,6 +611,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -623,6 +632,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -642,6 +652,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -680,6 +691,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
auto port = static_cast<unsigned>(server.port());
auto url = "" port);
@@ -724,6 +736,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:(id)makeString("http://localhost:", server.port())]]];
Util::run(&webAuthenticationPanelRan);
@@ -743,6 +756,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -763,6 +777,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -781,6 +796,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -800,6 +816,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsFake:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -819,6 +836,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsFake:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -838,6 +856,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsNull:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -857,6 +876,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsNull:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -876,6 +896,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -895,6 +916,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelRan);
@@ -915,6 +937,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelCancelImmediately = true;
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -933,6 +956,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelCancelImmediately = true;
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -949,6 +973,7 @@
[[configuration preferences] _setEnabled:NO forExperimentalFeature:webAuthenticationModernExperimentalFeature()];
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Unknown internal error. Error code: 2"];
}
@@ -963,6 +988,7 @@
[[configuration preferences] _setEnabled:NO forExperimentalFeature:webAuthenticationModernExperimentalFeature()];
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Unknown internal error. Error code: 2"];
}
@@ -977,6 +1003,7 @@
[[configuration preferences] _setEnabled:NO forExperimentalFeature:webAuthenticationModernExperimentalFeature()];
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Pin is null."];
}
@@ -994,6 +1021,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsNull:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Pin is null."];
@@ -1011,6 +1039,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "123";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1031,6 +1060,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1051,6 +1081,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1071,6 +1102,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1090,6 +1122,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1109,6 +1142,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1127,6 +1161,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1147,6 +1182,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1166,6 +1202,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1184,6 +1221,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1204,6 +1242,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1224,6 +1263,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
webAuthenticationPanelPin = "1234";
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1244,6 +1284,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsNull:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Operation timed out."];
@@ -1261,6 +1302,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Succeeded!"];
@@ -1283,6 +1325,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelUpdateLAError);
@@ -1300,6 +1343,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
ASSERT_TRUE(addKeyToKeychain(testES256PrivateKeyBase64, "", testUserEntityBundleBase64));
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1319,6 +1363,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::run(&webAuthenticationPanelUpdateLANoCredential);
@@ -1337,6 +1382,7 @@
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[delegate setIsNull:true];
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Disallow local authenticator."];
@@ -1354,6 +1400,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"Disallow local authenticator."];
@@ -1371,6 +1418,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
localAuthenticatorPolicy = _WKLocalAuthenticatorPolicyAllow;
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1391,6 +1439,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"This request has been cancelled by the user."];
@@ -1408,6 +1457,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
localAuthenticatorPolicy = _WKLocalAuthenticatorPolicyAllow;
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1441,6 +1491,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
ASSERT_TRUE(addKeyToKeychain(testES256PrivateKeyBase64, "", testUserEntityBundleBase64));
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
@@ -1461,6 +1512,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
[webView waitForMessage:@"This request has been cancelled by the user."];
@@ -1478,6 +1530,7 @@
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
[webView setUIDelegate:delegate.get()];
+ [webView focus];
ASSERT_TRUE(addKeyToKeychain(testES256PrivateKeyBase64, "", testUserEntityBundleBase64));
ASSERT_TRUE(addKeyToKeychain("BBRoi2JbR0IXTeJmvXUp1YIuM4sph/Lu3eGf75F7n+HojHKG70a4R0rB2PQce5/SJle6T7OO5Cqet/LJZVM6NQ8yDDxWvayf71GTDp2yUtuIbqJLFVbpWymlj9WRizgX3A==", "", "omJpZEoAAQIDBAUGBwgJZG5hbWVkSmFuZQ=="/* { "id": h'00010203040506070809', "name": "Jane" } */));
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp (281227 => 281228)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp 2021-08-19 08:40:05 UTC (rev 281227)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp 2021-08-19 08:46:05 UTC (rev 281228)
@@ -798,6 +798,42 @@
g_assert_true(WebViewTest::_javascript_ResultToBoolean(_javascript_Result));
}
+static void testWebViewDocumentFocus(WebViewTest* test, gconstpointer)
+{
+ if (!g_strcmp0(g_getenv("UNDER_XVFB"), "yes")) {
+ g_test_skip("This tests doesn't work under Xvfb");
+ return;
+ }
+
+ test->showInWindow();
+ test->loadHtml("<html><title></title>"
+ "<body _onload_='document.getElementById(\"editable\").focus()'>"
+ "<input id='editable'></input>"
+ "<script>"
+ "document.addEventListener(\"visibilitychange\", onVisibilityChange, false);"
+ "function onVisibilityChange() {"
+ " document.title = document.visibilityState;"
+ "}"
+ "</script>"
+ "</body></html>",
+ nullptr);
+ test->waitUntilLoadFinished();
+
+ GUniqueOutPtr<GError> error;
+ WebKitJavascriptResult* _javascript_Result = test->runJavaScriptAndWaitUntilFinished("document.hasFocus();", &error.outPtr());
+ g_assert_nonnull(_javascript_Result);
+ g_assert_no_error(error.get());
+ g_assert_true(WebViewTest::_javascript_ResultToBoolean(_javascript_Result));
+
+ // Hide the view to make it lose the focus, the window is still the active one though.
+ test->hideView();
+ test->waitUntilTitleChangedTo("hidden");
+ _javascript_Result = test->runJavaScriptAndWaitUntilFinished("document.hasFocus();", &error.outPtr());
+ g_assert_nonnull(_javascript_Result);
+ g_assert_no_error(error.get());
+ g_assert_false(WebViewTest::_javascript_ResultToBoolean(_javascript_Result));
+}
+
#if PLATFORM(GTK)
class SnapshotWebViewTest: public WebViewTest {
public:
@@ -1709,6 +1745,7 @@
SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot);
#endif
WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
+ WebViewTest::add("WebKitWebView", "document-focus", testWebViewDocumentFocus);
#if ENABLE(NOTIFICATIONS)
NotificationWebViewTest::add("WebKitWebView", "notification", testWebViewNotification);
NotificationWebViewTest::add("WebKitWebView", "notification-initial-permission-allowed", testWebViewNotificationInitialPermissionAllowed);