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

Side by Side Diff: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc

Issue 2054163003: Fix SitePerProcessTextInputManagerTest.StopTrackingCrashedChildFrame on CFI Bots. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not assume we only have 2 views registered in the begining. Created 4 years, 6 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
OLDNEW
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 "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Make sure that the first view has set its TextInputState.type to NONE. 316 // Make sure that the first view has set its TextInputState.type to NONE.
317 view_type_observer.Wait(); 317 view_type_observer.Wait();
318 318
319 // Verify that we are tracking the TextInputState from the first frame. 319 // Verify that we are tracking the TextInputState from the first frame.
320 content::RenderWidgetHostView* first_view = frames[0]->GetView(); 320 content::RenderWidgetHostView* first_view = frames[0]->GetView();
321 ui::TextInputType first_view_type; 321 ui::TextInputType first_view_type;
322 EXPECT_TRUE(content::GetTextInputTypeForView(active_contents(), first_view, 322 EXPECT_TRUE(content::GetTextInputTypeForView(active_contents(), first_view,
323 &first_view_type)); 323 &first_view_type));
324 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, first_view_type); 324 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, first_view_type);
325 325
326 size_t registered_views_count =
EhsanK 2016/06/11 10:26:56 I was expecting this number to be 2U as it was in
327 content::GetAllViewsRegisteredWithTextInputManager(active_contents())
Charlie Reis 2016/06/13 18:46:13 We should just expose the count if we don't need t
EhsanK 2016/06/25 00:10:34 Acknowledged.
328 .size();
329
326 // Now that the second frame's <input> is focused, we crash the first frame 330 // Now that the second frame's <input> is focused, we crash the first frame
327 // and observe that text input state is updated for the view. 331 // and observe that text input state is updated for the view.
328 std::unique_ptr<content::TestRenderWidgetHostViewDestructionObserver> 332 std::unique_ptr<content::TestRenderWidgetHostViewDestructionObserver>
329 destruction_observer( 333 destruction_observer(
330 new content::TestRenderWidgetHostViewDestructionObserver(first_view)); 334 new content::TestRenderWidgetHostViewDestructionObserver(first_view));
331 frames[0]->GetProcess()->Shutdown(0, false); 335 frames[0]->GetProcess()->Shutdown(0, false);
332 destruction_observer->Wait(); 336 destruction_observer->Wait();
333 337
334 // Verifying that the TextInputManager is no longer tracking TextInputState 338 // Verifying that the TextInputManager is no longer tracking TextInputState
335 // for |first_view|. Note that |first_view| is now a dangling pointer. 339 // for |first_view|.
336 EXPECT_FALSE(content::GetTextInputTypeForView(active_contents(), first_view, 340 EXPECT_EQ(
337 &first_view_type)); 341 registered_views_count - 1U,
342 content::GetAllViewsRegisteredWithTextInputManager(active_contents())
343 .size());
338 344
339 // Now crash the second <iframe> which has an active view. 345 // Now crash the second <iframe> which has an active view.
340 content::RenderWidgetHostView* second_view = frames[1]->GetView();
341 TextInputManagerChangeObserver change_observer(active_contents()); 346 TextInputManagerChangeObserver change_observer(active_contents());
342 frames[1]->GetProcess()->Shutdown(0, false); 347 frames[1]->GetProcess()->Shutdown(0, false);
343 change_observer.Wait(); 348 change_observer.Wait();
344 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, 349 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
345 content::GetTextInputTypeFromWebContents(active_contents())); 350 content::GetTextInputTypeFromWebContents(active_contents()));
346 EXPECT_FALSE(!!content::GetActiveViewFromWebContents(active_contents())); 351 EXPECT_FALSE(!!content::GetActiveViewFromWebContents(active_contents()));
347 ui::TextInputType second_view_type; 352 EXPECT_EQ(
348 EXPECT_FALSE(content::GetTextInputTypeForView(active_contents(), second_view, 353 registered_views_count - 2U,
349 &second_view_type)); 354 content::GetAllViewsRegisteredWithTextInputManager(active_contents())
355 .size());
350 } 356 }
351 357
352 // The following test loads a page with two child frames: one in process and one 358 // The following test loads a page with two child frames: one in process and one
353 // out of process with main frame. The test inserts an <input> inside each frame 359 // out of process with main frame. The test inserts an <input> inside each frame
354 // and focuses the first frame and observes the TextInputManager setting the 360 // and focuses the first frame and observes the TextInputManager setting the
355 // state to ui::TEXT_INPUT_TYPE_TEXT. Then, the frame is detached and the test 361 // state to ui::TEXT_INPUT_TYPE_TEXT. Then, the frame is detached and the test
356 // observes that the state type is reset to ui::TEXT_INPUT_TYPE_NONE. The same 362 // observes that the state type is reset to ui::TEXT_INPUT_TYPE_NONE. The same
357 // sequence of actions is then performed on the out of process frame. 363 // sequence of actions is then performed on the out of process frame.
358 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, 364 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
359 ResetStateAfterFrameDetached) { 365 ResetStateAfterFrameDetached) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 EXPECT_FALSE(send_and_check_show_ime()); 554 EXPECT_FALSE(send_and_check_show_ime());
549 555
550 // Set |TextInputState.show_ime_if_needed|. Expect IME. 556 // Set |TextInputState.show_ime_if_needed|. Expect IME.
551 sender.SetShowImeIfNeeded(true); 557 sender.SetShowImeIfNeeded(true);
552 EXPECT_TRUE(send_and_check_show_ime()); 558 EXPECT_TRUE(send_and_check_show_ime());
553 559
554 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. 560 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME.
555 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); 561 sender.SetType(ui::TEXT_INPUT_TYPE_NONE);
556 EXPECT_FALSE(send_and_check_show_ime()); 562 EXPECT_FALSE(send_and_check_show_ime());
557 } 563 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/text_input_manager.h » ('j') | content/browser/renderer_host/text_input_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698