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

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: Cleanup 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
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 6262 matching lines...) Expand 10 before | Expand all | Expand 10 after
6273 6273
6274 EXPECT_TRUE(observer.WasUserInteractionReceived()); 6274 EXPECT_TRUE(observer.WasUserInteractionReceived());
6275 6275
6276 // Target an event to the main frame. 6276 // Target an event to the main frame.
6277 observer.Reset(); 6277 observer.Reset();
6278 SimulateMouseClick(root->current_frame_host()->GetRenderWidgetHost(), 1, 1); 6278 SimulateMouseClick(root->current_frame_host()->GetRenderWidgetHost(), 1, 1);
6279 6279
6280 EXPECT_TRUE(observer.WasUserInteractionReceived()); 6280 EXPECT_TRUE(observer.WasUserInteractionReceived());
6281 } 6281 }
6282 6282
6283 // Check that out-of-process frames correctly calculate their ability to enter
6284 // fullscreen. A frame is allowed enter fullscreen if the allowFullscreen
6285 // attribute is present in all of its ancestor <iframe> elements. For OOPIF,
6286 // when a parent frame changes this attribute, the change is replicated to the
6287 // child frame and its proxies.
6288 //
6289 // The test checks the following cases:
6290 //
6291 // 1. Static attribute (<iframe allowfullscreen>)
6292 // 2. Attribute injected dynamically via JavaScript
6293 // 3. Multiple levels of nesting (A-embed-B-embed-C)
6294 // 4. Cross-site subframe navigation
6295 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, AllowFullscreen) {
6296 // Load a page with a cross-site <iframe allowFullscreen>.
6297 GURL url_1(embedded_test_server()->GetURL(
6298 "a.com", "/frame_tree/page_with_one_frame.html"));
6299 EXPECT_TRUE(NavigateToURL(shell(), url_1));
6300
6301 WebContentsImpl* contents = web_contents();
6302 FrameTreeNode* root = contents->GetFrameTree()->root();
6303
6304 // Helper to check if a frame is allowed to go fullscreen on the renderer
6305 // side.
6306 auto is_fullscreen_allowed = [](FrameTreeNode* ftn) {
6307 bool fullscreen_allowed = false;
6308 EXPECT_TRUE(ExecuteScriptAndExtractBool(
6309 ftn->current_frame_host(),
6310 "window.domAutomationController.send(document.webkitFullscreenEnabled)",
6311 &fullscreen_allowed));
6312 return fullscreen_allowed;
6313 };
6314
6315 EXPECT_TRUE(is_fullscreen_allowed(root));
6316 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
6317 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allowFullscreen);
6318
6319 // Now navigate to a page with two <iframe>'s, both without allowFullscreen.
6320 GURL url_2(embedded_test_server()->GetURL(
6321 "a.com", "/cross_site_iframe_factory.html?a(b,c)"));
6322 EXPECT_TRUE(NavigateToURL(shell(), url_2));
6323 EXPECT_FALSE(root->child_at(0)->frame_owner_properties().allowFullscreen);
6324 EXPECT_FALSE(root->child_at(1)->frame_owner_properties().allowFullscreen);
6325
6326 EXPECT_TRUE(is_fullscreen_allowed(root));
6327 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)));
6328 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(1)));
6329
6330 // Dynamically enable fullscreen for first subframe and check that the
6331 // fullscreen property was updated on the FrameTreeNode.
6332 EXPECT_TRUE(ExecuteScript(
6333 root->current_frame_host(),
6334 "document.getElementById('child-0').allowFullscreen='true'"));
6335 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allowFullscreen);
6336
6337 // Check that the first subframe is now allowed to go fullscreen. Other
6338 // frames shouldn't be affected.
6339 EXPECT_TRUE(is_fullscreen_allowed(root));
6340 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
6341 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(1)));
6342
6343 // Now navigate to a page with two levels of nesting.
6344 GURL url_3(embedded_test_server()->GetURL(
6345 "a.com", "/cross_site_iframe_factory.html?a(b(c))"));
6346 EXPECT_TRUE(NavigateToURL(shell(), url_3));
6347
6348 EXPECT_TRUE(is_fullscreen_allowed(root));
6349 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)));
6350 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
6351
6352 // Dynamically enable fullscreen for bottom subframe.
6353 EXPECT_TRUE(ExecuteScript(
6354 root->child_at(0)->current_frame_host(),
6355 "document.getElementById('child-0').allowFullscreen='true'"));
6356
6357 // This still shouldn't allow the bottom child to go fullscreen, since the
6358 // top frame hasn't allowed fullscreen for the middle frame.
6359 EXPECT_TRUE(is_fullscreen_allowed(root));
6360 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)));
6361 EXPECT_FALSE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
6362
6363 // Now allow fullscreen for the middle frame.
6364 EXPECT_TRUE(ExecuteScript(
6365 root->current_frame_host(),
6366 "document.getElementById('child-0').allowFullscreen='true'"));
6367
6368 // All frames should be allowed to go fullscreen now.
6369 EXPECT_TRUE(is_fullscreen_allowed(root));
6370 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
6371 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
6372
6373 // Cross-site navigation should preserve the fullscreen flags.
6374 NavigateFrameToURL(root->child_at(0)->child_at(0),
6375 embedded_test_server()->GetURL("d.com", "/title1.html"));
6376 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
6377 }
6378
6283 } // namespace content 6379 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698