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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1938753002: OOPIF: Replicate allowFullscreen flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 | « content/browser/frame_host/render_frame_proxy_host.cc ('k') | content/common/frame_messages.h » ('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 (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 7100 matching lines...) Expand 10 before | Expand all | Expand 10 after
7111 false, gfx::Rect()); 7111 false, gfx::Rect());
7112 EXPECT_FALSE( 7112 EXPECT_FALSE(
7113 ContainsKey(web_contents()->pending_widget_views_, 7113 ContainsKey(web_contents()->pending_widget_views_,
7114 std::make_pair(process1->GetID(), filter1->routing_id()))); 7114 std::make_pair(process1->GetID(), filter1->routing_id())));
7115 EXPECT_FALSE( 7115 EXPECT_FALSE(
7116 ContainsKey(web_contents()->pending_widget_views_, 7116 ContainsKey(web_contents()->pending_widget_views_,
7117 std::make_pair(process2->GetID(), filter2->routing_id()))); 7117 std::make_pair(process2->GetID(), filter2->routing_id())));
7118 } 7118 }
7119 #endif 7119 #endif
7120 7120
7121 // Check that out-of-process frames correctly calculate their ability to enter
7122 // fullscreen. A frame is allowed enter fullscreen if the allowFullscreen
7123 // attribute is present in all of its ancestor <iframe> elements. For OOPIF,
7124 // when a parent frame changes this attribute, the change is replicated to the
7125 // child frame and its proxies.
7126 //
7127 // The test checks the following cases:
7128 //
7129 // 1. Static attribute (<iframe allowfullscreen>)
7130 // 2. Attribute injected dynamically via JavaScript
7131 // 3. Multiple levels of nesting (A-embed-B-embed-C)
7132 // 4. Cross-site subframe navigation
7133 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, AllowFullscreen) {
7134 // Load a page with a cross-site <iframe allowFullscreen>.
7135 GURL url_1(embedded_test_server()->GetURL(
7136 "a.com", "/page_with_allowfullscreen_frame.html"));
7137 EXPECT_TRUE(NavigateToURL(shell(), url_1));
7138
7139 WebContentsImpl* contents = web_contents();
7140 FrameTreeNode* root = contents->GetFrameTree()->root();
7141
7142 // Helper to check if a frame is allowed to go fullscreen on the renderer
7143 // side.
7144 auto is_fullscreen_allowed = [](FrameTreeNode* ftn) {
7145 bool fullscreen_allowed = false;
7146 EXPECT_TRUE(ExecuteScriptAndExtractBool(
7147 ftn->current_frame_host(),
7148 "window.domAutomationController.send(document.webkitFullscreenEnabled)",
7149 &fullscreen_allowed));
7150 return fullscreen_allowed;
7151 };
7152
7153 EXPECT_TRUE(is_fullscreen_allowed(root));
7154 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
7155 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allowFullscreen);
7156
7157 // Now navigate to a page with two <iframe>'s, both without allowFullscreen.
7158 GURL url_2(embedded_test_server()->GetURL(
7159 "a.com", "/cross_site_iframe_factory.html?a(b,c)"));
7160 EXPECT_TRUE(NavigateToURL(shell(), url_2));
7161 EXPECT_FALSE(root->child_at(0)->frame_owner_properties().allowFullscreen);
7162 EXPECT_FALSE(root->child_at(1)->frame_owner_properties().allowFullscreen);
7163
7164 EXPECT_TRUE(is_fullscreen_allowed(root));
7165 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)));
7166 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(1)));
7167
7168 // Dynamically enable fullscreen for first subframe and check that the
7169 // fullscreen property was updated on the FrameTreeNode.
7170 EXPECT_TRUE(ExecuteScript(
7171 root->current_frame_host(),
7172 "document.getElementById('child-0').allowFullscreen='true'"));
7173 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allowFullscreen);
7174
7175 // Check that the first subframe is now allowed to go fullscreen. Other
7176 // frames shouldn't be affected.
7177 EXPECT_TRUE(is_fullscreen_allowed(root));
7178 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
7179 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(1)));
7180
7181 // Now navigate to a page with two levels of nesting.
7182 GURL url_3(embedded_test_server()->GetURL(
7183 "a.com", "/cross_site_iframe_factory.html?a(b(c))"));
7184 EXPECT_TRUE(NavigateToURL(shell(), url_3));
7185
7186 EXPECT_TRUE(is_fullscreen_allowed(root));
7187 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)));
7188 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7189
7190 // Dynamically enable fullscreen for bottom subframe.
7191 EXPECT_TRUE(ExecuteScript(
7192 root->child_at(0)->current_frame_host(),
7193 "document.getElementById('child-0').allowFullscreen='true'"));
7194
7195 // This still shouldn't allow the bottom child to go fullscreen, since the
7196 // top frame hasn't allowed fullscreen for the middle frame.
7197 EXPECT_TRUE(is_fullscreen_allowed(root));
7198 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)));
7199 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7200
7201 // Now allow fullscreen for the middle frame.
7202 EXPECT_TRUE(ExecuteScript(
7203 root->current_frame_host(),
7204 "document.getElementById('child-0').allowFullscreen='true'"));
7205
7206 // All frames should be allowed to go fullscreen now.
7207 EXPECT_TRUE(is_fullscreen_allowed(root));
7208 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
7209 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7210
7211 // Cross-site navigation should preserve the fullscreen flags.
7212 NavigateFrameToURL(root->child_at(0)->child_at(0),
7213 embedded_test_server()->GetURL("d.com", "/title1.html"));
7214 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7215 }
7216
7121 } // namespace content 7217 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_proxy_host.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698