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

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

Issue 2331223002: Added allowvr attribute to iframes and vrEnabled to Document (Closed)
Patch Set: Rebase and moved vrEnabled from navigator to document Created 4 years, 3 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 public: 583 public:
584 SitePerProcessIgnoreCertErrorsBrowserTest() {} 584 SitePerProcessIgnoreCertErrorsBrowserTest() {}
585 585
586 protected: 586 protected:
587 void SetUpCommandLine(base::CommandLine* command_line) override { 587 void SetUpCommandLine(base::CommandLine* command_line) override {
588 SitePerProcessBrowserTest::SetUpCommandLine(command_line); 588 SitePerProcessBrowserTest::SetUpCommandLine(command_line);
589 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); 589 command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
590 } 590 }
591 }; 591 };
592 592
593 //
594 // SitePerProcessWebVRBrowserTest
595 //
596
597 class SitePerProcessWebVRBrowserTest : public SitePerProcessBrowserTest {
598 public:
599 SitePerProcessWebVRBrowserTest() {}
600
601 protected:
602 void SetUpCommandLine(base::CommandLine* command_line) override {
603 SitePerProcessBrowserTest::SetUpCommandLine(command_line);
604 command_line->AppendSwitch(switches::kEnableWebVR);
605 }
606 };
607
593 double GetFrameDeviceScaleFactor(const ToRenderFrameHost& adapter) { 608 double GetFrameDeviceScaleFactor(const ToRenderFrameHost& adapter) {
594 double device_scale_factor; 609 double device_scale_factor;
595 const char kGetFrameDeviceScaleFactor[] = 610 const char kGetFrameDeviceScaleFactor[] =
596 "window.domAutomationController.send(window.devicePixelRatio);"; 611 "window.domAutomationController.send(window.devicePixelRatio);";
597 EXPECT_TRUE(ExecuteScriptAndExtractDouble(adapter, kGetFrameDeviceScaleFactor, 612 EXPECT_TRUE(ExecuteScriptAndExtractDouble(adapter, kGetFrameDeviceScaleFactor,
598 &device_scale_factor)); 613 &device_scale_factor));
599 return device_scale_factor; 614 return device_scale_factor;
600 } 615 }
601 616
602 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, 617 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest,
(...skipping 6858 matching lines...) Expand 10 before | Expand all | Expand 10 after
7461 EXPECT_TRUE(is_fullscreen_allowed(root)); 7476 EXPECT_TRUE(is_fullscreen_allowed(root));
7462 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); 7477 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
7463 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7478 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7464 7479
7465 // Cross-site navigation should preserve the fullscreen flags. 7480 // Cross-site navigation should preserve the fullscreen flags.
7466 NavigateFrameToURL(root->child_at(0)->child_at(0), 7481 NavigateFrameToURL(root->child_at(0)->child_at(0),
7467 embedded_test_server()->GetURL("d.com", "/title1.html")); 7482 embedded_test_server()->GetURL("d.com", "/title1.html"));
7468 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7483 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7469 } 7484 }
7470 7485
7486 // Check that out-of-process frames correctly calculate their ability to enter
7487 // VR. A frame is allowed enter VR if the allowVR attribute is present in all of
7488 // its ancestor <iframe> elements. For OOPIF, when a parent frame changes this
7489 // attribute, the change is replicated to the child frame and its proxies.
7490 //
7491 // The test checks the following cases:
7492 //
7493 // 1. Static attribute (<iframe allowvr>)
7494 // 2. Attribute injected dynamically via JavaScript
7495 // 3. Multiple levels of nesting (A-embed-B-embed-C)
7496 // 4. Cross-site subframe navigation
7497 IN_PROC_BROWSER_TEST_F(SitePerProcessWebVRBrowserTest, AllowVR) {
7498 // Load a page with a cross-site <iframe allowvr>.
7499 GURL url_1(embedded_test_server()->GetURL(
7500 "a.com", "/page_with_allowvr_frame.html"));
7501 EXPECT_TRUE(NavigateToURL(shell(), url_1));
7502
7503 WebContentsImpl* contents = web_contents();
7504 FrameTreeNode* root = contents->GetFrameTree()->root();
7505
7506 // Helper to check if a frame is allowed to go VR on the renderer
7507 // side.
7508 auto is_vr_allowed = [](FrameTreeNode* ftn) {
7509 bool vr_allowed = false;
7510 EXPECT_TRUE(ExecuteScriptAndExtractBool(
7511 ftn,
7512 "window.domAutomationController.send(navigator.vrEnabled)",
7513 &vr_allowed));
7514 return vr_allowed;
7515 };
7516
7517 EXPECT_TRUE(is_vr_allowed(root));
7518 EXPECT_TRUE(is_vr_allowed(root->child_at(0)));
7519 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allow_vr);
7520
7521 // Now navigate to a page with two <iframe>'s, both without allowvr.
7522 GURL url_2(embedded_test_server()->GetURL(
7523 "a.com", "/cross_site_iframe_factory.html?a(b,c)"));
7524 EXPECT_TRUE(NavigateToURL(shell(), url_2));
7525 EXPECT_FALSE(root->child_at(0)->frame_owner_properties().allow_vr);
7526 EXPECT_FALSE(root->child_at(1)->frame_owner_properties().allow_vr);
7527
7528 EXPECT_TRUE(is_vr_allowed(root));
7529 EXPECT_FALSE(is_vr_allowed(root->child_at(0)));
7530 EXPECT_FALSE(is_vr_allowed(root->child_at(1)));
7531
7532 // Dynamically enable VR for first subframe and check that the
7533 // VR property was updated on the FrameTreeNode.
7534 EXPECT_TRUE(ExecuteScript(
7535 root, "document.getElementById('child-0').allowVR='true'"));
7536 EXPECT_TRUE(root->child_at(0)->frame_owner_properties().allow_vr);
7537
7538 // Check that the first subframe is now allowed to go VR. Other
7539 // frames shouldn't be affected.
7540 EXPECT_TRUE(is_vr_allowed(root));
7541 EXPECT_TRUE(is_vr_allowed(root->child_at(0)));
7542 EXPECT_FALSE(is_vr_allowed(root->child_at(1)));
7543
7544 // Now navigate to a page with two levels of nesting.
7545 GURL url_3(embedded_test_server()->GetURL(
7546 "a.com", "/cross_site_iframe_factory.html?a(b(c))"));
7547 EXPECT_TRUE(NavigateToURL(shell(), url_3));
7548
7549 EXPECT_TRUE(is_vr_allowed(root));
7550 EXPECT_FALSE(is_vr_allowed(root->child_at(0)));
7551 EXPECT_FALSE(is_vr_allowed(root->child_at(0)->child_at(0)));
7552
7553 // Dynamically enable vr for bottom subframe.
7554 EXPECT_TRUE(ExecuteScript(
7555 root->child_at(0),
7556 "document.getElementById('child-0').allowVR='true'"));
7557
7558 // This still shouldn't allow the bottom child to go VR, since the
7559 // top frame hasn't allowed VR for the middle frame.
7560 EXPECT_TRUE(is_vr_allowed(root));
7561 EXPECT_FALSE(is_vr_allowed(root->child_at(0)));
7562 EXPECT_FALSE(is_vr_allowed(root->child_at(0)->child_at(0)));
7563
7564 // Now allow vr for the middle frame.
7565 EXPECT_TRUE(ExecuteScript(
7566 root, "document.getElementById('child-0').allowVR='true'"));
7567
7568 // All frames should be allowed to go VR now.
7569 EXPECT_TRUE(is_vr_allowed(root));
7570 EXPECT_TRUE(is_vr_allowed(root->child_at(0)));
7571 EXPECT_TRUE(is_vr_allowed(root->child_at(0)->child_at(0)));
7572
7573 // Cross-site navigation should preserve the VR flags.
7574 NavigateFrameToURL(root->child_at(0)->child_at(0),
7575 embedded_test_server()->GetURL("d.com", "/title1.html"));
7576 EXPECT_TRUE(is_vr_allowed(root->child_at(0)->child_at(0)));
7577 }
7578
7471 // Test for https://crbug.com/615575. It ensures that file chooser triggered 7579 // Test for https://crbug.com/615575. It ensures that file chooser triggered
7472 // by a document in an out-of-process subframe works properly. 7580 // by a document in an out-of-process subframe works properly.
7473 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, FileChooserInSubframe) { 7581 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, FileChooserInSubframe) {
7474 EXPECT_TRUE(NavigateToURL(shell(), embedded_test_server()->GetURL( 7582 EXPECT_TRUE(NavigateToURL(shell(), embedded_test_server()->GetURL(
7475 "a.com", "/cross_site_iframe_factory.html?a(b)"))); 7583 "a.com", "/cross_site_iframe_factory.html?a(b)")));
7476 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 7584 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
7477 7585
7478 GURL url(embedded_test_server()->GetURL("b.com", "/file_input.html")); 7586 GURL url(embedded_test_server()->GetURL("b.com", "/file_input.html"));
7479 NavigateFrameToURL(root->child_at(0), url); 7587 NavigateFrameToURL(root->child_at(0), url);
7480 7588
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
8091 " Site A ------------ proxies for B C\n" 8199 " Site A ------------ proxies for B C\n"
8092 " +--Site B ------- proxies for A C\n" 8200 " +--Site B ------- proxies for A C\n"
8093 " +--Site C -- proxies for A B\n" 8201 " +--Site C -- proxies for A B\n"
8094 "Where A = http://a.com/\n" 8202 "Where A = http://a.com/\n"
8095 " B = http://b.com/\n" 8203 " B = http://b.com/\n"
8096 " C = http://c.com/", 8204 " C = http://c.com/",
8097 DepictFrameTree(root)); 8205 DepictFrameTree(root));
8098 } 8206 }
8099 8207
8100 } // namespace content 8208 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/frame_owner_properties.h » ('j') | third_party/WebKit/Source/modules/vr/DocumentVR.idl » ('J')

Powered by Google App Engine
This is Rietveld 408576698