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

Unified Diff: content/browser/renderer_host/resource_dispatcher_host_uitest.cc

Issue 7748022: Protect sensistive chrome: and chrome-extension: schemes as not being able to be manipulated by b... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/resource_dispatcher_host_uitest.cc
===================================================================
--- content/browser/renderer_host/resource_dispatcher_host_uitest.cc (revision 98255)
+++ content/browser/renderer_host/resource_dispatcher_host_uitest.cc (working copy)
@@ -9,6 +9,7 @@
#include "base/file_path.h"
#include "base/path_service.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "base/test/test_timeouts.h"
#include "chrome/test/automation/automation_proxy.h"
#include "chrome/test/automation/browser_proxy.h"
@@ -356,15 +357,22 @@
// the ResourceDispatcherHost would think that such navigations were
// cross-site, because we didn't clean up from the previous request. Since
// TabContents was in the NORMAL state, it would ignore the attempt to run
- // the onunload handler, and the navigation would fail.
- // (Test by redirecting to javascript:window.location='someURL'.)
+ // the onunload handler, and the navigation would fail. We would like to
+ // test by redirecting to javascript:window.location='someURL', but
+ // javascript: URLs are prohibited by policy from interacting with sensitive
+ // chrome pages of which the error page is one. Instead, use automation to
+ // kick off the navigation, and wait to see that the tab loads.
Charlie Reis 2011/08/30 16:55:59 This ExecuteAndExtractBool approach looks great.
+ bool success;
GURL test_url(test_server.GetURL("files/title2.html"));
- std::string redirect_url = "javascript:window.location='" +
- test_url.possibly_invalid_spec() + "'";
- ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
- tab->NavigateToURL(GURL(redirect_url)));
- EXPECT_TRUE(tab->GetTabTitle(&tab_title));
- EXPECT_EQ(L"Title Of Awesomeness", tab_title);
+ std::string redirect_script = "window.location='" +
+ test_url.possibly_invalid_spec() + "';" +
+ "window.domAutomationController.send(true);";
+ EXPECT_TRUE(tab->ExecuteAndExtractBool(
+ L"", ASCIIToWide(redirect_script), &success));
+ EXPECT_TRUE(WaitUntilJavaScriptCondition(
Charlie Reis 2011/08/30 16:55:59 I'm a little concerned about this wait being flaky
+ tab.get(), L"", L"window.domAutomationController.send("
+ L"document.title == 'Title Of Awesomeness')",
+ 20000));
}
TEST_F(ResourceDispatcherTest, CrossOriginRedirectBlocked) {
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698