| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_content_browser_client.h" | 9 #include "chrome/browser/chrome_content_browser_client.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB, | 631 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB, |
| 632 ui::VKEY_TAB, false, false, false, false); | 632 ui::VKEY_TAB, false, false, false, false); |
| 633 set_state_observer.Wait(); | 633 set_state_observer.Wait(); |
| 634 | 634 |
| 635 TextInputManagerTypeObserver reset_state_observer(active_contents(), | 635 TextInputManagerTypeObserver reset_state_observer(active_contents(), |
| 636 ui::TEXT_INPUT_TYPE_NONE); | 636 ui::TEXT_INPUT_TYPE_NONE); |
| 637 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 637 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 638 reset_state_observer.Wait(); | 638 reset_state_observer.Wait(); |
| 639 } | 639 } |
| 640 | 640 |
| 641 // This test verifies that if we have a focused <input> in the main frame and |
| 642 // the tab is closed, TextInputManager handles unregistering itself and |
| 643 // notifying the observers properly (see https://crbug.com/669375). |
| 644 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| 645 ClosingTabWillNotCrash) { |
| 646 CreateIframePage("a()"); |
| 647 content::RenderFrameHost* main_frame = GetFrame(IndexVector{}); |
| 648 AddInputFieldToFrame(main_frame, "text", "", false); |
| 649 |
| 650 // Focus the input and wait for state update. |
| 651 TextInputManagerTypeObserver observer(active_contents(), |
| 652 ui::TEXT_INPUT_TYPE_TEXT); |
| 653 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB, |
| 654 ui::VKEY_TAB, false, false, false, false); |
| 655 observer.Wait(); |
| 656 |
| 657 // Now destroy the tab. We should exit without crashing. |
| 658 browser()->tab_strip_model()->CloseWebContentsAt( |
| 659 0, TabStripModel::CLOSE_USER_GESTURE); |
| 660 } |
| 661 |
| 641 // The following test verifies that when the active widget changes value, it is | 662 // The following test verifies that when the active widget changes value, it is |
| 642 // always from nullptr to non-null or vice versa. | 663 // always from nullptr to non-null or vice versa. |
| 643 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 664 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| 644 ResetTextInputStateOnActiveWidgetChange) { | 665 ResetTextInputStateOnActiveWidgetChange) { |
| 645 CreateIframePage("a(b,c(a,b),d)"); | 666 CreateIframePage("a(b,c(a,b),d)"); |
| 646 std::vector<content::RenderFrameHost*> frames{ | 667 std::vector<content::RenderFrameHost*> frames{ |
| 647 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), | 668 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), |
| 648 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), | 669 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), |
| 649 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; | 670 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; |
| 650 std::vector<content::RenderWidgetHostView*> views; | 671 std::vector<content::RenderWidgetHostView*> views; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 content::RenderFrameHost* frame = frames[i / 2]; | 861 content::RenderFrameHost* frame = frames[i / 2]; |
| 841 FocusFormField(frame, values[i]); | 862 FocusFormField(frame, values[i]); |
| 842 FormFieldDataVerifier verifier(values[i], placeholders[i]); | 863 FormFieldDataVerifier verifier(values[i], placeholders[i]); |
| 843 content::FormFieldDataCallback callback = | 864 content::FormFieldDataCallback callback = |
| 844 base::Bind(&FormFieldDataVerifier::Verify, base::Unretained(&verifier)); | 865 base::Bind(&FormFieldDataVerifier::Verify, base::Unretained(&verifier)); |
| 845 frame->RequestFocusedFormFieldData(callback); | 866 frame->RequestFocusedFormFieldData(callback); |
| 846 verifier.Wait(); | 867 verifier.Wait(); |
| 847 } | 868 } |
| 848 } | 869 } |
| 849 | 870 |
| 850 | |
| 851 // TODO(ekaramad): The following tests are specifically written for Aura and are | 871 // TODO(ekaramad): The following tests are specifically written for Aura and are |
| 852 // based on InputMethodObserver. Write similar tests for Mac/Android/Mus | 872 // based on InputMethodObserver. Write similar tests for Mac/Android/Mus |
| 853 // (crbug.com/602723). | 873 // (crbug.com/602723). |
| 854 #if defined(USE_AURA) | 874 #if defined(USE_AURA) |
| 855 // ----------------------------------------------------------------------------- | 875 // ----------------------------------------------------------------------------- |
| 856 // Input Method Observer Tests | 876 // Input Method Observer Tests |
| 857 // | 877 // |
| 858 // The following tests will make use of the InputMethodObserver to verify that | 878 // The following tests will make use of the InputMethodObserver to verify that |
| 859 // OOPIF pages interact properly with the InputMethod through the tab's view. | 879 // OOPIF pages interact properly with the InputMethod through the tab's view. |
| 860 | 880 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 | 1242 |
| 1223 // Closing this WebContents while we still hold on to our TestBrowserClient. | 1243 // Closing this WebContents while we still hold on to our TestBrowserClient. |
| 1224 EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt( | 1244 EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt( |
| 1225 1, TabStripModel::CLOSE_USER_GESTURE)); | 1245 1, TabStripModel::CLOSE_USER_GESTURE)); |
| 1226 | 1246 |
| 1227 // For the cleanup of the original WebContents in tab index 0. | 1247 // For the cleanup of the original WebContents in tab index 0. |
| 1228 content::SetBrowserClientForTesting(old_browser_client); | 1248 content::SetBrowserClientForTesting(old_browser_client); |
| 1229 } | 1249 } |
| 1230 #endif // defined(MAC_OSX) | 1250 #endif // defined(MAC_OSX) |
| 1231 #endif // !defined(OS_ANDROID) | 1251 #endif // !defined(OS_ANDROID) |
| OLD | NEW |