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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2482873002: Add is_srcdoc to FrameNavigationEntry and restore about::srcdoc URL. (Closed)
Patch Set: Addressed comments (@nasko) 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 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
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
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.
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 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
6811 ->GetFrameTree()
6812 ->root();
6813 FrameNavigationEntry* frame_entry_1 = entry->GetFrameEntry(root->child_at(0));
6814 FrameNavigationEntry* frame_entry_2 = entry->GetFrameEntry(root->child_at(1));
6815
6816 // Check the is_srcdoc() method returns the right value.
6817 EXPECT_EQ(frame_entry_1->is_srcdoc(), true);
6818 EXPECT_EQ(frame_entry_2->is_srcdoc(), false);
6819
6820 // Check the iframe URL has been converted from about::srcdoc to about::blank.
6821 EXPECT_EQ(frame_entry_1->url(), GURL(url::kAboutBlankURL));
6822 }
6823
6791 namespace { 6824 namespace {
6792 6825
6793 class RequestMonitoringNavigationBrowserTest : public ContentBrowserTest { 6826 class RequestMonitoringNavigationBrowserTest : public ContentBrowserTest {
6794 public: 6827 public:
6795 RequestMonitoringNavigationBrowserTest() : weak_factory_(this) {} 6828 RequestMonitoringNavigationBrowserTest() : weak_factory_(this) {}
6796 6829
6797 const net::test_server::HttpRequest* FindAccumulatedRequest( 6830 const net::test_server::HttpRequest* FindAccumulatedRequest(
6798 const GURL& url_to_find) { 6831 const GURL& url_to_find) {
6799 // net::test_server::HttpRequest::GetURL hardcodes "http://localhost/" part. 6832 // net::test_server::HttpRequest::GetURL hardcodes "http://localhost/" part.
6800 GURL::Replacements replacements; 6833 GURL::Replacements replacements;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
6903 // Verify that the extra header was NOT present for the subresource. 6936 // Verify that the extra header was NOT present for the subresource.
6904 const net::test_server::HttpRequest* image_request = 6937 const net::test_server::HttpRequest* image_request =
6905 FindAccumulatedRequest(image_url); 6938 FindAccumulatedRequest(image_url);
6906 ASSERT_TRUE(image_request); 6939 ASSERT_TRUE(image_request);
6907 EXPECT_THAT(image_request->headers, 6940 EXPECT_THAT(image_request->headers,
6908 testing::Not(testing::Contains( 6941 testing::Not(testing::Contains(
6909 testing::Key("X-ExtraHeadersVsSubresources")))); 6942 testing::Key("X-ExtraHeadersVsSubresources"))));
6910 } 6943 }
6911 6944
6912 } // namespace content 6945 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698