| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/test/scoped_feature_list.h" | 10 #include "base/test/scoped_feature_list.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 return content::FrameMatchingPredicate( | 277 return content::FrameMatchingPredicate( |
| 278 web_contents, base::Bind(&content::FrameMatchesName, name)); | 278 web_contents, base::Bind(&content::FrameMatchesName, name)); |
| 279 }; | 279 }; |
| 280 content::RenderFrameHost* app = web_contents->GetMainFrame(); | 280 content::RenderFrameHost* app = web_contents->GetMainFrame(); |
| 281 content::RenderFrameHost* same_dir = find_frame("SameOrigin-SamePath"); | 281 content::RenderFrameHost* same_dir = find_frame("SameOrigin-SamePath"); |
| 282 content::RenderFrameHost* diff_dir = find_frame("SameOrigin-DifferentPath"); | 282 content::RenderFrameHost* diff_dir = find_frame("SameOrigin-DifferentPath"); |
| 283 content::RenderFrameHost* same_site = find_frame("OtherSubdomain-SameSite"); | 283 content::RenderFrameHost* same_site = find_frame("OtherSubdomain-SameSite"); |
| 284 content::RenderFrameHost* cross_site = find_frame("CrossSite"); | 284 content::RenderFrameHost* cross_site = find_frame("CrossSite"); |
| 285 | 285 |
| 286 // | 286 // |
| 287 // Sanity-check sites of all relevant frames to verify test setup. | |
| 288 // | |
| 289 | |
| 290 GURL app_site = content::SiteInstance::GetSiteForURL( | |
| 291 app_browser_->profile(), app->GetLastCommittedURL()); | |
| 292 EXPECT_EQ(extensions::kExtensionScheme, app_site.scheme()); | |
| 293 | |
| 294 GURL same_dir_site = content::SiteInstance::GetSiteForURL( | |
| 295 app_browser_->profile(), same_dir->GetLastCommittedURL()); | |
| 296 EXPECT_EQ(extensions::kExtensionScheme, same_dir_site.scheme()); | |
| 297 EXPECT_EQ(same_dir_site, app_site); | |
| 298 | |
| 299 GURL diff_dir_site = content::SiteInstance::GetSiteForURL( | |
| 300 app_browser_->profile(), diff_dir->GetLastCommittedURL()); | |
| 301 EXPECT_NE(extensions::kExtensionScheme, diff_dir_site.scheme()); | |
| 302 EXPECT_NE(diff_dir_site, app_site); | |
| 303 | |
| 304 GURL same_site_site = content::SiteInstance::GetSiteForURL( | |
| 305 app_browser_->profile(), same_site->GetLastCommittedURL()); | |
| 306 EXPECT_NE(extensions::kExtensionScheme, same_site_site.scheme()); | |
| 307 EXPECT_NE(same_site_site, app_site); | |
| 308 EXPECT_EQ(same_site_site, diff_dir_site); | |
| 309 | |
| 310 GURL cross_site_site = content::SiteInstance::GetSiteForURL( | |
| 311 app_browser_->profile(), cross_site->GetLastCommittedURL()); | |
| 312 EXPECT_NE(cross_site_site, app_site); | |
| 313 EXPECT_NE(cross_site_site, same_site_site); | |
| 314 | |
| 315 // | |
| 316 // Verify that |same_dir| and |diff_dir| can script each other. | 287 // Verify that |same_dir| and |diff_dir| can script each other. |
| 317 // (they should - they have the same origin). | 288 // (they should - they have the same origin). |
| 318 // | 289 // |
| 319 | 290 |
| 320 std::string same_dir_origin; | 291 std::string same_dir_origin; |
| 321 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 292 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 322 same_dir, "domAutomationController.send(window.origin)", | 293 same_dir, "domAutomationController.send(window.origin)", |
| 323 &same_dir_origin)); | 294 &same_dir_origin)); |
| 324 | 295 |
| 325 std::string diff_dir_origin; | 296 std::string diff_dir_origin; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 337 &inner_text_from_other_frame)); | 308 &inner_text_from_other_frame)); |
| 338 EXPECT_EQ("Simple test page.", inner_text_from_other_frame); | 309 EXPECT_EQ("Simple test page.", inner_text_from_other_frame); |
| 339 | 310 |
| 340 // | 311 // |
| 341 // Verify there are no additional processes for same-site frames. | 312 // Verify there are no additional processes for same-site frames. |
| 342 // | 313 // |
| 343 | 314 |
| 344 EXPECT_EQ(same_dir->GetProcess(), app->GetProcess()); | 315 EXPECT_EQ(same_dir->GetProcess(), app->GetProcess()); |
| 345 EXPECT_EQ(diff_dir->GetProcess(), app->GetProcess()); | 316 EXPECT_EQ(diff_dir->GetProcess(), app->GetProcess()); |
| 346 EXPECT_EQ(same_site->GetProcess(), app->GetProcess()); | 317 EXPECT_EQ(same_site->GetProcess(), app->GetProcess()); |
| 347 // For now it is okay for |cross_site| to be in any process - see | 318 if (content::AreAllSitesIsolatedForTesting()) { |
| 348 // https://crbug.com/679011#c2. | 319 EXPECT_NE(same_site->GetProcess(), cross_site->GetProcess()); |
| 320 } |
| 349 } | 321 } |
| OLD | NEW |