OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/automation/automation_util.h" | 6 #include "chrome/browser/automation/automation_util.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 99 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
100 | 100 |
101 // Go back twice. | 101 // Go back twice. |
102 // If bug fixed, we cannot go back anymore. | 102 // If bug fixed, we cannot go back anymore. |
103 // If not fixed, we will redirect back to app2 and can go back again. | 103 // If not fixed, we will redirect back to app2 and can go back again. |
104 chrome::GoBack(browser(), CURRENT_TAB); | 104 chrome::GoBack(browser(), CURRENT_TAB); |
105 chrome::GoBack(browser(), CURRENT_TAB); | 105 chrome::GoBack(browser(), CURRENT_TAB); |
106 EXPECT_FALSE(chrome::CanGoBack(browser())); | 106 EXPECT_FALSE(chrome::CanGoBack(browser())); |
107 } | 107 } |
108 | 108 |
109 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossSiteDataPost) { | |
110 host_resolver()->AddRule("*", "127.0.0.1"); | |
111 ASSERT_TRUE(test_server()->Start()); | |
112 | |
113 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); | |
114 | |
115 GURL base_url = test_server()->GetURL("files/extensions/isolated_apps/"); | |
116 GURL::Replacements replace_host; | |
117 std::string host_str("localhost"); // Must stay in scope with replace_host. | |
118 replace_host.SetHostStr(host_str); | |
119 base_url = base_url.ReplaceComponents(replace_host); | |
120 std::string resolve_url ="app1/main.html"; | |
121 ui_test_utils::NavigateToURLWithDisposition( | |
122 browser(), base_url.Resolve(resolve_url), | |
123 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
124 | |
125 WebContents* tab0 = chrome::GetWebContentsAt(browser(), 0); | |
126 pid_t old_process = tab0->GetRenderProcessHost()->GetHandle(); | |
127 | |
128 std::string data = "post \0\ndata"; | |
129 GURL echo_url = test_server()->GetURL("echoall"); | |
130 std::string jsSubmit = "(function submitform() {"; | |
131 jsSubmit.append("var form = document.createElement(\"form\");"); | |
132 jsSubmit.append("form.setAttribute(\"method\", \"POST\");"); | |
133 jsSubmit.append("form.setAttribute(\"action\", \""); | |
134 jsSubmit.append(echo_url.spec().c_str()); | |
135 jsSubmit.append("\");var hiddenField = document.createElement(\"input\");"); | |
136 jsSubmit.append("hiddenField.setAttribute(\"type\", \"hidden\");"); | |
137 jsSubmit.append("hiddenField.setAttribute(\"name\", \"data\");"); | |
138 jsSubmit.append("hiddenField.setAttribute(\"value\", \"" + data + "\");"); | |
139 jsSubmit.append("form.appendChild(hiddenField);"); | |
140 jsSubmit.append("document.body.appendChild(form);"); | |
141 jsSubmit.append("form.submit();"); | |
142 jsSubmit.append("})()"); | |
143 | |
144 ASSERT_TRUE(ExecuteJavaScript( | |
145 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), | |
146 L"", | |
147 ASCIIToWide(jsSubmit))); | |
148 | |
149 const string16 expected_title = ASCIIToUTF16("echoall"); | |
150 content::TitleWatcher title_watcher(tab0, expected_title); | |
151 string16 actual_title = title_watcher.WaitAndGetTitle(); | |
Charlie Reis
2012/11/20 05:46:03
Can we avoid relying on title changes? Might be b
irobert
2012/11/22 01:37:00
Done.
| |
152 EXPECT_EQ(expected_title, actual_title); | |
153 | |
154 // Make Sure we are in the new process | |
Charlie Reis
2012/11/20 05:46:03
nit: sure
nit: end with period.
irobert
2012/11/22 01:37:00
Done.
| |
155 WebContents* tab1 = chrome::GetWebContentsAt(browser(), 0); | |
156 EXPECT_NE(old_process, | |
157 tab1->GetRenderProcessHost()->GetHandle()); | |
158 | |
159 std::string getResult = "window.domAutomationController.send("; | |
Charlie Reis
2012/11/20 05:46:03
Maybe add a comment to this block about how it's r
irobert
2012/11/22 01:37:00
Done.
| |
160 getResult.append("document.getElementsByTagName('pre')[0].firstChild.data);"); | |
161 std::string value; | |
162 ASSERT_TRUE(ExecuteJavaScriptAndExtractString( | |
163 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), | |
164 L"", | |
165 ASCIIToWide(getResult), | |
166 &value)); | |
167 EXPECT_EQ("data="+data+"\n", value); | |
Charlie Reis
2012/11/20 05:46:03
nit: Spaces around the +'s
irobert
2012/11/22 01:37:00
Done.
| |
168 } | |
169 | |
170 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossSiteFilePost) { | |
171 } | |
172 | |
109 // Tests that cookies set within an isolated app are not visible to normal | 173 // Tests that cookies set within an isolated app are not visible to normal |
110 // pages or other apps. | 174 // pages or other apps. |
111 // | 175 // |
112 // TODO(ajwong): Also test what happens if an app spans multiple sites in its | 176 // TODO(ajwong): Also test what happens if an app spans multiple sites in its |
113 // extent. These origins should also be isolated, but still have origin-based | 177 // extent. These origins should also be isolated, but still have origin-based |
114 // separation as you would expect. | 178 // separation as you would expect. |
115 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) { | 179 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) { |
116 host_resolver()->AddRule("*", "127.0.0.1"); | 180 host_resolver()->AddRule("*", "127.0.0.1"); |
117 ASSERT_TRUE(test_server()->Start()); | 181 ASSERT_TRUE(test_server()->Start()); |
118 | 182 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 EXPECT_EQ("ss_app2", result); | 531 EXPECT_EQ("ss_app2", result); |
468 | 532 |
469 ui_test_utils::NavigateToURLWithDisposition( | 533 ui_test_utils::NavigateToURLWithDisposition( |
470 browser(), base_url.Resolve("non_app/main.html"), | 534 browser(), base_url.Resolve("non_app/main.html"), |
471 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 535 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
472 ASSERT_TRUE(ExecuteJavaScriptAndExtractString( | 536 ASSERT_TRUE(ExecuteJavaScriptAndExtractString( |
473 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), | 537 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), |
474 L"", kRetrieveSessionStorage.c_str(), &result)); | 538 L"", kRetrieveSessionStorage.c_str(), &result)); |
475 EXPECT_EQ("ss_normal", result); | 539 EXPECT_EQ("ss_normal", result); |
476 } | 540 } |
OLD | NEW |