Chromium Code Reviews| 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 266d5a48593f87c799412bcaf06fcd462067f444..3fce1e909871733fd793c27abcbe4a71c0882080 100644 |
| --- a/chrome/browser/extensions/isolated_app_browsertest.cc |
| +++ b/chrome/browser/extensions/isolated_app_browsertest.cc |
| @@ -75,6 +75,67 @@ class IsolatedAppTest : public ExtensionBrowserTest { |
| } // namespace |
| +IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossSiteDataPost) { |
|
irobert
2012/11/09 19:07:57
This Test is for the DataType Post Submission.
I a
|
| + 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); |
| + pid_t 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("})()"); |
| + |
| + ASSERT_TRUE(ExecuteJavaScript( |
| + chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), |
| + L"", |
| + ASCIIToWide(jsSubmit))); |
| + |
| + const string16 expected_title = ASCIIToUTF16("echoall"); |
| + content::TitleWatcher title_watcher(tab0, expected_title); |
| + string16 actual_title = title_watcher.WaitAndGetTitle(); |
| + EXPECT_EQ(expected_title, actual_title); |
| + |
| + // Make Sure we are in the new process |
| + WebContents* tab1 = chrome::GetWebContentsAt(browser(), 0); |
| + EXPECT_NE(old_process, |
| + tab1->GetRenderProcessHost()->GetHandle()); |
| + |
| + 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); |
| +} |
| + |
| // Tests that cookies set within an isolated app are not visible to normal |
| // pages or other apps. |
| // |