| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/win/metro.h" | 6 #include "base/win/metro.h" |
| 7 #include "content/public/browser/web_contents.h" | 7 #include "content/public/browser/web_contents.h" |
| 8 #include "content/public/common/content_switches.h" | 8 #include "content/public/common/content_switches.h" |
| 9 #include "content/public/test/test_utils.h" | 9 #include "content/public/test/test_utils.h" |
| 10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
| 11 #include "content/shell/shell.h" | 11 #include "content/shell/shell.h" |
| 12 #include "content/test/content_browser_test_utils.h" | 12 #include "content/test/content_browser_test_utils.h" |
| 13 #include "content/test/content_browser_test.h" | 13 #include "content/test/content_browser_test.h" |
| 14 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
| 15 #include "ui/base/ime/win/mock_tsf_bridge.h" | 15 #include "ui/base/ime/win/mock_tsf_bridge.h" |
| 16 #include "ui/base/ime/win/tsf_bridge.h" | 16 #include "ui/base/ime/win/tsf_bridge.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace content { |
| 19 class RenderWidgetHostViewWinTest : public content::ContentBrowserTest { | 19 class RenderWidgetHostViewWinTest : public ContentBrowserTest { |
| 20 public: | 20 public: |
| 21 RenderWidgetHostViewWinTest() {} | 21 RenderWidgetHostViewWinTest() {} |
| 22 | 22 |
| 23 virtual void SetUpCommandLine(CommandLine* command_line) { | 23 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 24 command_line->AppendSwitch(switches::kEnableTextServicesFramework); | 24 command_line->AppendSwitch(switches::kEnableTextServicesFramework); |
| 25 } | 25 } |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 // crbug.com/151798 | 28 // crbug.com/151798 |
| 29 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, | 29 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, |
| 30 DISABLED_SwichToPasswordField) { | 30 DISABLED_SwichToPasswordField) { |
| 31 ui::MockTsfBridge mock_bridge; | 31 ui::MockTsfBridge mock_bridge; |
| 32 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); | 32 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); |
| 33 GURL test_url = content::GetTestUrl("textinput", | 33 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); |
| 34 "ime_enable_disable_test.html"); | |
| 35 | 34 |
| 36 content::NavigateToURL(shell(), test_url); | 35 NavigateToURL(shell(), test_url); |
| 37 content::WaitForLoadStop(shell()->web_contents()); | 36 WaitForLoadStop(shell()->web_contents()); |
| 38 content::RunAllPendingInMessageLoop(); | 37 RunAllPendingInMessageLoop(); |
| 39 | 38 |
| 40 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); | 39 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); |
| 41 | 40 |
| 42 // Focus to the text field, the IME should be enabled. | 41 // Focus to the text field, the IME should be enabled. |
| 43 bool success = false; | 42 bool success = false; |
| 44 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 43 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 45 shell()->web_contents()->GetRenderViewHost(), L"", | 44 shell()->web_contents()->GetRenderViewHost(), L"", |
| 46 L"window.domAutomationController.send(text01_focus());", | 45 L"window.domAutomationController.send(text01_focus());", |
| 47 &success)); | 46 &success)); |
| 48 EXPECT_TRUE(success); | 47 EXPECT_TRUE(success); |
| 49 content::WaitForLoadStop(shell()->web_contents()); | 48 WaitForLoadStop(shell()->web_contents()); |
| 50 content::RunAllPendingInMessageLoop(); | 49 RunAllPendingInMessageLoop(); |
| 51 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); | 50 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); |
| 52 | 51 |
| 53 // Focus to the password field, the IME should be disabled. | 52 // Focus to the password field, the IME should be disabled. |
| 54 success = false; | 53 success = false; |
| 55 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 54 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 56 shell()->web_contents()->GetRenderViewHost(), L"", | 55 shell()->web_contents()->GetRenderViewHost(), L"", |
| 57 L"window.domAutomationController.send(password02_focus());", | 56 L"window.domAutomationController.send(password02_focus());", |
| 58 &success)); | 57 &success)); |
| 59 EXPECT_TRUE(success); | 58 EXPECT_TRUE(success); |
| 60 content::WaitForLoadStop(shell()->web_contents()); | 59 WaitForLoadStop(shell()->web_contents()); |
| 61 content::RunAllPendingInMessageLoop(); | 60 RunAllPendingInMessageLoop(); |
| 62 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); | 61 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); |
| 63 | 62 |
| 64 ui::TsfBridge::ReplaceForTesting(old_bridge); | 63 ui::TsfBridge::ReplaceForTesting(old_bridge); |
| 65 } | 64 } |
| 66 | 65 |
| 67 // crbug.com/151798 | 66 // crbug.com/151798 |
| 68 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, | 67 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, |
| 69 DISABLED_SwitchToSameField) { | 68 DISABLED_SwitchToSameField) { |
| 70 ui::MockTsfBridge mock_bridge; | 69 ui::MockTsfBridge mock_bridge; |
| 71 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); | 70 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); |
| 72 GURL test_url = content::GetTestUrl("textinput", | 71 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); |
| 73 "ime_enable_disable_test.html"); | |
| 74 | 72 |
| 75 content::NavigateToURL(shell(), test_url); | 73 NavigateToURL(shell(), test_url); |
| 76 content::WaitForLoadStop(shell()->web_contents()); | 74 WaitForLoadStop(shell()->web_contents()); |
| 77 content::RunAllPendingInMessageLoop(); | 75 RunAllPendingInMessageLoop(); |
| 78 | 76 |
| 79 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); | 77 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); |
| 80 | 78 |
| 81 // Focus to the text field, the IME should be enabled. | 79 // Focus to the text field, the IME should be enabled. |
| 82 bool success = false; | 80 bool success = false; |
| 83 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 81 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 84 shell()->web_contents()->GetRenderViewHost(), L"", | 82 shell()->web_contents()->GetRenderViewHost(), L"", |
| 85 L"window.domAutomationController.send(text01_focus());", | 83 L"window.domAutomationController.send(text01_focus());", |
| 86 &success)); | 84 &success)); |
| 87 EXPECT_TRUE(success); | 85 EXPECT_TRUE(success); |
| 88 content::WaitForLoadStop(shell()->web_contents()); | 86 WaitForLoadStop(shell()->web_contents()); |
| 89 content::RunAllPendingInMessageLoop(); | 87 RunAllPendingInMessageLoop(); |
| 90 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); | 88 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); |
| 91 | 89 |
| 92 // Focus to another text field, the IME should be enabled. | 90 // Focus to another text field, the IME should be enabled. |
| 93 success = false; | 91 success = false; |
| 94 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 92 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 95 shell()->web_contents()->GetRenderViewHost(), L"", | 93 shell()->web_contents()->GetRenderViewHost(), L"", |
| 96 L"window.domAutomationController.send(text02_focus());", | 94 L"window.domAutomationController.send(text02_focus());", |
| 97 &success)); | 95 &success)); |
| 98 EXPECT_TRUE(success); | 96 EXPECT_TRUE(success); |
| 99 content::WaitForLoadStop(shell()->web_contents()); | 97 WaitForLoadStop(shell()->web_contents()); |
| 100 content::RunAllPendingInMessageLoop(); | 98 RunAllPendingInMessageLoop(); |
| 101 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); | 99 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); |
| 102 | 100 |
| 103 ui::TsfBridge::ReplaceForTesting(old_bridge); | 101 ui::TsfBridge::ReplaceForTesting(old_bridge); |
| 104 } | 102 } |
| 105 | 103 |
| 106 // crbug.com/151798 | 104 // crbug.com/151798 |
| 107 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, | 105 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, |
| 108 DISABLED_SwitchToSamePasswordField) { | 106 DISABLED_SwitchToSamePasswordField) { |
| 109 ui::MockTsfBridge mock_bridge; | 107 ui::MockTsfBridge mock_bridge; |
| 110 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); | 108 ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); |
| 111 GURL test_url = content::GetTestUrl("textinput", | 109 GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); |
| 112 "ime_enable_disable_test.html"); | |
| 113 | 110 |
| 114 content::NavigateToURL(shell(), test_url); | 111 NavigateToURL(shell(), test_url); |
| 115 content::WaitForLoadStop(shell()->web_contents()); | 112 WaitForLoadStop(shell()->web_contents()); |
| 116 content::RunAllPendingInMessageLoop(); | 113 RunAllPendingInMessageLoop(); |
| 117 | 114 |
| 118 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); | 115 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, mock_bridge.latest_text_iput_type()); |
| 119 | 116 |
| 120 // Focus to the password field, the IME should be disabled. | 117 // Focus to the password field, the IME should be disabled. |
| 121 bool success = false; | 118 bool success = false; |
| 122 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 119 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 123 shell()->web_contents()->GetRenderViewHost(), L"", | 120 shell()->web_contents()->GetRenderViewHost(), L"", |
| 124 L"window.domAutomationController.send(password01_focus());", | 121 L"window.domAutomationController.send(password01_focus());", |
| 125 &success)); | 122 &success)); |
| 126 EXPECT_TRUE(success); | 123 EXPECT_TRUE(success); |
| 127 content::WaitForLoadStop(shell()->web_contents()); | 124 WaitForLoadStop(shell()->web_contents()); |
| 128 content::RunAllPendingInMessageLoop(); | 125 RunAllPendingInMessageLoop(); |
| 129 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); | 126 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); |
| 130 | 127 |
| 131 // Focus to the another password field, the IME should be disabled. | 128 // Focus to the another password field, the IME should be disabled. |
| 132 success = false; | 129 success = false; |
| 133 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( | 130 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool( |
| 134 shell()->web_contents()->GetRenderViewHost(), L"", | 131 shell()->web_contents()->GetRenderViewHost(), L"", |
| 135 L"window.domAutomationController.send(password02_focus());", | 132 L"window.domAutomationController.send(password02_focus());", |
| 136 &success)); | 133 &success)); |
| 137 EXPECT_TRUE(success); | 134 EXPECT_TRUE(success); |
| 138 content::WaitForLoadStop(shell()->web_contents()); | 135 WaitForLoadStop(shell()->web_contents()); |
| 139 content::RunAllPendingInMessageLoop(); | 136 RunAllPendingInMessageLoop(); |
| 140 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); | 137 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); |
| 141 | 138 |
| 142 ui::TsfBridge::ReplaceForTesting(old_bridge); | 139 ui::TsfBridge::ReplaceForTesting(old_bridge); |
| 143 } | 140 } |
| 144 } // namespace | 141 |
| 142 } // namespace content |
| OLD | NEW |