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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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. | |
|
kenrb
2017/02/17 17:41:15
nit: s/propogated/propagated
| |
| 9196 IN_PROC_BROWSER_TEST_F(SitePerProcessFeaturePolicyBrowserTest, AllowedIFrames) { | |
| 9197 GURL url(embedded_test_server()->GetURL("/allowed_frames.html")); | |
| 9198 EXPECT_TRUE(NavigateToURL(shell(), url)); | |
| 9199 | |
| 9200 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | |
| 9201 | |
| 9202 // Iframes without "allow" attribute, or an empty "allow" attribute will not | |
| 9203 // have any allowed features propogated. | |
| 9204 EXPECT_TRUE( | |
| 9205 root->child_at(0)->frame_owner_properties().allowed_features.empty()); | |
| 9206 EXPECT_TRUE( | |
| 9207 root->child_at(1)->frame_owner_properties().allowed_features.empty()); | |
| 9208 | |
| 9209 // Make sure the third frame starts out at the correct cross-site page. | |
| 9210 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"), | |
| 9211 root->child_at(2)->current_url()); | |
| 9212 // Check allowed features are propogated correctly for cross-site iframes. | |
| 9213 EXPECT_EQ(root->child_at(2)->frame_owner_properties().allowed_features.size(), | |
| 9214 2u); | |
| 9215 EXPECT_EQ(root->child_at(2)->frame_owner_properties().allowed_features[0], | |
| 9216 blink::WebFeaturePolicyFeature::Fullscreen); | |
| 9217 EXPECT_EQ(root->child_at(2)->frame_owner_properties().allowed_features[1], | |
| 9218 blink::WebFeaturePolicyFeature::Vibrate); | |
| 9219 | |
| 9220 // Check allowed features are propogated correctly for same-site iframes. | |
| 9221 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features.size(), | |
| 9222 2u); | |
| 9223 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[0], | |
| 9224 blink::WebFeaturePolicyFeature::Fullscreen); | |
| 9225 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[1], | |
| 9226 blink::WebFeaturePolicyFeature::Vibrate); | |
| 9227 } | |
| 9228 | |
| 9229 // Test dynamic updates to iframe "allow" attribute are propogated correctly. | |
| 9230 IN_PROC_BROWSER_TEST_F(SitePerProcessFeaturePolicyBrowserTest, | |
| 9231 AllowedIFramesDynamic) { | |
| 9232 GURL main_url(embedded_test_server()->GetURL("/allowed_frames.html")); | |
| 9233 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
| 9234 | |
| 9235 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | |
| 9236 | |
| 9237 // Test for dynamically removing "allow" attribute. | |
| 9238 EXPECT_TRUE(ExecuteScript( | |
| 9239 root, "document.getElementById('child-2').removeAttribute('allow')")); | |
| 9240 EXPECT_TRUE( | |
| 9241 root->child_at(2)->frame_owner_properties().allowed_features.empty()); | |
| 9242 | |
| 9243 // Test for dynamically setting "allow" attribute by element.setAttribute. | |
| 9244 EXPECT_TRUE(ExecuteScript( | |
| 9245 root, | |
| 9246 "document.getElementById('child-3').setAttribute('allow', 'payment')")); | |
| 9247 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features.size(), | |
| 9248 1u); | |
| 9249 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[0], | |
| 9250 blink::WebFeaturePolicyFeature::Payment); | |
| 9251 | |
| 9252 // Test for dynamically setting "allow" attribute by frame.allow="...". | |
| 9253 EXPECT_TRUE(ExecuteScript( | |
| 9254 root, "document.getElementById('child-3').allow='fullscreen vibrate'")); | |
| 9255 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features.size(), | |
| 9256 2u); | |
| 9257 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[0], | |
| 9258 blink::WebFeaturePolicyFeature::Fullscreen); | |
| 9259 EXPECT_EQ(root->child_at(3)->frame_owner_properties().allowed_features[1], | |
| 9260 blink::WebFeaturePolicyFeature::Vibrate); | |
| 9261 } | |
| 9262 | |
| 9193 // Test harness that allows for "barrier" style delaying of requests matching | 9263 // Test harness that allows for "barrier" style delaying of requests matching |
| 9194 // certain paths. Call SetDelayedRequestsForPath to delay requests, then | 9264 // certain paths. Call SetDelayedRequestsForPath to delay requests, then |
| 9195 // SetUpEmbeddedTestServer to register handlers and start the server. | 9265 // SetUpEmbeddedTestServer to register handlers and start the server. |
| 9196 class RequestDelayingSitePerProcessBrowserTest | 9266 class RequestDelayingSitePerProcessBrowserTest |
| 9197 : public SitePerProcessBrowserTest { | 9267 : public SitePerProcessBrowserTest { |
| 9198 public: | 9268 public: |
| 9199 RequestDelayingSitePerProcessBrowserTest() | 9269 RequestDelayingSitePerProcessBrowserTest() |
| 9200 : test_server_(base::MakeUnique<net::EmbeddedTestServer>()) {} | 9270 : test_server_(base::MakeUnique<net::EmbeddedTestServer>()) {} |
| 9201 | 9271 |
| 9202 // Must be called after any calls to SetDelayedRequestsForPath. | 9272 // Must be called after any calls to SetDelayedRequestsForPath. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9334 "subframes_with_resources.html?urls=%s,%s&" | 9404 "subframes_with_resources.html?urls=%s,%s&" |
| 9335 "numSubresources=3", | 9405 "numSubresources=3", |
| 9336 path0.c_str(), path1.c_str()))); | 9406 path0.c_str(), path1.c_str()))); |
| 9337 EXPECT_TRUE(NavigateToURL(shell(), url)); | 9407 EXPECT_TRUE(NavigateToURL(shell(), url)); |
| 9338 bool result; | 9408 bool result; |
| 9339 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell(), "createFrames()", &result)); | 9409 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell(), "createFrames()", &result)); |
| 9340 EXPECT_TRUE(result); | 9410 EXPECT_TRUE(result); |
| 9341 } | 9411 } |
| 9342 | 9412 |
| 9343 } // namespace content | 9413 } // namespace content |
| OLD | NEW |