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

Side by Side Diff: chrome/browser/site_per_process_interactive_browsertest.cc

Issue 2040973003: OOPIF: Process all local ancestors when requesting and exiting fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_window.h" 8 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" 9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 gfx::Size GetScreenSize() { 45 gfx::Size GetScreenSize() {
46 content::WebContents* web_contents = 46 content::WebContents* web_contents =
47 browser()->tab_strip_model()->GetActiveWebContents(); 47 browser()->tab_strip_model()->GetActiveWebContents();
48 const display::Display display = 48 const display::Display display =
49 display::Screen::GetScreen()->GetDisplayNearestWindow( 49 display::Screen::GetScreen()->GetDisplayNearestWindow(
50 web_contents->GetRenderWidgetHostView()->GetNativeView()); 50 web_contents->GetRenderWidgetHostView()->GetNativeView());
51 return display.bounds().size(); 51 return display.bounds().size();
52 } 52 }
53 53
54 enum class FullscreenExitMethod {
55 JS_CALL,
56 ESC_PRESS,
57 };
58
59 void FullscreenElementInABA(FullscreenExitMethod exit_method);
60
54 private: 61 private:
55 DISALLOW_COPY_AND_ASSIGN(SitePerProcessInteractiveBrowserTest); 62 DISALLOW_COPY_AND_ASSIGN(SitePerProcessInteractiveBrowserTest);
56 }; 63 };
57 64
58 // Check that document.hasFocus() works properly with out-of-process iframes. 65 // Check that document.hasFocus() works properly with out-of-process iframes.
59 // The test builds a page with four cross-site frames and then focuses them one 66 // The test builds a page with four cross-site frames and then focuses them one
60 // by one, checking the value of document.hasFocus() in all frames. For any 67 // by one, checking the value of document.hasFocus() in all frames. For any
61 // given focused frame, document.hasFocus() should return true for that frame 68 // given focused frame, document.hasFocus() should return true for that frame
62 // and all its ancestor frames. 69 // and all its ancestor frames.
63 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest, DocumentHasFocus) { 70 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest, DocumentHasFocus) {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 EXPECT_FALSE(ElementHasFullscreenStyle(child, "fullscreen-div")); 462 EXPECT_FALSE(ElementHasFullscreenStyle(child, "fullscreen-div"));
456 EXPECT_FALSE(ElementHasFullscreenStyle(main_frame, "child-0")); 463 EXPECT_FALSE(ElementHasFullscreenStyle(main_frame, "child-0"));
457 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(main_frame, "child-0")); 464 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(main_frame, "child-0"));
458 465
459 // Check that both frames cleared their document.webkitFullscreenElement. 466 // Check that both frames cleared their document.webkitFullscreenElement.
460 EXPECT_EQ("none", GetFullscreenElementId(main_frame)); 467 EXPECT_EQ("none", GetFullscreenElementId(main_frame));
461 EXPECT_EQ("none", GetFullscreenElementId(child)); 468 EXPECT_EQ("none", GetFullscreenElementId(child));
462 } 469 }
463 470
464 // Check that on a page with A-embed-B-embed-A frame hierarchy, an element in 471 // Check that on a page with A-embed-B-embed-A frame hierarchy, an element in
465 // the bottom frame can enter and exit fullscreen. 472 // the bottom frame can enter and exit fullscreen. |exit_method| specifies
466 // 473 // whether to use browser-initiated vs. renderer-initiated fullscreen exit
467 // TODO(alexmos): For now, the test will verify sizing and fullscreen CSS 474 // (i.e., pressing escape vs. a JS call), since they trigger different code
468 // styles, but additional refactoring of Blink's Fullscreen class is required 475 // paths on the Blink side.
469 // to fully handle fullscreenchange events and webkitFullscreenElement in the 476 void SitePerProcessInteractiveBrowserTest::FullscreenElementInABA(
470 // main frame. 477 FullscreenExitMethod exit_method) {
471 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
472 FullscreenElementInABA) {
473 GURL main_url(embedded_test_server()->GetURL( 478 GURL main_url(embedded_test_server()->GetURL(
474 "a.com", "/cross_site_iframe_factory.html?a(b(a))")); 479 "a.com", "/cross_site_iframe_factory.html?a(b(a))"));
475 ui_test_utils::NavigateToURL(browser(), main_url); 480 ui_test_utils::NavigateToURL(browser(), main_url);
476 content::WebContents* web_contents = 481 content::WebContents* web_contents =
477 browser()->tab_strip_model()->GetActiveWebContents(); 482 browser()->tab_strip_model()->GetActiveWebContents();
478 483
479 content::RenderFrameHost* main_frame = web_contents->GetMainFrame(); 484 content::RenderFrameHost* main_frame = web_contents->GetMainFrame();
480 content::RenderFrameHost* child = ChildFrameAt(main_frame, 0); 485 content::RenderFrameHost* child = ChildFrameAt(main_frame, 0);
481 content::RenderFrameHost* grandchild = ChildFrameAt(child, 0); 486 content::RenderFrameHost* grandchild = ChildFrameAt(child, 0);
482 487
(...skipping 16 matching lines...) Expand all
499 504
500 // Add a resize event handler that will send a message when the grandchild 505 // Add a resize event handler that will send a message when the grandchild
501 // frame is resized to the screen size. Also save its original size. 506 // frame is resized to the screen size. Also save its original size.
502 AddResizeListener(grandchild, GetScreenSize()); 507 AddResizeListener(grandchild, GetScreenSize());
503 gfx::Size original_grandchild_size = GetFrameSize(grandchild); 508 gfx::Size original_grandchild_size = GetFrameSize(grandchild);
504 509
505 // Fullscreen a <div> inside the bottom subframe. This will block until 510 // Fullscreen a <div> inside the bottom subframe. This will block until
506 // (1) the fullscreenchange events in all frames send a response, and 511 // (1) the fullscreenchange events in all frames send a response, and
507 // (2) the frame is resized to fill the whole screen. 512 // (2) the frame is resized to fill the whole screen.
508 // (3) the browser has finished the fullscreen transition. 513 // (3) the browser has finished the fullscreen transition.
509 // 514 std::set<std::string> expected_events = {"main_frame", "child", "grandchild"};
510 // TODO(alexmos): Also wait for "main_frame" once
511 // blink::Fullscreen::requestFullscreen() and exitFullscreen() are fixed to
512 // process all local ancestors.
513 std::set<std::string> expected_events = {"child", "grandchild"};
514 { 515 {
515 content::DOMMessageQueue queue; 516 content::DOMMessageQueue queue;
516 std::unique_ptr<FullscreenNotificationObserver> observer( 517 std::unique_ptr<FullscreenNotificationObserver> observer(
517 new FullscreenNotificationObserver()); 518 new FullscreenNotificationObserver());
518 EXPECT_TRUE(ExecuteScript(grandchild, "activateFullscreen()")); 519 EXPECT_TRUE(ExecuteScript(grandchild, "activateFullscreen()"));
519 WaitForMultipleFullscreenEvents(expected_events, queue); 520 WaitForMultipleFullscreenEvents(expected_events, queue);
520 observer->Wait(); 521 observer->Wait();
521 } 522 }
522 523
523 // Verify that the browser has entered fullscreen for the current tab. 524 // Verify that the browser has entered fullscreen for the current tab.
524 EXPECT_TRUE(browser()->window()->IsFullscreen()); 525 EXPECT_TRUE(browser()->window()->IsFullscreen());
525 EXPECT_TRUE(browser()->exclusive_access_manager() 526 EXPECT_TRUE(browser()->exclusive_access_manager()
526 ->fullscreen_controller() 527 ->fullscreen_controller()
527 ->IsFullscreenForTabOrPending(web_contents)); 528 ->IsFullscreenForTabOrPending(web_contents));
528 529
529 // Verify that the <div> has fullscreen style in the bottom frame, and that 530 // Verify that the <div> has fullscreen style in the bottom frame, and that
530 // the proper <iframe> elements have fullscreen style in its ancestor frames. 531 // the proper <iframe> elements have fullscreen style in its ancestor frames.
531 EXPECT_TRUE(ElementHasFullscreenStyle(grandchild, "fullscreen-div")); 532 EXPECT_TRUE(ElementHasFullscreenStyle(grandchild, "fullscreen-div"));
532 EXPECT_TRUE(ElementHasFullscreenStyle(child, "child-0")); 533 EXPECT_TRUE(ElementHasFullscreenStyle(child, "child-0"));
533 EXPECT_TRUE(ElementHasFullscreenAncestorStyle(child, "child-0")); 534 EXPECT_TRUE(ElementHasFullscreenAncestorStyle(child, "child-0"));
534 EXPECT_TRUE(ElementHasFullscreenStyle(main_frame, "child-0")); 535 EXPECT_TRUE(ElementHasFullscreenStyle(main_frame, "child-0"));
535 EXPECT_TRUE(ElementHasFullscreenAncestorStyle(main_frame, "child-0")); 536 EXPECT_TRUE(ElementHasFullscreenAncestorStyle(main_frame, "child-0"));
536 537
537 // Check document.webkitFullscreenElement in all frames. 538 // Check document.webkitFullscreenElement in all frames.
539 EXPECT_EQ("child-0", GetFullscreenElementId(main_frame));
538 EXPECT_EQ("child-0", GetFullscreenElementId(child)); 540 EXPECT_EQ("child-0", GetFullscreenElementId(child));
539 EXPECT_EQ("fullscreen-div", GetFullscreenElementId(grandchild)); 541 EXPECT_EQ("fullscreen-div", GetFullscreenElementId(grandchild));
540 // TODO(alexmos): Also check that |main_frame|'s webkitFullscreenElement is
541 // "child-0" once blink::Fullscreen::requestFullscreen() is fixed to handle
542 // all local ancestors.
543 542
544 // Now exit fullscreen from the subframe. 543 // Now exit fullscreen from the subframe.
545 AddResizeListener(grandchild, original_grandchild_size); 544 AddResizeListener(grandchild, original_grandchild_size);
546 { 545 {
547 content::DOMMessageQueue queue; 546 content::DOMMessageQueue queue;
548 std::unique_ptr<FullscreenNotificationObserver> observer( 547 std::unique_ptr<FullscreenNotificationObserver> observer(
549 new FullscreenNotificationObserver()); 548 new FullscreenNotificationObserver());
550 EXPECT_TRUE(ExecuteScript(grandchild, "exitFullscreen()")); 549 switch (exit_method) {
550 case FullscreenExitMethod::JS_CALL:
551 EXPECT_TRUE(ExecuteScript(grandchild, "exitFullscreen()"));
552 break;
553 case FullscreenExitMethod::ESC_PRESS:
554 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE,
555 false, false, false,
556 false));
557 break;
558 default:
559 NOTREACHED();
560 }
551 WaitForMultipleFullscreenEvents(expected_events, queue); 561 WaitForMultipleFullscreenEvents(expected_events, queue);
552 observer->Wait(); 562 observer->Wait();
553 } 563 }
554 564
555 EXPECT_FALSE(browser()->window()->IsFullscreen()); 565 EXPECT_FALSE(browser()->window()->IsFullscreen());
556 566
557 // Verify that the fullscreen styles were removed from the <div> and its 567 // Verify that the fullscreen styles were removed from the <div> and its
558 // container <iframe>'s. 568 // container <iframe>'s.
559 EXPECT_FALSE(ElementHasFullscreenStyle(grandchild, "fullscreen-div")); 569 EXPECT_FALSE(ElementHasFullscreenStyle(grandchild, "fullscreen-div"));
560 EXPECT_FALSE(ElementHasFullscreenStyle(child, "child-0")); 570 EXPECT_FALSE(ElementHasFullscreenStyle(child, "child-0"));
561 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(child, "child-0")); 571 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(child, "child-0"));
562 EXPECT_FALSE(ElementHasFullscreenStyle(main_frame, "child-0")); 572 EXPECT_FALSE(ElementHasFullscreenStyle(main_frame, "child-0"));
563 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(main_frame, "child-0")); 573 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(main_frame, "child-0"));
564 574
565 // Check that document.webkitFullscreenElement was cleared in all three 575 // Check that document.webkitFullscreenElement was cleared in all three
566 // frames. 576 // frames.
567 EXPECT_EQ("none", GetFullscreenElementId(main_frame)); 577 EXPECT_EQ("none", GetFullscreenElementId(main_frame));
568 EXPECT_EQ("none", GetFullscreenElementId(child)); 578 EXPECT_EQ("none", GetFullscreenElementId(child));
569 EXPECT_EQ("none", GetFullscreenElementId(grandchild)); 579 EXPECT_EQ("none", GetFullscreenElementId(grandchild));
570 } 580 }
571 581
582 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
583 FullscreenElementInABAAndExitViaEscapeKey) {
584 FullscreenElementInABA(FullscreenExitMethod::ESC_PRESS);
585 }
586
587 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
588 FullscreenElementInABAAndExitViaJS) {
589 FullscreenElementInABA(FullscreenExitMethod::JS_CALL);
590 }
591
572 // Check that fullscreen works on a more complex page hierarchy with multiple 592 // Check that fullscreen works on a more complex page hierarchy with multiple
573 // local and remote ancestors. The test uses this frame tree: 593 // local and remote ancestors. The test uses this frame tree:
574 // 594 //
575 // A (a_top) 595 // A (a_top)
576 // | 596 // |
577 // A (a_bottom) 597 // A (a_bottom)
578 // / \ . 598 // / \ .
579 // (b_first) B B (b_second) 599 // (b_first) B B (b_second)
580 // | 600 // |
581 // C (c_top) 601 // C (c_top)
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // Verify that all fullscreen styles have been cleared. 732 // Verify that all fullscreen styles have been cleared.
713 EXPECT_FALSE(ElementHasFullscreenStyle(a_top, "child-0")); 733 EXPECT_FALSE(ElementHasFullscreenStyle(a_top, "child-0"));
714 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-0")); 734 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-0"));
715 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-1")); 735 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-1"));
716 EXPECT_FALSE(ElementHasFullscreenStyle(b_second, "child-0")); 736 EXPECT_FALSE(ElementHasFullscreenStyle(b_second, "child-0"));
717 EXPECT_FALSE(ElementHasFullscreenStyle(c_top, "child-0")); 737 EXPECT_FALSE(ElementHasFullscreenStyle(c_top, "child-0"));
718 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "fullscreen-div")); 738 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "fullscreen-div"));
719 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "child-0")); 739 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "child-0"));
720 } 740 }
721 741
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Fullscreen.cpp » ('j') | third_party/WebKit/Source/core/dom/Fullscreen.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698