| 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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 // WebContentsObserver | 427 // WebContentsObserver |
| 428 void DidGetUserInteraction(const blink::WebInputEvent::Type type) override { | 428 void DidGetUserInteraction(const blink::WebInputEvent::Type type) override { |
| 429 user_interaction_received_ = true; | 429 user_interaction_received_ = true; |
| 430 } | 430 } |
| 431 | 431 |
| 432 bool user_interaction_received_; | 432 bool user_interaction_received_; |
| 433 | 433 |
| 434 DISALLOW_COPY_AND_ASSIGN(UserInteractionObserver); | 434 DISALLOW_COPY_AND_ASSIGN(UserInteractionObserver); |
| 435 }; | 435 }; |
| 436 | 436 |
| 437 // This observer is used to wait for its owner FrameTreeNode to become focused. | |
| 438 class FrameFocusedObserver : public FrameTreeNode::Observer { | |
| 439 public: | |
| 440 FrameFocusedObserver(FrameTreeNode* owner) | |
| 441 : owner_(owner), message_loop_runner_(new MessageLoopRunner) { | |
| 442 owner->AddObserver(this); | |
| 443 } | |
| 444 | |
| 445 ~FrameFocusedObserver() override { owner_->RemoveObserver(this); } | |
| 446 | |
| 447 void Wait() { message_loop_runner_->Run(); } | |
| 448 | |
| 449 private: | |
| 450 // FrameTreeNode::Observer | |
| 451 void OnFrameTreeNodeFocused(FrameTreeNode* node) override { | |
| 452 if (node == owner_) | |
| 453 message_loop_runner_->Quit(); | |
| 454 } | |
| 455 | |
| 456 FrameTreeNode* owner_; | |
| 457 scoped_refptr<MessageLoopRunner> message_loop_runner_; | |
| 458 | |
| 459 DISALLOW_COPY_AND_ASSIGN(FrameFocusedObserver); | |
| 460 }; | |
| 461 | |
| 462 // This observer is used to wait for its owner FrameTreeNode to become deleted. | 437 // This observer is used to wait for its owner FrameTreeNode to become deleted. |
| 463 class FrameDeletedObserver : public FrameTreeNode::Observer { | 438 class FrameDeletedObserver : public FrameTreeNode::Observer { |
| 464 public: | 439 public: |
| 465 FrameDeletedObserver(FrameTreeNode* owner) | 440 FrameDeletedObserver(FrameTreeNode* owner) |
| 466 : owner_(owner), message_loop_runner_(new MessageLoopRunner) { | 441 : owner_(owner), message_loop_runner_(new MessageLoopRunner) { |
| 467 owner->AddObserver(this); | 442 owner->AddObserver(this); |
| 468 } | 443 } |
| 469 | 444 |
| 470 void Wait() { message_loop_runner_->Run(); } | 445 void Wait() { message_loop_runner_->Run(); } |
| 471 | 446 |
| 472 private: | 447 private: |
| 473 // FrameTreeNode::Observer | 448 // FrameTreeNode::Observer |
| 474 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) override { | 449 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) override { |
| 475 if (node == owner_) | 450 if (node == owner_) |
| 476 message_loop_runner_->Quit(); | 451 message_loop_runner_->Quit(); |
| 477 } | 452 } |
| 478 | 453 |
| 479 FrameTreeNode* owner_; | 454 FrameTreeNode* owner_; |
| 480 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 455 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 481 | 456 |
| 482 DISALLOW_COPY_AND_ASSIGN(FrameDeletedObserver); | 457 DISALLOW_COPY_AND_ASSIGN(FrameDeletedObserver); |
| 483 }; | 458 }; |
| 484 | 459 |
| 485 // Helper function to focus a frame by sending it a mouse click and then | 460 // Helper function to focus a frame by sending it a mouse click and then |
| 486 // waiting for it to become focused. | 461 // waiting for it to become focused. |
| 487 void FocusFrame(FrameTreeNode* frame) { | 462 void FocusFrame(FrameTreeNode* frame) { |
| 488 FrameFocusedObserver focus_observer(frame); | 463 FrameFocusedObserver focus_observer(frame->current_frame_host()); |
| 489 SimulateMouseClick(frame->current_frame_host()->GetRenderWidgetHost(), 1, 1); | 464 SimulateMouseClick(frame->current_frame_host()->GetRenderWidgetHost(), 1, 1); |
| 490 focus_observer.Wait(); | 465 focus_observer.Wait(); |
| 491 } | 466 } |
| 492 | 467 |
| 493 // A BrowserMessageFilter that drops SwapOut ACK messages. | 468 // A BrowserMessageFilter that drops SwapOut ACK messages. |
| 494 class SwapoutACKMessageFilter : public BrowserMessageFilter { | 469 class SwapoutACKMessageFilter : public BrowserMessageFilter { |
| 495 public: | 470 public: |
| 496 SwapoutACKMessageFilter() : BrowserMessageFilter(FrameMsgStart) {} | 471 SwapoutACKMessageFilter() : BrowserMessageFilter(FrameMsgStart) {} |
| 497 | 472 |
| 498 protected: | 473 protected: |
| (...skipping 7003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7502 | 7477 |
| 7503 shell()->web_contents()->WasShown(); | 7478 shell()->web_contents()->WasShown(); |
| 7504 | 7479 |
| 7505 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 7480 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
| 7506 root->child_at(0)->current_frame_host(), | 7481 root->child_at(0)->current_frame_host(), |
| 7507 "window.domAutomationController.send(event_fired);", &event_fired)); | 7482 "window.domAutomationController.send(event_fired);", &event_fired)); |
| 7508 EXPECT_EQ(2, event_fired); | 7483 EXPECT_EQ(2, event_fired); |
| 7509 } | 7484 } |
| 7510 | 7485 |
| 7511 } // namespace content | 7486 } // namespace content |
| OLD | NEW |