[GTK] MiniBrowser: web view doesn't get the focus when new window is created
https://bugs.webkit.org/show_bug.cgi?id=188546

Reviewed by Michael Catanzaro.

Tools:

When a new window is created, the first widget of the windo is getting the focus, the toolbar in this case. We
always want the WebView to grab the focus. In case of new empty tab, we want to the URL bar to be focused
instead. This was causing failures in WebDriver tests that create a popup window with an input element that is
filled with send keys command. The input element is marked as focused in the DOM, but the actual focused widget
is the toolbar, so key events are sent to the toolbar instead of the web view.

* MiniBrowser/gtk/BrowserWindow.c:
(webViewCreate):
(newTabCallback):
(openPrivateWindow):
(browser_window_get_or_create_web_view_for_automation):

WebDriverTests:

Remove expectations of the tests that pass now.

* TestExpectations.json:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@234915 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index b48cf79..5ace334 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,5 +1,24 @@
 2018-08-16  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] MiniBrowser: web view doesn't get the focus when new window is created
+        https://bugs.webkit.org/show_bug.cgi?id=188546
+
+        Reviewed by Michael Catanzaro.
+
+        When a new window is created, the first widget of the windo is getting the focus, the toolbar in this case. We
+        always want the WebView to grab the focus. In case of new empty tab, we want to the URL bar to be focused
+        instead. This was causing failures in WebDriver tests that create a popup window with an input element that is
+        filled with send keys command. The input element is marked as focused in the DOM, but the actual focused widget
+        is the toolbar, so key events are sent to the toolbar instead of the web view.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (webViewCreate):
+        (newTabCallback):
+        (openPrivateWindow):
+        (browser_window_get_or_create_web_view_for_automation):
+
+2018-08-16  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         Unreviewed. Fix WebDriver tests after r234839.
 
         New pytest requires to autoinstall attrs too.
diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.c b/Tools/MiniBrowser/gtk/BrowserWindow.c
index 36b3065..d559835 100644
--- a/Tools/MiniBrowser/gtk/BrowserWindow.c
+++ b/Tools/MiniBrowser/gtk/BrowserWindow.c
@@ -338,6 +338,7 @@
 
     GtkWidget *newWindow = browser_window_new(GTK_WINDOW(window), window->webContext);
     browser_window_append_view(BROWSER_WINDOW(newWindow), newWebView);
+    gtk_widget_grab_focus(GTK_WIDGET(newWebView));
     g_signal_connect(newWebView, "ready-to-show", G_CALLBACK(webViewReadyToShow), newWindow);
     g_signal_connect(newWebView, "run-as-modal", G_CALLBACK(webViewRunAsModal), newWindow);
     g_signal_connect(newWebView, "close", G_CALLBACK(webViewClose), newWindow);
@@ -528,6 +529,7 @@
         "user-content-manager", webkit_web_view_get_user_content_manager(webView),
         "is-controlled-by-automation", webkit_web_view_is_controlled_by_automation(webView),
         NULL)));
+    gtk_widget_grab_focus(window->uriEntry);
     gtk_notebook_set_current_page(GTK_NOTEBOOK(window->notebook), -1);
 }
 
@@ -548,6 +550,7 @@
         NULL));
     GtkWidget *newWindow = browser_window_new(GTK_WINDOW(window), window->webContext);
     browser_window_append_view(BROWSER_WINDOW(newWindow), newWebView);
+    gtk_widget_grab_focus(GTK_WIDGET(newWebView));
     gtk_widget_show(GTK_WIDGET(newWindow));
 }
 
@@ -1233,5 +1236,6 @@
         "is-controlled-by-automation", TRUE,
         NULL));
     browser_window_append_view(window, newWebView);
+    gtk_widget_grab_focus(GTK_WIDGET(newWebView));
     return newWebView;
 }
diff --git a/WebDriverTests/ChangeLog b/WebDriverTests/ChangeLog
index 0b468d8..e27d2b0 100644
--- a/WebDriverTests/ChangeLog
+++ b/WebDriverTests/ChangeLog
@@ -1,3 +1,14 @@
+2018-08-16  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] MiniBrowser: web view doesn't get the focus when new window is created
+        https://bugs.webkit.org/show_bug.cgi?id=188546
+
+        Reviewed by Michael Catanzaro.
+
+        Remove expectations of the tests that pass now.
+
+        * TestExpectations.json:
+
 2018-08-14  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed gardening. Update several test expectations after r234839.
diff --git a/WebDriverTests/TestExpectations.json b/WebDriverTests/TestExpectations.json
index 14cd22a..b33a22a 100644
--- a/WebDriverTests/TestExpectations.json
+++ b/WebDriverTests/TestExpectations.json
@@ -478,20 +478,10 @@
             }
         }
     },
-    "imported/w3c/webdriver/tests/back/back.py": {
-        "subtests": {
-            "test_dismissed_beforeunload": {
-                "expected": {"all": {"status": ["TIMEOUT"], "bug": "webkit.org/b/188546"}}
-            }
-        }
-    },
     "imported/w3c/webdriver/tests/close_window/close.py": {
         "subtests": {
             "test_close_last_browsing_context": {
                 "expected": {"gtk": {"status": ["FAIL", "PASS"], "bug": "webkit.org/b/188118"}}
-            },
-            "test_close_browsing_context_with_dismissed_beforeunload_prompt": {
-                "expected": {"all": {"status": ["TIMEOUT"], "bug": "webkit.org/b/188546"}}
             }
         }
     },
@@ -607,13 +597,6 @@
             }
         }
     },
-    "imported/w3c/webdriver/tests/forward/forward.py": {
-        "subtests": {
-            "test_dismissed_beforeunload": {
-                "expected": {"all": {"status": ["TIMEOUT"], "bug": "webkit.org/b/188546"}}
-            }
-        }
-    },
     "imported/w3c/webdriver/tests/element_send_keys/events.py": {
         "subtests": {
             "test_file_upload": {