diff options
author | irobert@chromium.org <irobert@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-13 19:15:46 +0000 |
---|---|---|
committer | irobert@chromium.org <irobert@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-13 19:15:46 +0000 |
commit | b4c096942b68e1508d9a31f9ba5f1a0b672e4cd3 (patch) | |
tree | f6cc6f33414be2ed4d0d27d97eb7d3c2cae3bbc4 /chrome/browser/extensions | |
parent | 721048dd38524cfd1510bb0c2323bc484ab39ac0 (diff) | |
download | chromium_src-b4c096942b68e1508d9a31f9ba5f1a0b672e4cd3.zip chromium_src-b4c096942b68e1508d9a31f9ba5f1a0b672e4cd3.tar.gz chromium_src-b4c096942b68e1508d9a31f9ba5f1a0b672e4cd3.tar.bz2 |
The new cross-process client-redirect logic is replacing the current navigation entry, which is correct if the redirect happens while the page is still loading but incorrect if the page has already finished loading. For each cross-site navigation, we further check whether the redirection happens before or after page finishes loading.
BUG=164419
Review URL: https://chromiumcodereview.appspot.com/11446070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/isolated_app_browsertest.cc | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/chrome/browser/extensions/isolated_app_browsertest.cc b/chrome/browser/extensions/isolated_app_browsertest.cc index 0e80417..de74087 100644 --- a/chrome/browser/extensions/isolated_app_browsertest.cc +++ b/chrome/browser/extensions/isolated_app_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/automation/automation_util.h" #include "chrome/browser/extensions/extension_apitest.h" @@ -90,7 +91,7 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossProcessClientRedirect) { browser(), base_url.Resolve("app1/main.html"), CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - // redirect to app2. + // Redirect to app2. GURL redirect_url(test_server()->GetURL( "client-redirect?files/extensions/isolated_apps/app2/main.html")); ui_test_utils::NavigateToURLWithDisposition( @@ -100,7 +101,37 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossProcessClientRedirect) { // Go back twice. // If bug fixed, we cannot go back anymore. // If not fixed, we will redirect back to app2 and can go back again. + EXPECT_TRUE(chrome::CanGoBack(browser())); chrome::GoBack(browser(), CURRENT_TAB); + EXPECT_TRUE(chrome::CanGoBack(browser())); + chrome::GoBack(browser(), CURRENT_TAB); + EXPECT_FALSE(chrome::CanGoBack(browser())); + + // We also need to test script-initialized navigation (document.location.href) + // happened after page finishes loading. This one will also triggered the + // willPerformClientRedirect hook in RenderViewImpl but should not replace + // the previous history entry. + ui_test_utils::NavigateToURLWithDisposition( + browser(), base_url.Resolve("non_app/main.html"), + NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + + WebContents* tab0 = chrome::GetWebContentsAt(browser(), 1); + RenderViewHost* rvh = tab0->GetRenderViewHost(); + + // Using JavaScript to navigate to app2 page, + // after the non_app page has finished loading. + content::WindowedNotificationObserver observer1( + content::NOTIFICATION_LOAD_STOP, + content::Source<NavigationController>( + &chrome::GetActiveWebContents(browser())->GetController())); + std::string script = base::StringPrintf( + "document.location.href=\"%s\";", + base_url.Resolve("app2/main.html").spec().c_str()); + EXPECT_TRUE(ExecuteJavaScript(rvh, L"", ASCIIToWide(script))); + observer1.Wait(); + + // This kind of navigation should not replace previous navigation entry. + EXPECT_TRUE(chrome::CanGoBack(browser())); chrome::GoBack(browser(), CURRENT_TAB); EXPECT_FALSE(chrome::CanGoBack(browser())); } |