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

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

Issue 2159093002: Clear provisional item on all server redirects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove conditional. Created 4 years, 5 months 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/FlagExpectations/isolate-extensions » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 3122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3133 shell()->web_contents()->GetController().GoBack(); 3133 shell()->web_contents()->GetController().GoBack();
3134 back_load_observer.Wait(); 3134 back_load_observer.Wait();
3135 } 3135 }
3136 EXPECT_EQ(redirect_dest_url, root->current_url()); 3136 EXPECT_EQ(redirect_dest_url, root->current_url());
3137 EXPECT_EQ(0U, root->child_count()); 3137 EXPECT_EQ(0U, root->child_count());
3138 EXPECT_EQ(0U, entry2->root_node()->children.size()); 3138 EXPECT_EQ(0U, entry2->root_node()->children.size());
3139 EXPECT_EQ(4, controller.GetEntryCount()); 3139 EXPECT_EQ(4, controller.GetEntryCount());
3140 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 3140 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
3141 } 3141 }
3142 3142
3143 // Similar to FrameNavigationEntry_BackWithRedirect but with same-origin frames.
3144 // (This wasn't working initially).
3145 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3146 FrameNavigationEntry_SameOriginBackWithRedirect) {
3147 // 1. Start on a page with an iframe.
3148 GURL initial_url(embedded_test_server()->GetURL(
3149 "/navigation_controller/page_with_data_iframe.html"));
3150 EXPECT_TRUE(NavigateToURL(shell(), initial_url));
3151 const NavigationControllerImpl& controller =
3152 static_cast<const NavigationControllerImpl&>(
3153 shell()->web_contents()->GetController());
3154 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
3155 ->GetFrameTree()
3156 ->root();
3157 EXPECT_EQ(initial_url, root->current_url());
3158 EXPECT_EQ(1U, root->child_count());
3159 NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry();
3160 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
3161 EXPECT_EQ(1U, entry1->root_node()->children.size());
3162
3163 // 2. Navigate the iframe to a page with a nested iframe.
3164 GURL frame_url(embedded_test_server()->GetURL(
3165 "/navigation_controller/page_with_data_iframe.html"));
3166 GURL data_url("data:text/html,Subframe");
3167 NavigateFrameToURL(root->child_at(0), frame_url);
3168 EXPECT_EQ(initial_url, root->current_url());
3169 EXPECT_EQ(frame_url, root->child_at(0)->current_url());
3170 EXPECT_EQ(data_url, root->child_at(0)->child_at(0)->current_url());
3171
3172 EXPECT_EQ(2, controller.GetEntryCount());
3173 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3174 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
3175 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
3176 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3177 NavigationEntryImpl::TreeNode* root_node = entry2->root_node();
3178 ASSERT_EQ(1U, root_node->children.size());
3179 EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url());
3180 EXPECT_EQ(data_url,
3181 root_node->children[0]->children[0]->frame_entry->url());
3182 }
3183
3184 // Cause the iframe to redirect when we come back later. It will go
3185 // same-origin to a page with an about:blank iframe.
3186 GURL frame_redirect_dest_url(embedded_test_server()->GetURL(
3187 "/navigation_controller/page_with_iframe.html"));
3188 GURL blank_url(url::kAboutBlankURL);
nasko 2016/07/20 18:16:39 nit: This isn't needed until 3225. It will be more
Charlie Reis 2016/07/20 19:35:08 Done.
3189 {
3190 TestNavigationObserver observer(shell()->web_contents());
3191 std::string script = "history.replaceState({}, '', '/server-redirect?" +
3192 frame_redirect_dest_url.spec() + "')";
3193 EXPECT_TRUE(ExecuteScript(root->child_at(0), script));
3194 observer.Wait();
3195 }
3196
3197 // We should not have lost subframe entries for the nested frame.
3198 EXPECT_EQ(2, controller.GetEntryCount());
3199 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3200 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3201 FrameNavigationEntry* nested_entry =
3202 entry2->GetFrameEntry(root->child_at(0)->child_at(0));
3203 EXPECT_TRUE(nested_entry);
3204 EXPECT_EQ(data_url, nested_entry->url());
3205 }
3206
3207 // 3. Navigate the main frame to a different page. When we come back, we'll
3208 // commit the main frame first and have no pending entry when navigating the
3209 // subframes.
3210 GURL url2(embedded_test_server()->GetURL(
3211 "/navigation_controller/simple_page_1.html"));
3212 EXPECT_TRUE(NavigateToURL(shell(), url2));
3213 EXPECT_EQ(3, controller.GetEntryCount());
3214 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
3215
3216 // 4. Go back. The first iframe should redirect to a cross-site page with a
nasko 2016/07/20 18:16:39 nit: same-origin page?
Charlie Reis 2016/07/20 19:35:08 Done.
3217 // different nested iframe.
3218 {
3219 TestNavigationObserver back_load_observer(shell()->web_contents());
3220 shell()->web_contents()->GetController().GoBack();
nasko 2016/07/20 18:16:39 nit: controller.GoBack()?
Charlie Reis 2016/07/20 19:35:08 Done.
3221 back_load_observer.Wait();
3222 }
3223 EXPECT_EQ(initial_url, root->current_url());
3224 EXPECT_EQ(frame_redirect_dest_url, root->child_at(0)->current_url());
3225 EXPECT_EQ(blank_url, root->child_at(0)->child_at(0)->current_url());
3226
3227 // Check the FrameNavigationEntries as well.
3228 EXPECT_EQ(3, controller.GetEntryCount());
3229 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3230 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3231 EXPECT_EQ(frame_redirect_dest_url,
3232 entry2->GetFrameEntry(root->child_at(0))->url());
3233 EXPECT_EQ(blank_url,
3234 entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url());
3235 }
3236
3237 // Now cause the main frame to redirect to a page with no frames when we come
3238 // back to it.
3239 GURL redirect_dest_url(embedded_test_server()->GetURL(
3240 "/navigation_controller/simple_page_2.html"));
3241 {
3242 TestNavigationObserver observer(shell()->web_contents());
3243 std::string script = "history.replaceState({}, '', '/server-redirect?" +
3244 redirect_dest_url.spec() + "')";
3245 EXPECT_TRUE(ExecuteScript(root, script));
3246 observer.Wait();
3247 }
3248
3249 // 5. Navigate the main frame to a different page.
3250 EXPECT_TRUE(NavigateToURL(shell(), url2));
3251 EXPECT_EQ(3, controller.GetEntryCount());
3252 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
3253
3254 // 6. Go back, causing the main frame to redirect to a page with no frames.
3255 // All child items should be gone.
3256 {
3257 TestNavigationObserver back_load_observer(shell()->web_contents());
3258 shell()->web_contents()->GetController().GoBack();
nasko 2016/07/20 18:16:39 nit: controller.GoBack()?
Charlie Reis 2016/07/20 19:35:08 Done.
3259 back_load_observer.Wait();
3260 }
3261 EXPECT_EQ(redirect_dest_url, root->current_url());
3262 EXPECT_EQ(0U, root->child_count());
3263 EXPECT_EQ(0U, entry2->root_node()->children.size());
3264 EXPECT_EQ(3, controller.GetEntryCount());
3265 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
3266 }
3267
3143 // Verify that subframes can be restored in a new NavigationController using the 3268 // Verify that subframes can be restored in a new NavigationController using the
3144 // PageState of an existing NavigationEntry. 3269 // PageState of an existing NavigationEntry.
3145 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 3270 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
3146 FrameNavigationEntry_RestoreViaPageState) { 3271 FrameNavigationEntry_RestoreViaPageState) {
3147 // 1. Start on a page with a data URL iframe. 3272 // 1. Start on a page with a data URL iframe.
3148 GURL main_url_a(embedded_test_server()->GetURL( 3273 GURL main_url_a(embedded_test_server()->GetURL(
3149 "a.com", "/navigation_controller/page_with_data_iframe.html")); 3274 "a.com", "/navigation_controller/page_with_data_iframe.html"));
3150 GURL data_url("data:text/html,Subframe"); 3275 GURL data_url("data:text/html,Subframe");
3151 NavigateToURL(shell(), main_url_a); 3276 NavigateToURL(shell(), main_url_a);
3152 const NavigationControllerImpl& controller = 3277 const NavigationControllerImpl& controller =
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after
5205 std::string body; 5330 std::string body;
5206 EXPECT_TRUE(ExecuteScriptAndExtractString( 5331 EXPECT_TRUE(ExecuteScriptAndExtractString(
5207 shell()->web_contents(), 5332 shell()->web_contents(),
5208 "window.domAutomationController.send(" 5333 "window.domAutomationController.send("
5209 "document.getElementsByTagName('pre')[0].innerText);", 5334 "document.getElementsByTagName('pre')[0].innerText);",
5210 &body)); 5335 &body));
5211 EXPECT_EQ("text=value\n", body); 5336 EXPECT_EQ("text=value\n", body);
5212 } 5337 }
5213 5338
5214 } // namespace content 5339 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/FlagExpectations/isolate-extensions » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698