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

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

Issue 2855973005: Update tests for snapshot allowfullscreen behavior (Closed)
Patch Set: Update docs Created 3 years, 7 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/test/data/cross_site_iframe_factory.html » ('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 "base/test/scoped_feature_list.h" 7 #include "base/test/scoped_feature_list.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
10 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h" 10 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h"
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 bool has_style = false; 574 bool has_style = false;
575 std::string script = base::StringPrintf( 575 std::string script = base::StringPrintf(
576 "domAutomationController.send(" 576 "domAutomationController.send("
577 " document.querySelectorAll(" 577 " document.querySelectorAll("
578 " '#%s:-webkit-full-screen-ancestor').length == 1)", 578 " '#%s:-webkit-full-screen-ancestor').length == 1)",
579 element_id.c_str()); 579 element_id.c_str());
580 EXPECT_TRUE(ExecuteScriptAndExtractBool(host, script, &has_style)); 580 EXPECT_TRUE(ExecuteScriptAndExtractBool(host, script, &has_style));
581 return has_style; 581 return has_style;
582 } 582 }
583 583
584 // Set the allowFullscreen attribute on the <iframe> element identified by
585 // |frame_id|.
586 void SetAllowFullscreenForFrame(content::RenderFrameHost* host,
587 const std::string& frame_id) {
588 EXPECT_TRUE(ExecuteScript(
589 host, base::StringPrintf(
590 "document.getElementById('%s').allowFullscreen = true;",
591 frame_id.c_str())));
592 }
593
594 // Add a listener that will send back a message whenever the (prefixed) 584 // Add a listener that will send back a message whenever the (prefixed)
595 // fullscreenchange event fires. The message will be "fullscreenchange", 585 // fullscreenchange event fires. The message will be "fullscreenchange",
596 // followed by a space and the provided |id|. 586 // followed by a space and the provided |id|.
597 void AddFullscreenChangeListener(content::RenderFrameHost* frame, 587 void AddFullscreenChangeListener(content::RenderFrameHost* frame,
598 const std::string& id) { 588 const std::string& id) {
599 std::string script = base::StringPrintf( 589 std::string script = base::StringPrintf(
600 "document.addEventListener('webkitfullscreenchange', function() {" 590 "document.addEventListener('webkitfullscreenchange', function() {"
601 " domAutomationController.setAutomationId(0);" 591 " domAutomationController.setAutomationId(0);"
602 " domAutomationController.send('fullscreenchange %s');});", 592 " domAutomationController.send('fullscreenchange %s');});",
603 id.c_str()); 593 id.c_str());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 EXPECT_EQ("none", GetFullscreenElementId(child)); 728 EXPECT_EQ("none", GetFullscreenElementId(child));
739 } 729 }
740 730
741 // Check that on a page with A-embed-B-embed-A frame hierarchy, an element in 731 // Check that on a page with A-embed-B-embed-A frame hierarchy, an element in
742 // the bottom frame can enter and exit fullscreen. |exit_method| specifies 732 // the bottom frame can enter and exit fullscreen. |exit_method| specifies
743 // whether to use browser-initiated vs. renderer-initiated fullscreen exit 733 // whether to use browser-initiated vs. renderer-initiated fullscreen exit
744 // (i.e., pressing escape vs. a JS call), since they trigger different code 734 // (i.e., pressing escape vs. a JS call), since they trigger different code
745 // paths on the Blink side. 735 // paths on the Blink side.
746 void SitePerProcessInteractiveBrowserTest::FullscreenElementInABA( 736 void SitePerProcessInteractiveBrowserTest::FullscreenElementInABA(
747 FullscreenExitMethod exit_method) { 737 FullscreenExitMethod exit_method) {
748 GURL main_url(embedded_test_server()->GetURL( 738 GURL main_url(embedded_test_server()->GetURL("a.com",
749 "a.com", "/cross_site_iframe_factory.html?a(b(a))")); 739 "/cross_site_iframe_factory."
740 "html?a(b{allowfullscreen}(a{"
741 "allowfullscreen}))"));
750 ui_test_utils::NavigateToURL(browser(), main_url); 742 ui_test_utils::NavigateToURL(browser(), main_url);
751 content::WebContents* web_contents = 743 content::WebContents* web_contents =
752 browser()->tab_strip_model()->GetActiveWebContents(); 744 browser()->tab_strip_model()->GetActiveWebContents();
753 745
754 content::RenderFrameHost* main_frame = web_contents->GetMainFrame(); 746 content::RenderFrameHost* main_frame = web_contents->GetMainFrame();
755 content::RenderFrameHost* child = ChildFrameAt(main_frame, 0); 747 content::RenderFrameHost* child = ChildFrameAt(main_frame, 0);
756 content::RenderFrameHost* grandchild = ChildFrameAt(child, 0); 748 content::RenderFrameHost* grandchild = ChildFrameAt(child, 0);
757 749
758 // Navigate the bottom frame to a page that has a fullscreenable <div>. 750 // Navigate the bottom frame to a page that has a fullscreenable <div>.
759 content::TestNavigationObserver observer(web_contents); 751 content::TestNavigationObserver observer(web_contents);
760 EXPECT_TRUE( 752 EXPECT_TRUE(
761 ExecuteScript(grandchild, "location.href = '/fullscreen_frame.html'")); 753 ExecuteScript(grandchild, "location.href = '/fullscreen_frame.html'"));
762 observer.Wait(); 754 observer.Wait();
763 EXPECT_EQ(embedded_test_server()->GetURL("a.com", "/fullscreen_frame.html"), 755 EXPECT_EQ(embedded_test_server()->GetURL("a.com", "/fullscreen_frame.html"),
764 grandchild->GetLastCommittedURL()); 756 grandchild->GetLastCommittedURL());
765 757
766 // Add allowFullscreen attribute to both <iframe> elements.
767 SetAllowFullscreenForFrame(main_frame, "child-0");
768 SetAllowFullscreenForFrame(child, "child-0");
769
770 // Make fullscreenchange events in all three frames send a message. 758 // Make fullscreenchange events in all three frames send a message.
771 AddFullscreenChangeListener(main_frame, "main_frame"); 759 AddFullscreenChangeListener(main_frame, "main_frame");
772 AddFullscreenChangeListener(child, "child"); 760 AddFullscreenChangeListener(child, "child");
773 AddFullscreenChangeListener(grandchild, "grandchild"); 761 AddFullscreenChangeListener(grandchild, "grandchild");
774 762
775 // Add a resize event handler that will send a message when the grandchild 763 // Add a resize event handler that will send a message when the grandchild
776 // frame is resized to the screen size. Also save its original size. 764 // frame is resized to the screen size. Also save its original size.
777 AddResizeListener(grandchild, GetScreenSize()); 765 AddResizeListener(grandchild, GetScreenSize());
778 gfx::Size original_grandchild_size = GetFrameSize(grandchild); 766 gfx::Size original_grandchild_size = GetFrameSize(grandchild);
779 767
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 // 863 //
876 // The c_middle frame will trigger fullscreen for its <div> element. The test 864 // The c_middle frame will trigger fullscreen for its <div> element. The test
877 // verifies that its ancestor chain is properly updated for fullscreen, and 865 // verifies that its ancestor chain is properly updated for fullscreen, and
878 // that the b_first node that's not on the chain is not affected. 866 // that the b_first node that's not on the chain is not affected.
879 // 867 //
880 // The test also exits fullscreen by simulating pressing ESC rather than using 868 // The test also exits fullscreen by simulating pressing ESC rather than using
881 // document.webkitExitFullscreen(), which tests the browser-initiated 869 // document.webkitExitFullscreen(), which tests the browser-initiated
882 // fullscreen exit path. 870 // fullscreen exit path.
883 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest, 871 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
884 FullscreenElementInMultipleSubframes) { 872 FullscreenElementInMultipleSubframes) {
873 // Allow fullscreen in all iframes descending to |c_middle|.
885 GURL main_url(embedded_test_server()->GetURL( 874 GURL main_url(embedded_test_server()->GetURL(
886 "a.com", "/cross_site_iframe_factory.html?a(a(b,b(c(c))))")); 875 "a.com",
876 "/cross_site_iframe_factory.html?a(a{allowfullscreen}(b,b{"
877 "allowfullscreen}(c{allowfullscreen}(c{allowfullscreen}))))"));
887 ui_test_utils::NavigateToURL(browser(), main_url); 878 ui_test_utils::NavigateToURL(browser(), main_url);
888 content::WebContents* web_contents = 879 content::WebContents* web_contents =
889 browser()->tab_strip_model()->GetActiveWebContents(); 880 browser()->tab_strip_model()->GetActiveWebContents();
890 881
891 content::RenderFrameHost* a_top = web_contents->GetMainFrame(); 882 content::RenderFrameHost* a_top = web_contents->GetMainFrame();
892 content::RenderFrameHost* a_bottom = ChildFrameAt(a_top, 0); 883 content::RenderFrameHost* a_bottom = ChildFrameAt(a_top, 0);
893 content::RenderFrameHost* b_first = ChildFrameAt(a_bottom, 0); 884 content::RenderFrameHost* b_first = ChildFrameAt(a_bottom, 0);
894 content::RenderFrameHost* b_second = ChildFrameAt(a_bottom, 1); 885 content::RenderFrameHost* b_second = ChildFrameAt(a_bottom, 1);
895 content::RenderFrameHost* c_top = ChildFrameAt(b_second, 0); 886 content::RenderFrameHost* c_top = ChildFrameAt(b_second, 0);
896 content::RenderFrameHost* c_middle = ChildFrameAt(c_top, 0); 887 content::RenderFrameHost* c_middle = ChildFrameAt(c_top, 0);
897 888
898 // Allow fullscreen in all iframes descending to |c_middle|. This relies on
899 // IDs that cross_site_iframe_factory assigns to child frames.
900 SetAllowFullscreenForFrame(a_top, "child-0");
901 SetAllowFullscreenForFrame(a_bottom, "child-1");
902 SetAllowFullscreenForFrame(b_second, "child-0");
903 SetAllowFullscreenForFrame(c_top, "child-0");
904
905 // Navigate |c_middle| to a page that has a fullscreenable <div> and another 889 // Navigate |c_middle| to a page that has a fullscreenable <div> and another
906 // frame. 890 // frame.
907 content::TestNavigationObserver observer(web_contents); 891 content::TestNavigationObserver observer(web_contents);
908 EXPECT_TRUE( 892 EXPECT_TRUE(
909 ExecuteScript(c_middle, "location.href = '/fullscreen_frame.html'")); 893 ExecuteScript(c_middle, "location.href = '/fullscreen_frame.html'"));
910 observer.Wait(); 894 observer.Wait();
911 EXPECT_EQ(embedded_test_server()->GetURL("c.com", "/fullscreen_frame.html"), 895 EXPECT_EQ(embedded_test_server()->GetURL("c.com", "/fullscreen_frame.html"),
912 c_middle->GetLastCommittedURL()); 896 c_middle->GetLastCommittedURL());
913 content::RenderFrameHost* c_bottom = ChildFrameAt(c_middle, 0); 897 content::RenderFrameHost* c_bottom = ChildFrameAt(c_middle, 0);
914 898
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 } 1451 }
1468 1452
1469 // To make sure we never clicked into the date picker, get current date value 1453 // To make sure we never clicked into the date picker, get current date value
1470 // and make sure it matches the cached value. 1454 // and make sure it matches the cached value.
1471 std::string date; 1455 std::string date;
1472 ASSERT_TRUE(ExecuteScriptAndExtractString( 1456 ASSERT_TRUE(ExecuteScriptAndExtractString(
1473 child_frame, "window.domAutomationController.send(input.value);", &date)); 1457 child_frame, "window.domAutomationController.send(input.value);", &date));
1474 EXPECT_EQ(cached_date, date) << "Cached date was '" << cached_date 1458 EXPECT_EQ(cached_date, date) << "Cached date was '" << cached_date
1475 << "' but current date is '" << date << "'."; 1459 << "' but current date is '" << date << "'.";
1476 } 1460 }
OLDNEW
« no previous file with comments | « no previous file | content/test/data/cross_site_iframe_factory.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698