Chromium Code Reviews| 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 6468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6479 | 6479 |
| 6480 // Go back and ensure the about:blank URL committed in the same SiteInstance | 6480 // Go back and ensure the about:blank URL committed in the same SiteInstance |
| 6481 // as the original navigation. | 6481 // as the original navigation. |
| 6482 EXPECT_TRUE(web_contents()->GetController().CanGoBack()); | 6482 EXPECT_TRUE(web_contents()->GetController().CanGoBack()); |
| 6483 TestFrameNavigationObserver frame_observer(child); | 6483 TestFrameNavigationObserver frame_observer(child); |
| 6484 web_contents()->GetController().GoBack(); | 6484 web_contents()->GetController().GoBack(); |
| 6485 frame_observer.WaitForCommit(); | 6485 frame_observer.WaitForCommit(); |
| 6486 EXPECT_EQ(orig_site_instance, child->current_frame_host()->GetSiteInstance()); | 6486 EXPECT_EQ(orig_site_instance, child->current_frame_host()->GetSiteInstance()); |
| 6487 } | 6487 } |
| 6488 | 6488 |
| 6489 // Check that out-of-process frames correctly calculate their ability to enter | |
| 6490 // fullscreen. A frame is allowed enter fullscreen if the allowFullscreen | |
| 6491 // attribute is present in all of its ancestor <iframe> elements. For OOPIF, | |
| 6492 // when a parent frame changes this attribute, the change is replicated to the | |
| 6493 // child frame and its proxies. | |
| 6494 // | |
| 6495 // The test checks the following cases: | |
| 6496 // | |
| 6497 // 1. Static attribute (<iframe allowfullscreen>) | |
| 6498 // 2. Attribute injected dynamically via JavaScript | |
| 6499 // 3. Multiple levels of nesting (A-embed-B-embed-C) | |
| 6500 // 4. Cross-site subframe navigation | |
| 6501 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, AllowFullscreen) { | |
| 6502 // Load a page with a cross-site <iframe allowFullscreen>. | |
| 6503 GURL url_1(embedded_test_server()->GetURL( | |
| 6504 "a.com", "/frame_tree/page_with_one_frame.html")); | |
| 6505 EXPECT_TRUE(NavigateToURL(shell(), url_1)); | |
| 6506 | |
| 6507 WebContentsImpl* contents = web_contents(); | |
| 6508 FrameTreeNode* root = contents->GetFrameTree()->root(); | |
| 6509 | |
| 6510 // Helper to check if a frame is allowed to go fullscreen on the renderer | |
| 6511 // side. | |
| 6512 auto is_fullscreen_allowed = [](FrameTreeNode* ftn) { | |
| 6513 bool fullscreen_allowed = false; | |
| 6514 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 6515 ftn->current_frame_host(), | |
| 6516 "window.domAutomationController.send(document.webkitFullscreenEnabled)", | |
| 6517 &fullscreen_allowed)); | |
| 6518 return fullscreen_allowed; | |
| 6519 }; | |
| 6520 | |
| 6521 EXPECT_TRUE(is_fullscreen_allowed(root)); | |
| 6522 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); | |
| 6523 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allowFullscreen); | |
| 6524 | |
| 6525 // Now navigate to a page with two <iframe>'s, both without allowFullscreen. | |
| 6526 GURL url_2(embedded_test_server()->GetURL( | |
| 6527 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); | |
| 6528 EXPECT_TRUE(NavigateToURL(shell(), url_2)); | |
| 6529 EXPECT_FALSE(root->child_at(0)->frame_owner_properties().allowFullscreen); | |
| 6530 EXPECT_FALSE(root->child_at(1)->frame_owner_properties().allowFullscreen); | |
| 6531 | |
| 6532 EXPECT_TRUE(is_fullscreen_allowed(root)); | |
| 6533 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0))); | |
| 6534 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(1))); | |
| 6535 | |
| 6536 // Dynamically enable fullscreen for first subframe and check that the | |
| 6537 // fullscreen property was updated on the FrameTreeNode. | |
| 6538 EXPECT_TRUE(ExecuteScript( | |
| 6539 root->current_frame_host(), | |
| 6540 "document.getElementById('child-0').allowFullscreen='true'")); | |
| 6541 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allowFullscreen); | |
| 6542 | |
| 6543 // Check that the first subframe is now allowed to go fullscreen. Other | |
| 6544 // frames shouldn't be affected. | |
| 6545 EXPECT_TRUE(is_fullscreen_allowed(root)); | |
| 6546 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); | |
| 6547 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(1))); | |
| 6548 | |
| 6549 // Now navigate to a page with two levels of nesting. | |
| 6550 GURL url_3(embedded_test_server()->GetURL( | |
| 6551 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); | |
| 6552 EXPECT_TRUE(NavigateToURL(shell(), url_3)); | |
| 6553 | |
| 6554 EXPECT_TRUE(is_fullscreen_allowed(root)); | |
| 6555 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0))); | |
| 6556 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); | |
| 6557 | |
| 6558 // Dynamically enable fullscreen for bottom subframe. | |
| 6559 EXPECT_TRUE(ExecuteScript( | |
| 6560 root->child_at(0)->current_frame_host(), | |
| 6561 "document.getElementById('child-0').allowFullscreen='true'")); | |
| 6562 | |
| 6563 // This still shouldn't allow the bottom child to go fullscreen, since the | |
| 6564 // top frame hasn't allowed fullscreen for the middle frame. | |
| 6565 EXPECT_TRUE(is_fullscreen_allowed(root)); | |
| 6566 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0))); | |
| 6567 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); | |
| 6568 | |
| 6569 // Now allow fullscreen for the middle frame. | |
| 6570 EXPECT_TRUE(ExecuteScript( | |
| 6571 root->current_frame_host(), | |
| 6572 "document.getElementById('child-0').allowFullscreen='true'")); | |
| 6573 | |
| 6574 // All frames should be allowed to go fullscreen now. | |
| 6575 EXPECT_TRUE(is_fullscreen_allowed(root)); | |
| 6576 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); | |
|
Charlie Reis
2016/05/13 21:18:42
Sanity check: This won't be racy, right? The scri
alexmos
2016/05/14 01:12:37
Yes, the ExecuteScript should block until it hears
| |
| 6577 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); | |
| 6578 | |
| 6579 // Cross-site navigation should preserve the fullscreen flags. | |
| 6580 NavigateFrameToURL(root->child_at(0)->child_at(0), | |
| 6581 embedded_test_server()->GetURL("d.com", "/title1.html")); | |
| 6582 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); | |
| 6583 } | |
| 6584 | |
| 6489 } // namespace content | 6585 } // namespace content |
| OLD | NEW |