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 6547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6558 EXPECT_EQ(0, child_count); | 6558 EXPECT_EQ(0, child_count); |
6559 | 6559 |
6560 EXPECT_EQ( | 6560 EXPECT_EQ( |
6561 " Site A ------------ proxies for B\n" | 6561 " Site A ------------ proxies for B\n" |
6562 " +--Site B ------- proxies for A\n" | 6562 " +--Site B ------- proxies for A\n" |
6563 "Where A = http://a.com/\n" | 6563 "Where A = http://a.com/\n" |
6564 " B = http://b.com/", | 6564 " B = http://b.com/", |
6565 DepictFrameTree(root)); | 6565 DepictFrameTree(root)); |
6566 } | 6566 } |
6567 | 6567 |
| 6568 // Check that out-of-process frames correctly calculate their ability to enter |
| 6569 // fullscreen. A frame is allowed enter fullscreen if the allowFullscreen |
| 6570 // attribute is present in all of its ancestor <iframe> elements. For OOPIF, |
| 6571 // when a parent frame changes this attribute, the change is replicated to the |
| 6572 // child frame and its proxies. |
| 6573 // |
| 6574 // The test checks the following cases: |
| 6575 // |
| 6576 // 1. Static attribute (<iframe allowfullscreen>) |
| 6577 // 2. Attribute injected dynamically via JavaScript |
| 6578 // 3. Multiple levels of nesting (A-embed-B-embed-C) |
| 6579 // 4. Cross-site subframe navigation |
| 6580 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, AllowFullscreen) { |
| 6581 // Load a page with a cross-site <iframe allowFullscreen>. |
| 6582 GURL url_1(embedded_test_server()->GetURL( |
| 6583 "a.com", "/page_with_allowfullscreen_frame.html")); |
| 6584 EXPECT_TRUE(NavigateToURL(shell(), url_1)); |
| 6585 |
| 6586 WebContentsImpl* contents = web_contents(); |
| 6587 FrameTreeNode* root = contents->GetFrameTree()->root(); |
| 6588 |
| 6589 // Helper to check if a frame is allowed to go fullscreen on the renderer |
| 6590 // side. |
| 6591 auto is_fullscreen_allowed = [](FrameTreeNode* ftn) { |
| 6592 bool fullscreen_allowed = false; |
| 6593 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 6594 ftn->current_frame_host(), |
| 6595 "window.domAutomationController.send(document.webkitFullscreenEnabled)", |
| 6596 &fullscreen_allowed)); |
| 6597 return fullscreen_allowed; |
| 6598 }; |
| 6599 |
| 6600 EXPECT_TRUE(is_fullscreen_allowed(root)); |
| 6601 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); |
| 6602 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allowFullscreen); |
| 6603 |
| 6604 // Now navigate to a page with two <iframe>'s, both without allowFullscreen. |
| 6605 GURL url_2(embedded_test_server()->GetURL( |
| 6606 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); |
| 6607 EXPECT_TRUE(NavigateToURL(shell(), url_2)); |
| 6608 EXPECT_FALSE(root->child_at(0)->frame_owner_properties().allowFullscreen); |
| 6609 EXPECT_FALSE(root->child_at(1)->frame_owner_properties().allowFullscreen); |
| 6610 |
| 6611 EXPECT_TRUE(is_fullscreen_allowed(root)); |
| 6612 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0))); |
| 6613 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(1))); |
| 6614 |
| 6615 // Dynamically enable fullscreen for first subframe and check that the |
| 6616 // fullscreen property was updated on the FrameTreeNode. |
| 6617 EXPECT_TRUE(ExecuteScript( |
| 6618 root->current_frame_host(), |
| 6619 "document.getElementById('child-0').allowFullscreen='true'")); |
| 6620 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allowFullscreen); |
| 6621 |
| 6622 // Check that the first subframe is now allowed to go fullscreen. Other |
| 6623 // frames shouldn't be affected. |
| 6624 EXPECT_TRUE(is_fullscreen_allowed(root)); |
| 6625 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); |
| 6626 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(1))); |
| 6627 |
| 6628 // Now navigate to a page with two levels of nesting. |
| 6629 GURL url_3(embedded_test_server()->GetURL( |
| 6630 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); |
| 6631 EXPECT_TRUE(NavigateToURL(shell(), url_3)); |
| 6632 |
| 6633 EXPECT_TRUE(is_fullscreen_allowed(root)); |
| 6634 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0))); |
| 6635 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); |
| 6636 |
| 6637 // Dynamically enable fullscreen for bottom subframe. |
| 6638 EXPECT_TRUE(ExecuteScript( |
| 6639 root->child_at(0)->current_frame_host(), |
| 6640 "document.getElementById('child-0').allowFullscreen='true'")); |
| 6641 |
| 6642 // This still shouldn't allow the bottom child to go fullscreen, since the |
| 6643 // top frame hasn't allowed fullscreen for the middle frame. |
| 6644 EXPECT_TRUE(is_fullscreen_allowed(root)); |
| 6645 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0))); |
| 6646 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); |
| 6647 |
| 6648 // Now allow fullscreen for the middle frame. |
| 6649 EXPECT_TRUE(ExecuteScript( |
| 6650 root->current_frame_host(), |
| 6651 "document.getElementById('child-0').allowFullscreen='true'")); |
| 6652 |
| 6653 // All frames should be allowed to go fullscreen now. |
| 6654 EXPECT_TRUE(is_fullscreen_allowed(root)); |
| 6655 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); |
| 6656 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); |
| 6657 |
| 6658 // Cross-site navigation should preserve the fullscreen flags. |
| 6659 NavigateFrameToURL(root->child_at(0)->child_at(0), |
| 6660 embedded_test_server()->GetURL("d.com", "/title1.html")); |
| 6661 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); |
| 6662 } |
| 6663 |
6568 } // namespace content | 6664 } // namespace content |
OLD | NEW |