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

Unified Diff: chrome/browser/extensions/isolated_app_browsertest.cc

Issue 11193051: To fix the cross-site post submission bug. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android API, Helper Function and Include_rules Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/isolated_app_browsertest.cc
diff --git a/chrome/browser/extensions/isolated_app_browsertest.cc b/chrome/browser/extensions/isolated_app_browsertest.cc
index 5962f77022d4a27a1eafe82a1967816c55d72f96..7a78dd32c45bf07b6bc8039aba67821b6a8997c9 100644
--- a/chrome/browser/extensions/isolated_app_browsertest.cc
+++ b/chrome/browser/extensions/isolated_app_browsertest.cc
@@ -106,6 +106,72 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossProcessClientRedirect) {
EXPECT_FALSE(chrome::CanGoBack(browser()));
}
+IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossSiteDataPost) {
+ host_resolver()->AddRule("*", "127.0.0.1");
+ ASSERT_TRUE(test_server()->Start());
+
+ ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1")));
+
+ GURL base_url = test_server()->GetURL("files/extensions/isolated_apps/");
+ GURL::Replacements replace_host;
+ std::string host_str("localhost"); // Must stay in scope with replace_host.
+ replace_host.SetHostStr(host_str);
+ base_url = base_url.ReplaceComponents(replace_host);
+ std::string resolve_url ="app1/main.html";
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), base_url.Resolve(resolve_url),
+ CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ WebContents* tab0 = chrome::GetWebContentsAt(browser(), 0);
+ base::ProcessHandle old_process = tab0->GetRenderProcessHost()->GetHandle();
+
+ std::string data = "post \0\ndata";
+ GURL echo_url = test_server()->GetURL("echoall");
+ std::string jsSubmit = "(function submitform() {";
+ jsSubmit.append("var form = document.createElement(\"form\");");
+ jsSubmit.append("form.setAttribute(\"method\", \"POST\");");
+ jsSubmit.append("form.setAttribute(\"action\", \"");
+ jsSubmit.append(echo_url.spec().c_str());
+ jsSubmit.append("\");var hiddenField = document.createElement(\"input\");");
+ jsSubmit.append("hiddenField.setAttribute(\"type\", \"hidden\");");
+ jsSubmit.append("hiddenField.setAttribute(\"name\", \"data\");");
+ jsSubmit.append("hiddenField.setAttribute(\"value\", \"" + data + "\");");
+ jsSubmit.append("form.appendChild(hiddenField);");
+ jsSubmit.append("document.body.appendChild(form);");
+ jsSubmit.append("form.submit();");
+ jsSubmit.append("})()");
+
+ content::WindowedNotificationObserver tab_loaded_observer(
+ content::NOTIFICATION_LOAD_STOP,
+ content::Source<NavigationController>(&tab0->GetController()));
+ ASSERT_TRUE(ExecuteJavaScript(
+ chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
+ L"",
+ ASCIIToWide(jsSubmit)));
+ tab_loaded_observer.Wait();
+
+ // Make sure we are in the new process.
+ WebContents* tab1 = chrome::GetWebContentsAt(browser(), 0);
+ EXPECT_NE(old_process,
+ tab1->GetRenderProcessHost()->GetHandle());
+
+ // The response page from TestServer displayed the POST data
+ // within the <pre> tag. We inject script to extract the POST data
+ // from this page and compare with the POST data we submitted.
+ std::string getResult = "window.domAutomationController.send(";
+ getResult.append("document.getElementsByTagName('pre')[0].firstChild.data);");
+ std::string value;
+ ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
+ chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
+ L"",
+ ASCIIToWide(getResult),
+ &value));
+ EXPECT_EQ("data=" + data + "\n", value);
+}
+
+IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossSiteFilePost) {
+}
+
// Tests that cookies set within an isolated app are not visible to normal
// pages or other apps.
//
« no previous file with comments | « no previous file | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698