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

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

Issue 2494633004: Remove about:srcdoc url conversion. (Closed)
Patch Set: Fix tests with about::blank Created 4 years, 1 month 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_instance_impl.h" 5 #include "content/browser/site_instance_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // Test of distinguishing URLs from different sites. Most of this logic is 386 // Test of distinguishing URLs from different sites. Most of this logic is
387 // tested in RegistryControlledDomainTest. This test focuses on URLs with 387 // tested in RegistryControlledDomainTest. This test focuses on URLs with
388 // different schemes or ports. 388 // different schemes or ports.
389 TEST_F(SiteInstanceTest, IsSameWebSite) { 389 TEST_F(SiteInstanceTest, IsSameWebSite) {
390 GURL url_foo = GURL("http://foo/a.html"); 390 GURL url_foo = GURL("http://foo/a.html");
391 GURL url_foo2 = GURL("http://foo/b.html"); 391 GURL url_foo2 = GURL("http://foo/b.html");
392 GURL url_foo_https = GURL("https://foo/a.html"); 392 GURL url_foo_https = GURL("https://foo/a.html");
393 GURL url_foo_port = GURL("http://foo:8080/a.html"); 393 GURL url_foo_port = GURL("http://foo:8080/a.html");
394 GURL url_javascript = GURL("javascript:alert(1);"); 394 GURL url_javascript = GURL("javascript:alert(1);");
395 GURL url_blank = GURL(url::kAboutBlankURL); 395 GURL url_blank = GURL(url::kAboutBlankURL);
396 GURL url_srcdoc = GURL(content::kAboutSrcDocURL);
396 397
397 // Same scheme and port -> same site. 398 // Same scheme and port -> same site.
398 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_foo2)); 399 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_foo2));
399 400
400 // Different scheme -> different site. 401 // Different scheme -> different site.
401 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_foo_https)); 402 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_foo_https));
402 403
403 // Different port -> same site. 404 // Different port -> same site.
404 // (Changes to document.domain make renderer ignore the port.) 405 // (Changes to document.domain make renderer ignore the port.)
405 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_foo_port)); 406 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_foo_port));
406 407
407 // JavaScript links should be considered same site for anything. 408 // JavaScript links should be considered same site for anything.
408 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_javascript, url_foo)); 409 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_javascript, url_foo));
409 EXPECT_TRUE( 410 EXPECT_TRUE(
410 SiteInstance::IsSameWebSite(nullptr, url_javascript, url_foo_https)); 411 SiteInstance::IsSameWebSite(nullptr, url_javascript, url_foo_https));
411 EXPECT_TRUE( 412 EXPECT_TRUE(
412 SiteInstance::IsSameWebSite(nullptr, url_javascript, url_foo_port)); 413 SiteInstance::IsSameWebSite(nullptr, url_javascript, url_foo_port));
413 414
414 // Navigating to a blank page is considered the same site. 415 // Navigating to a blank page or about:srcdoc is considered the same site.
Charlie Reis 2016/11/22 01:01:20 As mentioned earlier, let's leave this out, or may
arthursonzogni 2016/11/22 16:43:27 Done (see above).
415 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_blank)); 416 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_blank));
416 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo_https, url_blank)); 417 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo_https, url_blank));
417 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo_port, url_blank)); 418 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo_port, url_blank));
419 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo, url_srcdoc));
420 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo_https, url_srcdoc));
421 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, url_foo_port, url_srcdoc));
418 422
419 // Navigating from a blank site is not considered to be the same site. 423 // Navigating from a blank site or from about:srcdoc is not considered to be
424 // the same site.
420 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_blank, url_foo)); 425 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_blank, url_foo));
421 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_blank, url_foo_https)); 426 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_blank, url_foo_https));
422 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_blank, url_foo_port)); 427 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_blank, url_foo_port));
428 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_srcdoc, url_foo));
429 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_srcdoc, url_foo_https));
430 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, url_srcdoc, url_foo_port));
423 431
424 DrainMessageLoop(); 432 DrainMessageLoop();
425 } 433 }
426 434
427 // Test to ensure that there is only one SiteInstance per site in a given 435 // Test to ensure that there is only one SiteInstance per site in a given
428 // BrowsingInstance, when process-per-site is not in use. 436 // BrowsingInstance, when process-per-site is not in use.
429 TEST_F(SiteInstanceTest, OneSiteInstancePerSite) { 437 TEST_F(SiteInstanceTest, OneSiteInstancePerSite) {
430 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( 438 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
431 switches::kProcessPerSite)); 439 switches::kProcessPerSite));
432 std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); 440 std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); 848 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount());
841 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); 849 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount());
842 850
843 // Free the subframe instance, which should free the browsing instance. 851 // Free the subframe instance, which should free the browsing instance.
844 subframe_instance = nullptr; 852 subframe_instance = nullptr;
845 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); 853 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount());
846 EXPECT_EQ(1, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); 854 EXPECT_EQ(1, browser_client()->GetAndClearBrowsingInstanceDeleteCount());
847 } 855 }
848 856
849 } // namespace content 857 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698