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

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: Addressing creis@'s comments Created 4 years, 5 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/renderer_host/text_input_manager.h » ('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 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 bool success() const { return success_; } 66 bool success() const { return success_; }
67 67
68 protected: 68 protected:
69 content::TextInputManagerTester* tester() { return tester_.get(); } 69 content::TextInputManagerTester* tester() { return tester_.get(); }
70 70
71 void OnSuccess() { 71 void OnSuccess() {
72 success_ = true; 72 success_ = true;
73 if (message_loop_runner_) 73 if (message_loop_runner_)
74 message_loop_runner_->Quit(); 74 message_loop_runner_->Quit();
75
76 // By deleting |tester_| we make sure that the internal observer used in
77 // content/ is removed from the observer list of TextInputManager.
78 tester_.reset(nullptr);
75 } 79 }
76 80
77 private: 81 private:
78 std::unique_ptr<content::TextInputManagerTester> tester_; 82 std::unique_ptr<content::TextInputManagerTester> tester_;
79 bool success_; 83 bool success_;
80 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 84 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
81 85
82 DISALLOW_COPY_AND_ASSIGN(TextInputManagerObserverBase); 86 DISALLOW_COPY_AND_ASSIGN(TextInputManagerObserverBase);
83 }; 87 };
84 88
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Make sure that the first view has set its TextInputState.type to NONE. 320 // Make sure that the first view has set its TextInputState.type to NONE.
317 view_type_observer.Wait(); 321 view_type_observer.Wait();
318 322
319 // Verify that we are tracking the TextInputState from the first frame. 323 // Verify that we are tracking the TextInputState from the first frame.
320 content::RenderWidgetHostView* first_view = frames[0]->GetView(); 324 content::RenderWidgetHostView* first_view = frames[0]->GetView();
321 ui::TextInputType first_view_type; 325 ui::TextInputType first_view_type;
322 EXPECT_TRUE(content::GetTextInputTypeForView(active_contents(), first_view, 326 EXPECT_TRUE(content::GetTextInputTypeForView(active_contents(), first_view,
323 &first_view_type)); 327 &first_view_type));
324 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, first_view_type); 328 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, first_view_type);
325 329
330 size_t registered_views_count =
331 content::GetRegisteredViewsCountFromTextInputManager(active_contents());
332
333 DCHECK_GT(registered_views_count, 2U);
sky 2016/06/29 03:16:06 EXPECT?
EhsanK 2016/06/29 03:57:08 Done.
334
326 // Now that the second frame's <input> is focused, we crash the first frame 335 // 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. 336 // and observe that text input state is updated for the view.
328 std::unique_ptr<content::TestRenderWidgetHostViewDestructionObserver> 337 std::unique_ptr<content::TestRenderWidgetHostViewDestructionObserver>
329 destruction_observer( 338 destruction_observer(
330 new content::TestRenderWidgetHostViewDestructionObserver(first_view)); 339 new content::TestRenderWidgetHostViewDestructionObserver(first_view));
331 frames[0]->GetProcess()->Shutdown(0, false); 340 frames[0]->GetProcess()->Shutdown(0, false);
332 destruction_observer->Wait(); 341 destruction_observer->Wait();
333 342
334 // Verifying that the TextInputManager is no longer tracking TextInputState 343 // Verify that the TextInputManager is no longer tracking TextInputState for
335 // for |first_view|. Note that |first_view| is now a dangling pointer. 344 // |first_view|.
336 EXPECT_FALSE(content::GetTextInputTypeForView(active_contents(), first_view, 345 EXPECT_EQ(
337 &first_view_type)); 346 registered_views_count - 1U,
347 content::GetRegisteredViewsCountFromTextInputManager(active_contents()));
338 348
339 // Now crash the second <iframe> which has an active view. 349 // Now crash the second <iframe> which has an active view.
340 content::RenderWidgetHostView* second_view = frames[1]->GetView(); 350 destruction_observer.reset(
341 TextInputManagerChangeObserver change_observer(active_contents()); 351 new content::TestRenderWidgetHostViewDestructionObserver(
352 frames[1]->GetView()));
342 frames[1]->GetProcess()->Shutdown(0, false); 353 frames[1]->GetProcess()->Shutdown(0, false);
343 change_observer.Wait(); 354 destruction_observer->Wait();
344 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, 355
345 content::GetTextInputTypeFromWebContents(active_contents())); 356 EXPECT_EQ(
346 EXPECT_FALSE(!!content::GetActiveViewFromWebContents(active_contents())); 357 registered_views_count - 2U,
347 ui::TextInputType second_view_type; 358 content::GetRegisteredViewsCountFromTextInputManager(active_contents()));
348 EXPECT_FALSE(content::GetTextInputTypeForView(active_contents(), second_view,
349 &second_view_type));
350 } 359 }
351 360
352 // The following test loads a page with two child frames: one in process and one 361 // 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 362 // 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 363 // 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 364 // 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 365 // 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. 366 // sequence of actions is then performed on the out of process frame.
358 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, 367 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
359 ResetStateAfterFrameDetached) { 368 ResetStateAfterFrameDetached) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 EXPECT_FALSE(send_and_check_show_ime()); 557 EXPECT_FALSE(send_and_check_show_ime());
549 558
550 // Set |TextInputState.show_ime_if_needed|. Expect IME. 559 // Set |TextInputState.show_ime_if_needed|. Expect IME.
551 sender.SetShowImeIfNeeded(true); 560 sender.SetShowImeIfNeeded(true);
552 EXPECT_TRUE(send_and_check_show_ime()); 561 EXPECT_TRUE(send_and_check_show_ime());
553 562
554 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. 563 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME.
555 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); 564 sender.SetType(ui::TEXT_INPUT_TYPE_NONE);
556 EXPECT_FALSE(send_and_check_show_ime()); 565 EXPECT_FALSE(send_and_check_show_ime());
557 } 566 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/text_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698