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

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

Issue 2697713003: Initial Implementation of Iframe Attribute for Feature Policy (Part 2) (Closed)
Patch Set: Initial Impl Created 3 years, 10 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "content/public/test/test_navigation_observer.h" 63 #include "content/public/test/test_navigation_observer.h"
64 #include "content/public/test/test_utils.h" 64 #include "content/public/test/test_utils.h"
65 #include "content/shell/browser/shell.h" 65 #include "content/shell/browser/shell.h"
66 #include "content/test/content_browser_test_utils_internal.h" 66 #include "content/test/content_browser_test_utils_internal.h"
67 #include "ipc/ipc.mojom.h" 67 #include "ipc/ipc.mojom.h"
68 #include "ipc/ipc_security_test_util.h" 68 #include "ipc/ipc_security_test_util.h"
69 #include "net/dns/mock_host_resolver.h" 69 #include "net/dns/mock_host_resolver.h"
70 #include "net/test/embedded_test_server/embedded_test_server.h" 70 #include "net/test/embedded_test_server/embedded_test_server.h"
71 #include "net/test/embedded_test_server/http_request.h" 71 #include "net/test/embedded_test_server/http_request.h"
72 #include "net/test/embedded_test_server/http_response.h" 72 #include "net/test/embedded_test_server/http_response.h"
73 #include "testing/gmock/include/gmock/gmock.h"
73 #include "testing/gtest/include/gtest/gtest.h" 74 #include "testing/gtest/include/gtest/gtest.h"
75 #include "third_party/WebKit/public/platform/WebFeaturePolicy.h"
74 #include "third_party/WebKit/public/platform/WebInputEvent.h" 76 #include "third_party/WebKit/public/platform/WebInputEvent.h"
75 #include "third_party/WebKit/public/platform/WebInsecureRequestPolicy.h" 77 #include "third_party/WebKit/public/platform/WebInsecureRequestPolicy.h"
76 #include "third_party/WebKit/public/web/WebSandboxFlags.h" 78 #include "third_party/WebKit/public/web/WebSandboxFlags.h"
77 #include "ui/display/display_switches.h" 79 #include "ui/display/display_switches.h"
78 #include "ui/display/screen.h" 80 #include "ui/display/screen.h"
79 #include "ui/events/base_event_utils.h" 81 #include "ui/events/base_event_utils.h"
80 #include "ui/events/event.h" 82 #include "ui/events/event.h"
81 #include "ui/events/event_utils.h" 83 #include "ui/events/event_utils.h"
82 #include "ui/events/latency_info.h" 84 #include "ui/events/latency_info.h"
83 #include "ui/gfx/geometry/point.h" 85 #include "ui/gfx/geometry/point.h"
(...skipping 9099 matching lines...) Expand 10 before | Expand all | Expand 10 after
9183 EXPECT_TRUE(NavigateToURL( 9185 EXPECT_TRUE(NavigateToURL(
9184 shell(), embedded_test_server()->GetURL("b.com", "/title3.html"))); 9186 shell(), embedded_test_server()->GetURL("b.com", "/title3.html")));
9185 9187
9186 // Pretend that a.com just requested a context menu. This used to cause a 9188 // Pretend that a.com just requested a context menu. This used to cause a
9187 // because the RenderWidgetHostView is destroyed when the frame is swapped and 9189 // because the RenderWidgetHostView is destroyed when the frame is swapped and
9188 // added to pending delete list. 9190 // added to pending delete list.
9189 rfh->OnMessageReceived( 9191 rfh->OnMessageReceived(
9190 FrameHostMsg_ContextMenu(rfh->GetRoutingID(), ContextMenuParams())); 9192 FrameHostMsg_ContextMenu(rfh->GetRoutingID(), ContextMenuParams()));
9191 } 9193 }
9192 9194
9195 // Test iframe "allow" attribute is propogated correctly, both on same-site and
9196 // cross-site iframes.
9197 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, AllowedIFrames) {
9198 GURL url(embedded_test_server()->GetURL("/allowed_frames.html"));
9199 EXPECT_TRUE(NavigateToURL(shell(), url));
9200
9201 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
9202
9203 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"),
9204 root->child_at(0)->current_url());
9205
9206 EXPECT_EQ(
9207 root->child_at(0)->frame_owner_properties().allowed_feature_names.size(),
9208 2u);
9209 EXPECT_EQ(
9210 root->child_at(0)->frame_owner_properties().allowed_feature_names[0],
9211 blink::WebFeaturePolicyFeature::Fullscreen);
9212 EXPECT_EQ(
9213 root->child_at(0)->frame_owner_properties().allowed_feature_names[1],
9214 blink::WebFeaturePolicyFeature::Vibrate);
9215 EXPECT_EQ(
9216 root->child_at(1)->frame_owner_properties().allowed_feature_names.size(),
9217 2u);
9218 EXPECT_EQ(
9219 root->child_at(1)->frame_owner_properties().allowed_feature_names[0],
9220 blink::WebFeaturePolicyFeature::Fullscreen);
9221 EXPECT_EQ(
9222 root->child_at(1)->frame_owner_properties().allowed_feature_names[1],
9223 blink::WebFeaturePolicyFeature::Vibrate);
9224 }
9225
9226 // Test dynamic updates to iframe "allow" attribute are propogated correctly,
9227 // both on same-site and cross-site iframes.
9228 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, AllowedIFramesDynamic) {
9229 GURL main_url(embedded_test_server()->GetURL("/allowed_frames.html"));
9230 EXPECT_TRUE(NavigateToURL(shell(), main_url));
9231
9232 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
9233
9234 EXPECT_TRUE(ExecuteScript(
9235 root, "document.getElementById('child-1').removeAttribute('allow')"));
9236 EXPECT_TRUE(ExecuteScript(
9237 root,
9238 "document.getElementById('child-2').setAttribute('allow', 'payment')"));
9239
9240 EXPECT_TRUE(root->child_at(0)
9241 ->frame_owner_properties()
9242 .allowed_feature_names.empty());
9243 EXPECT_EQ(
9244 root->child_at(1)->frame_owner_properties().allowed_feature_names.size(),
9245 1u);
9246 EXPECT_EQ(
9247 root->child_at(1)->frame_owner_properties().allowed_feature_names[0],
9248 blink::WebFeaturePolicyFeature::Payment);
9249 }
9250
9193 // Test harness that allows for "barrier" style delaying of requests matching 9251 // Test harness that allows for "barrier" style delaying of requests matching
9194 // certain paths. Call SetDelayedRequestsForPath to delay requests, then 9252 // certain paths. Call SetDelayedRequestsForPath to delay requests, then
9195 // SetUpEmbeddedTestServer to register handlers and start the server. 9253 // SetUpEmbeddedTestServer to register handlers and start the server.
9196 class RequestDelayingSitePerProcessBrowserTest 9254 class RequestDelayingSitePerProcessBrowserTest
9197 : public SitePerProcessBrowserTest { 9255 : public SitePerProcessBrowserTest {
9198 public: 9256 public:
9199 RequestDelayingSitePerProcessBrowserTest() 9257 RequestDelayingSitePerProcessBrowserTest()
9200 : test_server_(base::MakeUnique<net::EmbeddedTestServer>()) {} 9258 : test_server_(base::MakeUnique<net::EmbeddedTestServer>()) {}
9201 9259
9202 // Must be called after any calls to SetDelayedRequestsForPath. 9260 // Must be called after any calls to SetDelayedRequestsForPath.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
9334 "subframes_with_resources.html?urls=%s,%s&" 9392 "subframes_with_resources.html?urls=%s,%s&"
9335 "numSubresources=3", 9393 "numSubresources=3",
9336 path0.c_str(), path1.c_str()))); 9394 path0.c_str(), path1.c_str())));
9337 EXPECT_TRUE(NavigateToURL(shell(), url)); 9395 EXPECT_TRUE(NavigateToURL(shell(), url));
9338 bool result; 9396 bool result;
9339 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell(), "createFrames()", &result)); 9397 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell(), "createFrames()", &result));
9340 EXPECT_TRUE(result); 9398 EXPECT_TRUE(result);
9341 } 9399 }
9342 9400
9343 } // namespace content 9401 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698