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

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: Add bug reference for nested fullscreen 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Fullscreen.cpp » ('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 "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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 EXPECT_FALSE(ElementHasFullscreenStyle(child, "fullscreen-div")); 465 EXPECT_FALSE(ElementHasFullscreenStyle(child, "fullscreen-div"));
459 EXPECT_FALSE(ElementHasFullscreenStyle(main_frame, "child-0")); 466 EXPECT_FALSE(ElementHasFullscreenStyle(main_frame, "child-0"));
460 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(main_frame, "child-0")); 467 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(main_frame, "child-0"));
461 468
462 // Check that both frames cleared their document.webkitFullscreenElement. 469 // Check that both frames cleared their document.webkitFullscreenElement.
463 EXPECT_EQ("none", GetFullscreenElementId(main_frame)); 470 EXPECT_EQ("none", GetFullscreenElementId(main_frame));
464 EXPECT_EQ("none", GetFullscreenElementId(child)); 471 EXPECT_EQ("none", GetFullscreenElementId(child));
465 } 472 }
466 473
467 // Check that on a page with A-embed-B-embed-A frame hierarchy, an element in 474 // Check that on a page with A-embed-B-embed-A frame hierarchy, an element in
468 // the bottom frame can enter and exit fullscreen. 475 // the bottom frame can enter and exit fullscreen. |exit_method| specifies
469 // 476 // whether to use browser-initiated vs. renderer-initiated fullscreen exit
470 // TODO(alexmos): For now, the test will verify sizing and fullscreen CSS 477 // (i.e., pressing escape vs. a JS call), since they trigger different code
471 // styles, but additional refactoring of Blink's Fullscreen class is required 478 // paths on the Blink side.
472 // to fully handle fullscreenchange events and webkitFullscreenElement in the 479 void SitePerProcessInteractiveBrowserTest::FullscreenElementInABA(
473 // main frame. 480 FullscreenExitMethod exit_method) {
474 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
475 FullscreenElementInABA) {
476 GURL main_url(embedded_test_server()->GetURL( 481 GURL main_url(embedded_test_server()->GetURL(
477 "a.com", "/cross_site_iframe_factory.html?a(b(a))")); 482 "a.com", "/cross_site_iframe_factory.html?a(b(a))"));
478 ui_test_utils::NavigateToURL(browser(), main_url); 483 ui_test_utils::NavigateToURL(browser(), main_url);
479 content::WebContents* web_contents = 484 content::WebContents* web_contents =
480 browser()->tab_strip_model()->GetActiveWebContents(); 485 browser()->tab_strip_model()->GetActiveWebContents();
481 486
482 content::RenderFrameHost* main_frame = web_contents->GetMainFrame(); 487 content::RenderFrameHost* main_frame = web_contents->GetMainFrame();
483 content::RenderFrameHost* child = ChildFrameAt(main_frame, 0); 488 content::RenderFrameHost* child = ChildFrameAt(main_frame, 0);
484 content::RenderFrameHost* grandchild = ChildFrameAt(child, 0); 489 content::RenderFrameHost* grandchild = ChildFrameAt(child, 0);
485 490
(...skipping 16 matching lines...) Expand all
502 507
503 // Add a resize event handler that will send a message when the grandchild 508 // Add a resize event handler that will send a message when the grandchild
504 // frame is resized to the screen size. Also save its original size. 509 // frame is resized to the screen size. Also save its original size.
505 AddResizeListener(grandchild, GetScreenSize()); 510 AddResizeListener(grandchild, GetScreenSize());
506 gfx::Size original_grandchild_size = GetFrameSize(grandchild); 511 gfx::Size original_grandchild_size = GetFrameSize(grandchild);
507 512
508 // Fullscreen a <div> inside the bottom subframe. This will block until 513 // Fullscreen a <div> inside the bottom subframe. This will block until
509 // (1) the fullscreenchange events in all frames send a response, and 514 // (1) the fullscreenchange events in all frames send a response, and
510 // (2) the frame is resized to fill the whole screen. 515 // (2) the frame is resized to fill the whole screen.
511 // (3) the browser has finished the fullscreen transition. 516 // (3) the browser has finished the fullscreen transition.
512 // 517 std::set<std::string> expected_events = {"main_frame", "child", "grandchild"};
513 // TODO(alexmos): Also wait for "main_frame" once
514 // blink::Fullscreen::requestFullscreen() and exitFullscreen() are fixed to
515 // process all local ancestors.
516 std::set<std::string> expected_events = {"child", "grandchild"};
517 { 518 {
518 content::DOMMessageQueue queue; 519 content::DOMMessageQueue queue;
519 std::unique_ptr<FullscreenNotificationObserver> observer( 520 std::unique_ptr<FullscreenNotificationObserver> observer(
520 new FullscreenNotificationObserver()); 521 new FullscreenNotificationObserver());
521 EXPECT_TRUE(ExecuteScript(grandchild, "activateFullscreen()")); 522 EXPECT_TRUE(ExecuteScript(grandchild, "activateFullscreen()"));
522 WaitForMultipleFullscreenEvents(expected_events, queue); 523 WaitForMultipleFullscreenEvents(expected_events, queue);
523 observer->Wait(); 524 observer->Wait();
524 } 525 }
525 526
526 // Verify that the browser has entered fullscreen for the current tab. 527 // Verify that the browser has entered fullscreen for the current tab.
527 EXPECT_TRUE(browser()->window()->IsFullscreen()); 528 EXPECT_TRUE(browser()->window()->IsFullscreen());
528 EXPECT_TRUE(browser()->exclusive_access_manager() 529 EXPECT_TRUE(browser()->exclusive_access_manager()
529 ->fullscreen_controller() 530 ->fullscreen_controller()
530 ->IsFullscreenForTabOrPending(web_contents)); 531 ->IsFullscreenForTabOrPending(web_contents));
531 532
532 // Verify that the <div> has fullscreen style in the bottom frame, and that 533 // Verify that the <div> has fullscreen style in the bottom frame, and that
533 // the proper <iframe> elements have fullscreen style in its ancestor frames. 534 // the proper <iframe> elements have fullscreen style in its ancestor frames.
534 EXPECT_TRUE(ElementHasFullscreenStyle(grandchild, "fullscreen-div")); 535 EXPECT_TRUE(ElementHasFullscreenStyle(grandchild, "fullscreen-div"));
535 EXPECT_TRUE(ElementHasFullscreenStyle(child, "child-0")); 536 EXPECT_TRUE(ElementHasFullscreenStyle(child, "child-0"));
536 EXPECT_TRUE(ElementHasFullscreenAncestorStyle(child, "child-0")); 537 EXPECT_TRUE(ElementHasFullscreenAncestorStyle(child, "child-0"));
537 EXPECT_TRUE(ElementHasFullscreenStyle(main_frame, "child-0")); 538 EXPECT_TRUE(ElementHasFullscreenStyle(main_frame, "child-0"));
538 EXPECT_TRUE(ElementHasFullscreenAncestorStyle(main_frame, "child-0")); 539 EXPECT_TRUE(ElementHasFullscreenAncestorStyle(main_frame, "child-0"));
539 540
540 // Check document.webkitFullscreenElement in all frames. 541 // Check document.webkitFullscreenElement in all frames.
542 EXPECT_EQ("child-0", GetFullscreenElementId(main_frame));
541 EXPECT_EQ("child-0", GetFullscreenElementId(child)); 543 EXPECT_EQ("child-0", GetFullscreenElementId(child));
542 EXPECT_EQ("fullscreen-div", GetFullscreenElementId(grandchild)); 544 EXPECT_EQ("fullscreen-div", GetFullscreenElementId(grandchild));
543 // TODO(alexmos): Also check that |main_frame|'s webkitFullscreenElement is
544 // "child-0" once blink::Fullscreen::requestFullscreen() is fixed to handle
545 // all local ancestors.
546 545
547 // Now exit fullscreen from the subframe. 546 // Now exit fullscreen from the subframe.
548 AddResizeListener(grandchild, original_grandchild_size); 547 AddResizeListener(grandchild, original_grandchild_size);
549 { 548 {
550 content::DOMMessageQueue queue; 549 content::DOMMessageQueue queue;
551 std::unique_ptr<FullscreenNotificationObserver> observer( 550 std::unique_ptr<FullscreenNotificationObserver> observer(
552 new FullscreenNotificationObserver()); 551 new FullscreenNotificationObserver());
553 EXPECT_TRUE(ExecuteScript(grandchild, "exitFullscreen()")); 552 switch (exit_method) {
553 case FullscreenExitMethod::JS_CALL:
554 EXPECT_TRUE(ExecuteScript(grandchild, "exitFullscreen()"));
555 break;
556 case FullscreenExitMethod::ESC_PRESS:
557 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
558 browser(), ui::VKEY_ESCAPE, false, false, false, false));
559 break;
560 default:
561 NOTREACHED();
562 }
554 WaitForMultipleFullscreenEvents(expected_events, queue); 563 WaitForMultipleFullscreenEvents(expected_events, queue);
555 observer->Wait(); 564 observer->Wait();
556 } 565 }
557 566
558 EXPECT_FALSE(browser()->window()->IsFullscreen()); 567 EXPECT_FALSE(browser()->window()->IsFullscreen());
559 568
560 // Verify that the fullscreen styles were removed from the <div> and its 569 // Verify that the fullscreen styles were removed from the <div> and its
561 // container <iframe>'s. 570 // container <iframe>'s.
562 EXPECT_FALSE(ElementHasFullscreenStyle(grandchild, "fullscreen-div")); 571 EXPECT_FALSE(ElementHasFullscreenStyle(grandchild, "fullscreen-div"));
563 EXPECT_FALSE(ElementHasFullscreenStyle(child, "child-0")); 572 EXPECT_FALSE(ElementHasFullscreenStyle(child, "child-0"));
564 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(child, "child-0")); 573 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(child, "child-0"));
565 EXPECT_FALSE(ElementHasFullscreenStyle(main_frame, "child-0")); 574 EXPECT_FALSE(ElementHasFullscreenStyle(main_frame, "child-0"));
566 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(main_frame, "child-0")); 575 EXPECT_FALSE(ElementHasFullscreenAncestorStyle(main_frame, "child-0"));
567 576
568 // Check that document.webkitFullscreenElement was cleared in all three 577 // Check that document.webkitFullscreenElement was cleared in all three
569 // frames. 578 // frames.
570 EXPECT_EQ("none", GetFullscreenElementId(main_frame)); 579 EXPECT_EQ("none", GetFullscreenElementId(main_frame));
571 EXPECT_EQ("none", GetFullscreenElementId(child)); 580 EXPECT_EQ("none", GetFullscreenElementId(child));
572 EXPECT_EQ("none", GetFullscreenElementId(grandchild)); 581 EXPECT_EQ("none", GetFullscreenElementId(grandchild));
573 } 582 }
574 583
584 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
585 FullscreenElementInABAAndExitViaEscapeKey) {
586 FullscreenElementInABA(FullscreenExitMethod::ESC_PRESS);
587 }
588
589 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
590 FullscreenElementInABAAndExitViaJS) {
591 FullscreenElementInABA(FullscreenExitMethod::JS_CALL);
592 }
593
575 // Check that fullscreen works on a more complex page hierarchy with multiple 594 // Check that fullscreen works on a more complex page hierarchy with multiple
576 // local and remote ancestors. The test uses this frame tree: 595 // local and remote ancestors. The test uses this frame tree:
577 // 596 //
578 // A (a_top) 597 // A (a_top)
579 // | 598 // |
580 // A (a_bottom) 599 // A (a_bottom)
581 // / \ . 600 // / \ .
582 // (b_first) B B (b_second) 601 // (b_first) B B (b_second)
583 // | 602 // |
584 // C (c_top) 603 // C (c_top)
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 // Verify that all fullscreen styles have been cleared. 734 // Verify that all fullscreen styles have been cleared.
716 EXPECT_FALSE(ElementHasFullscreenStyle(a_top, "child-0")); 735 EXPECT_FALSE(ElementHasFullscreenStyle(a_top, "child-0"));
717 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-0")); 736 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-0"));
718 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-1")); 737 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-1"));
719 EXPECT_FALSE(ElementHasFullscreenStyle(b_second, "child-0")); 738 EXPECT_FALSE(ElementHasFullscreenStyle(b_second, "child-0"));
720 EXPECT_FALSE(ElementHasFullscreenStyle(c_top, "child-0")); 739 EXPECT_FALSE(ElementHasFullscreenStyle(c_top, "child-0"));
721 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "fullscreen-div")); 740 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "fullscreen-div"));
722 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "child-0")); 741 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "child-0"));
723 } 742 }
724 743
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Fullscreen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698