Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc

Issue 2817673003: Making Mac Dictionary better for OOPIFs and <webview> (Closed)
Patch Set: Added the interactive test which now passes both on OOPIF and non-OOPIF webview. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/render_widget_host_view_child_frame.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/test_timeouts.h"
12 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/apps/app_browsertest_util.h" 16 #include "chrome/browser/apps/app_browsertest_util.h"
16 #include "chrome/browser/chrome_content_browser_client.h" 17 #include "chrome/browser/chrome_content_browser_client.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h" 19 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h"
19 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h" 20 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h"
20 #include "chrome/test/base/interactive_test_utils.h" 21 #include "chrome/test/base/interactive_test_utils.h"
21 #include "chrome/test/base/test_launcher_utils.h" 22 #include "chrome/test/base/test_launcher_utils.h"
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 ASSERT_TRUE(ctx_listener.WaitUntilSatisfied()); 1356 ASSERT_TRUE(ctx_listener.WaitUntilSatisfied());
1356 1357
1357 // Now verify that the selection text propagates properly to RWHV. 1358 // Now verify that the selection text propagates properly to RWHV.
1358 content::RenderWidgetHostView* guest_rwhv = 1359 content::RenderWidgetHostView* guest_rwhv =
1359 guest_web_contents()->GetRenderWidgetHostView(); 1360 guest_web_contents()->GetRenderWidgetHostView();
1360 ASSERT_TRUE(guest_rwhv); 1361 ASSERT_TRUE(guest_rwhv);
1361 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); 1362 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText());
1362 ASSERT_TRUE(selected_text.size() >= 10u); 1363 ASSERT_TRUE(selected_text.size() >= 10u);
1363 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); 1364 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10));
1364 } 1365 }
1366
1367 // The original TextInputClientMessageFilter is added during the initialization
1368 // phase of RenderProcessHost. The only chance we have to add the test filter
1369 // (so that it can receive the TextInputClientMac incoming IPC messages) is
1370 // during the call to RenderProcessWillLaunch() on ContentBrowserClient. This
1371 // class provides that for testing.
1372 class TestBrowserClient : public ChromeContentBrowserClient {
1373 public:
1374 TestBrowserClient() {}
1375 ~TestBrowserClient() override {}
1376
1377 // ContentBrowserClient overrides.
1378 void RenderProcessWillLaunch(
1379 content::RenderProcessHost* process_host) override {
1380 ChromeContentBrowserClient::RenderProcessWillLaunch(process_host);
1381 filters_.push_back(
1382 new content::TestTextInputClientMessageFilter(process_host));
1383 }
1384
1385 // Retrieves the registered filter for the given RenderProcessHost. It will
1386 // return false if the RenderProcessHost was initialized while a different
1387 // instance of ContentBrowserClient was in action.
1388 scoped_refptr<content::TestTextInputClientMessageFilter>
1389 GetTextInputClientMessageFilterForProcess(
1390 content::RenderProcessHost* process_host) const {
1391 for (auto filter : filters_) {
1392 if (filter->process() == process_host)
1393 return filter;
1394 }
1395 return nullptr;
1396 }
1397
1398 private:
1399 std::vector<scoped_refptr<content::TestTextInputClientMessageFilter>>
1400 filters_;
1401
1402 DISALLOW_COPY_AND_ASSIGN(TestBrowserClient);
1403 };
1404
1405 // Verifies that asking for a word lookup from a guest's RWHV will open the
1406 // dictionary popup window.
1407 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, WordLookUp) {
1408 // TestBrowserClient needs to replace the ChromeContenBrowserClient after most
Avi (use Gerrit) 2017/04/13 14:48:53 typo: ChromeContentBrowserClient
EhsanK 2017/04/13 15:13:07 Thanks. Deleted most of the comment since we do no
1409 // things are initialized but before the WebContents is created. Here we make
1410 // that happen by creating a new WebContents in a new tab. But before the test
1411 // exits, we must destroy the contents and replace the old
1412 // ContentBrowserClient because the original WebContents and the new one have
1413 // been initialized with the original ContentBrowserClient and the new
1414 // TestBrowserClient, respectively.
1415 TestBrowserClient browser_client;
1416 content::ContentBrowserClient* old_browser_client =
1417 content::SetBrowserClientForTesting(&browser_client);
1418
1419 SetupTest("web_view/text_selection",
1420 "/extensions/platform_apps/web_view/text_selection/guest.html");
1421 ASSERT_TRUE(guest_web_contents());
1422 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(GetPlatformAppWindow()));
1423
1424 auto guest_message_filter =
1425 browser_client.GetTextInputClientMessageFilterForProcess(
1426 guest_web_contents()->GetRenderProcessHost());
1427 EXPECT_TRUE(guest_message_filter);
1428
1429 // Lookup some string through context menu.
1430 ContextMenuNotificationObserver menu_observer(IDC_CONTENT_CONTEXT_LOOK_UP);
1431 SimulateRWHMouseClick(guest_web_contents()->GetRenderViewHost()->GetWidget(),
1432 blink::WebMouseEvent::Button::kRight, 20, 20);
1433 // Wait for the response form the guest renderer.
1434 guest_message_filter->WaitForStringFromRange();
1435
1436 // Sanity check.
1437 ASSERT_EQ("AAAA", guest_message_filter->string_from_range().substr(0, 4));
1438
1439 content::SetBrowserClientForTesting(old_browser_client);
1440 }
1365 #endif 1441 #endif
1366 1442
1367 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, FocusAndVisibility) { 1443 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, FocusAndVisibility) {
1368 ASSERT_TRUE(StartEmbeddedTestServer()); 1444 ASSERT_TRUE(StartEmbeddedTestServer());
1369 LoadAndLaunchPlatformApp("web_view/focus_visibility", 1445 LoadAndLaunchPlatformApp("web_view/focus_visibility",
1370 "WebViewInteractiveTest.LOADED"); 1446 "WebViewInteractiveTest.LOADED");
1371 ExtensionTestMessageListener test_init_listener( 1447 ExtensionTestMessageListener test_init_listener(
1372 "WebViewInteractiveTest.WebViewInitialized", false); 1448 "WebViewInteractiveTest.WebViewInitialized", false);
1373 SendMessageToEmbedder(GetParam() ? "init-oopif" : "init"); 1449 SendMessageToEmbedder(GetParam() ? "init-oopif" : "init");
1374 test_init_listener.WaitUntilSatisfied(); 1450 test_init_listener.WaitUntilSatisfied();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 // Get the input value from the guest. 1665 // Get the input value from the guest.
1590 value.clear(); 1666 value.clear();
1591 ASSERT_TRUE(ExecuteScriptAndExtractString(guest_web_contents, 1667 ASSERT_TRUE(ExecuteScriptAndExtractString(guest_web_contents,
1592 "window.domAutomationController." 1668 "window.domAutomationController."
1593 "send(document.querySelector('" 1669 "send(document.querySelector('"
1594 "input').value)", 1670 "input').value)",
1595 &value)); 1671 &value));
1596 EXPECT_EQ("A B C D", value); 1672 EXPECT_EQ("A B C D", value);
1597 } 1673 }
1598 #endif // OS_MACOSX 1674 #endif // OS_MACOSX
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_widget_host_view_child_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698