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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1934703002: Fix keyboard focus for OOPIF-<webview>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test flakiness and comments in PS 7,8. 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 (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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // WebContentsObserver 400 // WebContentsObserver
401 void DidGetUserInteraction(const blink::WebInputEvent::Type type) override { 401 void DidGetUserInteraction(const blink::WebInputEvent::Type type) override {
402 user_interaction_received_ = true; 402 user_interaction_received_ = true;
403 } 403 }
404 404
405 bool user_interaction_received_; 405 bool user_interaction_received_;
406 406
407 DISALLOW_COPY_AND_ASSIGN(UserInteractionObserver); 407 DISALLOW_COPY_AND_ASSIGN(UserInteractionObserver);
408 }; 408 };
409 409
410 // This observer is used to wait for its owner FrameTreeNode to become focused.
411 class FrameFocusedObserver : public FrameTreeNode::Observer {
412 public:
413 FrameFocusedObserver(FrameTreeNode* owner)
414 : owner_(owner), message_loop_runner_(new MessageLoopRunner) {
415 owner->AddObserver(this);
416 }
417
418 ~FrameFocusedObserver() override { owner_->RemoveObserver(this); }
419
420 void Wait() { message_loop_runner_->Run(); }
421
422 private:
423 // FrameTreeNode::Observer
424 void OnFrameTreeNodeFocused(FrameTreeNode* node) override {
425 if (node == owner_)
426 message_loop_runner_->Quit();
427 }
428
429 FrameTreeNode* owner_;
430 scoped_refptr<MessageLoopRunner> message_loop_runner_;
431
432 DISALLOW_COPY_AND_ASSIGN(FrameFocusedObserver);
433 };
434
435 // This observer is used to wait for its owner FrameTreeNode to become deleted. 410 // This observer is used to wait for its owner FrameTreeNode to become deleted.
436 class FrameDeletedObserver : public FrameTreeNode::Observer { 411 class FrameDeletedObserver : public FrameTreeNode::Observer {
437 public: 412 public:
438 FrameDeletedObserver(FrameTreeNode* owner) 413 FrameDeletedObserver(FrameTreeNode* owner)
439 : owner_(owner), message_loop_runner_(new MessageLoopRunner) { 414 : owner_(owner), message_loop_runner_(new MessageLoopRunner) {
440 owner->AddObserver(this); 415 owner->AddObserver(this);
441 } 416 }
442 417
443 void Wait() { message_loop_runner_->Run(); } 418 void Wait() { message_loop_runner_->Run(); }
444 419
445 private: 420 private:
446 // FrameTreeNode::Observer 421 // FrameTreeNode::Observer
447 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) override { 422 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) override {
448 if (node == owner_) 423 if (node == owner_)
449 message_loop_runner_->Quit(); 424 message_loop_runner_->Quit();
450 } 425 }
451 426
452 FrameTreeNode* owner_; 427 FrameTreeNode* owner_;
453 scoped_refptr<MessageLoopRunner> message_loop_runner_; 428 scoped_refptr<MessageLoopRunner> message_loop_runner_;
454 429
455 DISALLOW_COPY_AND_ASSIGN(FrameDeletedObserver); 430 DISALLOW_COPY_AND_ASSIGN(FrameDeletedObserver);
456 }; 431 };
457 432
458 // Helper function to focus a frame by sending it a mouse click and then 433 // Helper function to focus a frame by sending it a mouse click and then
459 // waiting for it to become focused. 434 // waiting for it to become focused.
460 void FocusFrame(FrameTreeNode* frame) { 435 void FocusFrame(FrameTreeNode* frame) {
461 FrameFocusedObserver focus_observer(frame); 436 FrameFocusedObserver focus_observer(frame->current_frame_host());
462 SimulateMouseClick(frame->current_frame_host()->GetRenderWidgetHost(), 1, 1); 437 SimulateMouseClick(frame->current_frame_host()->GetRenderWidgetHost(), 1, 1);
463 focus_observer.Wait(); 438 focus_observer.Wait();
464 } 439 }
465 440
466 // A BrowserMessageFilter that drops SwapOut ACK messages. 441 // A BrowserMessageFilter that drops SwapOut ACK messages.
467 class SwapoutACKMessageFilter : public BrowserMessageFilter { 442 class SwapoutACKMessageFilter : public BrowserMessageFilter {
468 public: 443 public:
469 SwapoutACKMessageFilter() : BrowserMessageFilter(FrameMsgStart) {} 444 SwapoutACKMessageFilter() : BrowserMessageFilter(FrameMsgStart) {}
470 445
471 protected: 446 protected:
(...skipping 6737 matching lines...) Expand 10 before | Expand all | Expand 10 after
7209 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); 7184 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
7210 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7185 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7211 7186
7212 // Cross-site navigation should preserve the fullscreen flags. 7187 // Cross-site navigation should preserve the fullscreen flags.
7213 NavigateFrameToURL(root->child_at(0)->child_at(0), 7188 NavigateFrameToURL(root->child_at(0)->child_at(0),
7214 embedded_test_server()->GetURL("d.com", "/title1.html")); 7189 embedded_test_server()->GetURL("d.com", "/title1.html"));
7215 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7190 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7216 } 7191 }
7217 7192
7218 } // namespace content 7193 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698