Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 3331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3342 EXPECT_EQ(2, controller.GetEntryCount()); | 3342 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3343 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3343 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 3344 | 3344 |
| 3345 // 3. Go back, recreating the subframes. | 3345 // 3. Go back, recreating the subframes. |
| 3346 { | 3346 { |
| 3347 TestNavigationObserver back_load_observer(shell()->web_contents()); | 3347 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 3348 controller.GoBack(); | 3348 controller.GoBack(); |
| 3349 back_load_observer.Wait(); | 3349 back_load_observer.Wait(); |
| 3350 } | 3350 } |
| 3351 ASSERT_EQ(1U, root->child_count()); | 3351 ASSERT_EQ(1U, root->child_count()); |
| 3352 // TODO(creis): This line is unexpectedly failing in PlzNavigate, so the test | |
| 3353 // is disabled there for now. | |
| 3354 ASSERT_EQ(1U, root->child_at(0)->child_count()); | 3352 ASSERT_EQ(1U, root->child_at(0)->child_count()); |
| 3355 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); | 3353 ASSERT_EQ(0U, root->child_at(0)->child_at(0)->child_count()); |
| 3356 EXPECT_EQ(main_url, root->current_url()); | 3354 EXPECT_EQ(main_url, root->current_url()); |
| 3357 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); | 3355 EXPECT_EQ(blank_url, root->child_at(0)->current_url()); |
| 3358 | 3356 |
| 3359 // Verify that the inner iframe went to the correct URL. | 3357 // Verify that the inner iframe went to the correct URL. |
| 3360 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); | 3358 EXPECT_EQ(inner_url, root->child_at(0)->child_at(0)->current_url()); |
| 3361 | 3359 |
| 3362 EXPECT_EQ(2, controller.GetEntryCount()); | 3360 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3363 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3361 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| (...skipping 3417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6781 | 6779 |
| 6782 // Check the FrameNavigationEntry's referrer. | 6780 // Check the FrameNavigationEntry's referrer. |
| 6783 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 6781 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 6784 ASSERT_EQ(1U, entry->root_node()->children.size()); | 6782 ASSERT_EQ(1U, entry->root_node()->children.size()); |
| 6785 FrameNavigationEntry* frame_entry = | 6783 FrameNavigationEntry* frame_entry = |
| 6786 entry->root_node()->children[0]->frame_entry.get(); | 6784 entry->root_node()->children[0]->frame_entry.get(); |
| 6787 EXPECT_EQ(frame_entry->referrer().url, url); | 6785 EXPECT_EQ(frame_entry->referrer().url, url); |
| 6788 } | 6786 } |
| 6789 } | 6787 } |
| 6790 | 6788 |
| 6789 // Verifies that FrameNavigationEntry's srcdoc attribute is valid. | |
|
alexmos
2016/11/07 22:51:46
nit: might be useful to include a reference to htt
arthursonzogni
2016/11/08 12:21:30
Yes, this CL is related to this bug. But this test
| |
| 6790 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | |
| 6791 FrameNavigationEntry_Srcdoc) { | |
| 6792 // This test only makes sense when subframe FrameNavigationEntries are in use. | |
| 6793 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
| 6794 return; | |
| 6795 | |
| 6796 const NavigationControllerImpl& controller = | |
| 6797 static_cast<const NavigationControllerImpl&>( | |
| 6798 shell()->web_contents()->GetController()); | |
| 6799 | |
| 6800 // Navigate to a page with two iframes, one with the srcdoc attribute and one | |
| 6801 // without it. | |
| 6802 GURL url(embedded_test_server()->GetURL( | |
| 6803 "/navigation_controller/page_with_srcdoc.html")); | |
| 6804 ASSERT_TRUE(NavigateToURL(shell(), url)); | |
| 6805 | |
| 6806 // Check that there is two iframes. | |
| 6807 ASSERT_EQ(1, controller.GetEntryCount()); | |
| 6808 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | |
| 6809 ASSERT_EQ(2U, entry->root_node()->children.size()); | |
| 6810 FrameNavigationEntry* frame_entry_1 = | |
| 6811 entry->root_node()->children[0]->frame_entry.get(); | |
| 6812 FrameNavigationEntry* frame_entry_2 = | |
| 6813 entry->root_node()->children[1]->frame_entry.get(); | |
| 6814 | |
| 6815 // The FrameNavigationEntry's order is not guaranteed to be preserved. Swap | |
| 6816 // the entries if there is an inversion. | |
|
alexmos
2016/11/07 22:51:45
Instead of reordering, can you get the FNEs via Fr
arthursonzogni
2016/11/08 12:21:30
Thanks! It is better now.
| |
| 6817 GURL iframe_2_url(embedded_test_server()->GetURL( | |
| 6818 "/navigation_controller/simple_page_1.html")); | |
| 6819 if (frame_entry_2->url() != iframe_2_url) | |
| 6820 std::swap(frame_entry_1,frame_entry_2); | |
| 6821 | |
| 6822 // Check the is_srcdoc() method returns the right value. | |
| 6823 EXPECT_EQ(frame_entry_1->is_srcdoc(), true); | |
| 6824 EXPECT_EQ(frame_entry_2->is_srcdoc(), false); | |
| 6825 | |
| 6826 // Check the iframe URL has been converted from about::srcdoc to about::blank. | |
| 6827 EXPECT_EQ(frame_entry_1->url(), GURL(url::kAboutBlankURL)); | |
| 6828 EXPECT_EQ(frame_entry_2->url(), iframe_2_url); | |
|
alexmos
2016/11/07 22:51:46
Is the part with restoring a srcdoc iframe after a
arthursonzogni
2016/11/08 12:21:30
I am not sure I fully understand the question. The
| |
| 6829 } | |
| 6830 | |
| 6791 namespace { | 6831 namespace { |
| 6792 | 6832 |
| 6793 class RequestMonitoringNavigationBrowserTest : public ContentBrowserTest { | 6833 class RequestMonitoringNavigationBrowserTest : public ContentBrowserTest { |
| 6794 public: | 6834 public: |
| 6795 RequestMonitoringNavigationBrowserTest() : weak_factory_(this) {} | 6835 RequestMonitoringNavigationBrowserTest() : weak_factory_(this) {} |
| 6796 | 6836 |
| 6797 const net::test_server::HttpRequest* FindAccumulatedRequest( | 6837 const net::test_server::HttpRequest* FindAccumulatedRequest( |
| 6798 const GURL& url_to_find) { | 6838 const GURL& url_to_find) { |
| 6799 // net::test_server::HttpRequest::GetURL hardcodes "http://localhost/" part. | 6839 // net::test_server::HttpRequest::GetURL hardcodes "http://localhost/" part. |
| 6800 GURL::Replacements replacements; | 6840 GURL::Replacements replacements; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6903 // Verify that the extra header was NOT present for the subresource. | 6943 // Verify that the extra header was NOT present for the subresource. |
| 6904 const net::test_server::HttpRequest* image_request = | 6944 const net::test_server::HttpRequest* image_request = |
| 6905 FindAccumulatedRequest(image_url); | 6945 FindAccumulatedRequest(image_url); |
| 6906 ASSERT_TRUE(image_request); | 6946 ASSERT_TRUE(image_request); |
| 6907 EXPECT_THAT(image_request->headers, | 6947 EXPECT_THAT(image_request->headers, |
| 6908 testing::Not(testing::Contains( | 6948 testing::Not(testing::Contains( |
| 6909 testing::Key("X-ExtraHeadersVsSubresources")))); | 6949 testing::Key("X-ExtraHeadersVsSubresources")))); |
| 6910 } | 6950 } |
| 6911 | 6951 |
| 6912 } // namespace content | 6952 } // namespace content |
| OLD | NEW |