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 8640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8651 // Start a URLRequest to the same URL. This should succeed. This would have | 8651 // Start a URLRequest to the same URL. This should succeed. This would have |
| 8652 // hit the 20 seconds delay before https://crbug.com/657195 was fixed. | 8652 // hit the 20 seconds delay before https://crbug.com/657195 was fixed. |
| 8653 EXPECT_TRUE(NavigateToURL(shell(), page_url)); | 8653 EXPECT_TRUE(NavigateToURL(shell(), page_url)); |
| 8654 EXPECT_EQ(page_url, shell()->web_contents()->GetLastCommittedURL()); | 8654 EXPECT_EQ(page_url, shell()->web_contents()->GetLastCommittedURL()); |
| 8655 | 8655 |
| 8656 // Note: even if the test fails and for some reason, the test has not timed | 8656 // Note: even if the test fails and for some reason, the test has not timed |
| 8657 // out by this point, the test teardown code will still hit a DCHECK when it | 8657 // out by this point, the test teardown code will still hit a DCHECK when it |
| 8658 // calls AssertNoURLRequests() in the shell's URLRequestContext destructor. | 8658 // calls AssertNoURLRequests() in the shell's URLRequestContext destructor. |
| 8659 } | 8659 } |
| 8660 | 8660 |
| 8661 // Ensure that an iframe that navigates cross-site doesn't use the same process | |
| 8662 // as its parent. Then when it navigates to its "srcdoc" attribute, it must | |
|
Charlie Reis
2016/11/23 08:02:25
nit: Then when its parent navigates it via the "sr
arthursonzogni
2016/11/23 09:00:48
Done.
| |
| 8663 // reuse its parent's process. | |
| 8664 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 8665 IframeSrcdocAfterCrossSiteNavigation) { | |
| 8666 GURL parent_url(embedded_test_server()->GetURL( | |
| 8667 "a.com", "/cross_site_iframe_factory.html?a(b)")); | |
| 8668 GURL child_url(embedded_test_server()->GetURL( | |
| 8669 "b.com", "/cross_site_iframe_factory.html?b()")); | |
| 8670 GURL blank_url(url::kAboutBlankURL); | |
|
Charlie Reis
2016/11/23 08:02:25
Sanity check: This will change to about:srcdoc aft
arthursonzogni
2016/11/23 09:00:48
Yes that's right. I confirm.
| |
| 8671 | |
| 8672 // #1 Navigate to a page with a cross-site iframe. | |
| 8673 EXPECT_TRUE(NavigateToURL(shell(), parent_url)); | |
| 8674 | |
| 8675 // Ensure that the iframe uses its own process. | |
| 8676 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | |
| 8677 ASSERT_EQ(1u, root->child_count()); | |
| 8678 FrameTreeNode* child = root->child_at(0); | |
| 8679 EXPECT_EQ(parent_url, root->current_url()); | |
| 8680 EXPECT_EQ(child_url, child->current_url()); | |
| 8681 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), | |
| 8682 child->current_frame_host()->GetSiteInstance()); | |
| 8683 EXPECT_NE(root->current_frame_host()->GetProcess(), | |
| 8684 child->current_frame_host()->GetProcess()); | |
| 8685 | |
| 8686 // #2 Navigate the iframe to its srcdoc attribute. | |
| 8687 TestNavigationObserver load_observer(shell()->web_contents()); | |
| 8688 EXPECT_TRUE(ExecuteScript( | |
| 8689 root, | |
| 8690 R"(document.getElementById("child-0").srcdoc = "srcdoc content";)")); | |
|
Charlie Reis
2016/11/23 08:02:25
Style nit: We don't use R (raw string literals) mu
arthursonzogni
2016/11/23 09:00:48
Done.
| |
| 8691 load_observer.Wait(); | |
| 8692 | |
| 8693 // Ensure that the iframe reuses its parent's process. | |
| 8694 EXPECT_EQ(blank_url, child->current_url()); | |
| 8695 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), | |
| 8696 child->current_frame_host()->GetSiteInstance()); | |
| 8697 EXPECT_EQ(root->current_frame_host()->GetProcess(), | |
| 8698 child->current_frame_host()->GetProcess()); | |
| 8699 } | |
| 8700 | |
| 8661 } // namespace content | 8701 } // namespace content |
| OLD | NEW |