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/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/automation/automation_util.h" | 7 #include "chrome/browser/automation/automation_util.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_commands.h" | 13 #include "chrome/browser/ui/browser_commands.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/site_instance.h" | 20 #include "content/public/browser/site_instance.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
23 #include "net/dns/mock_host_resolver.h" | 23 #include "net/dns/mock_host_resolver.h" |
| 24 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 25 #include "net/test/embedded_test_server/http_response.h" |
| 26 #include "net/test/embedded_test_server/http_request.h" |
24 | 27 |
25 using content::ExecuteScript; | 28 using content::ExecuteScript; |
26 using content::ExecuteScriptAndExtractString; | 29 using content::ExecuteScriptAndExtractString; |
27 using content::NavigationController; | 30 using content::NavigationController; |
28 using content::WebContents; | 31 using content::WebContents; |
29 using content::RenderViewHost; | 32 using content::RenderViewHost; |
30 | 33 |
31 namespace { | 34 namespace { |
32 | 35 |
33 std::string WrapForJavascriptAndExtract(const char* javascript_expression) { | 36 std::string WrapForJavascriptAndExtract(const char* javascript_expression) { |
34 return std::string("window.domAutomationController.send(") + | 37 return std::string("window.domAutomationController.send(") + |
35 javascript_expression + ")"; | 38 javascript_expression + ")"; |
36 } | 39 } |
37 | 40 |
| 41 scoped_ptr<net::test_server::HttpResponse> HandleExpectAndSetCookieRequest( |
| 42 const net::test_server::EmbeddedTestServer* test_server, |
| 43 const net::test_server::HttpRequest& request) { |
| 44 if (!StartsWithASCII(request.relative_url, "/expect-and-set-cookie?", true)) |
| 45 return scoped_ptr<net::test_server::HttpResponse>(NULL); |
| 46 |
| 47 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 48 new net::test_server::BasicHttpResponse); |
| 49 http_response->set_code(net::HTTP_OK); |
| 50 |
| 51 std::string request_cookies; |
| 52 std::map<std::string, std::string>::const_iterator it = |
| 53 request.headers.find("Cookie"); |
| 54 if (it != request.headers.end()) |
| 55 request_cookies = it->second; |
| 56 |
| 57 size_t query_string_pos = request.relative_url.find('?'); |
| 58 std::string query_string = |
| 59 request.relative_url.substr(query_string_pos + 1); |
| 60 url_parse::Component query(0, query_string.length()), key_pos, value_pos; |
| 61 bool expectations_satisfied = true; |
| 62 std::vector<std::string> cookies_to_set; |
| 63 while (url_parse::ExtractQueryKeyValue( |
| 64 query_string.c_str(), &query, &key_pos, &value_pos)) { |
| 65 std::string escaped_key(query_string.substr(key_pos.begin, key_pos.len)); |
| 66 std::string escaped_value( |
| 67 query_string.substr(value_pos.begin, value_pos.len)); |
| 68 |
| 69 std::string key = |
| 70 net::UnescapeURLComponent(escaped_key, |
| 71 net::UnescapeRule::NORMAL | |
| 72 net::UnescapeRule::SPACES | |
| 73 net::UnescapeRule::URL_SPECIAL_CHARS); |
| 74 |
| 75 std::string value = |
| 76 net::UnescapeURLComponent(escaped_value, |
| 77 net::UnescapeRule::NORMAL | |
| 78 net::UnescapeRule::SPACES | |
| 79 net::UnescapeRule::URL_SPECIAL_CHARS); |
| 80 |
| 81 if (key == "expect") { |
| 82 if (request_cookies.find(value) == std::string::npos) |
| 83 expectations_satisfied = false; |
| 84 } else if (key == "set") { |
| 85 cookies_to_set.push_back(value); |
| 86 } else { |
| 87 return scoped_ptr<net::test_server::HttpResponse>(NULL); |
| 88 } |
| 89 } |
| 90 |
| 91 if (expectations_satisfied) { |
| 92 for (size_t i = 0; i < cookies_to_set.size(); i++) |
| 93 http_response->AddCustomHeader("Set-Cookie", cookies_to_set[i]); |
| 94 } |
| 95 |
| 96 return http_response.PassAs<net::test_server::HttpResponse>(); |
| 97 } |
| 98 |
38 class IsolatedAppTest : public ExtensionBrowserTest { | 99 class IsolatedAppTest : public ExtensionBrowserTest { |
39 public: | 100 public: |
40 // Returns whether the given tab's current URL has the given cookie. | 101 // Returns whether the given tab's current URL has the given cookie. |
41 bool WARN_UNUSED_RESULT HasCookie(WebContents* contents, std::string cookie) { | 102 bool WARN_UNUSED_RESULT HasCookie(WebContents* contents, std::string cookie) { |
42 int value_size; | 103 int value_size; |
43 std::string actual_cookie; | 104 std::string actual_cookie; |
44 automation_util::GetCookies(contents->GetURL(), contents, &value_size, | 105 automation_util::GetCookies(contents->GetURL(), contents, &value_size, |
45 &actual_cookie); | 106 &actual_cookie); |
46 return actual_cookie.find(cookie) != std::string::npos; | 107 return actual_cookie.find(cookie) != std::string::npos; |
47 } | 108 } |
(...skipping 21 matching lines...) Expand all Loading... |
69 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 130 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
70 ExtensionBrowserTest::SetUpCommandLine(command_line); | 131 ExtensionBrowserTest::SetUpCommandLine(command_line); |
71 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 132 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
72 } | 133 } |
73 }; | 134 }; |
74 | 135 |
75 } // namespace | 136 } // namespace |
76 | 137 |
77 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossProcessClientRedirect) { | 138 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CrossProcessClientRedirect) { |
78 host_resolver()->AddRule("*", "127.0.0.1"); | 139 host_resolver()->AddRule("*", "127.0.0.1"); |
79 ASSERT_TRUE(test_server()->Start()); | 140 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
80 | 141 |
81 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); | 142 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); |
82 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2"))); | 143 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2"))); |
83 | 144 |
84 GURL base_url = test_server()->GetURL("files/extensions/isolated_apps/"); | 145 GURL base_url = embedded_test_server()->GetURL("/extensions/isolated_apps/"); |
85 GURL::Replacements replace_host; | 146 GURL::Replacements replace_host; |
86 std::string host_str("localhost"); // Must stay in scope with replace_host. | 147 std::string host_str("localhost"); // Must stay in scope with replace_host. |
87 replace_host.SetHostStr(host_str); | 148 replace_host.SetHostStr(host_str); |
88 base_url = base_url.ReplaceComponents(replace_host); | 149 base_url = base_url.ReplaceComponents(replace_host); |
89 ui_test_utils::NavigateToURLWithDisposition( | 150 ui_test_utils::NavigateToURLWithDisposition( |
90 browser(), base_url.Resolve("app1/main.html"), | 151 browser(), base_url.Resolve("app1/main.html"), |
91 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 152 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
92 | 153 |
93 // Redirect to app2. | 154 // Redirect to app2. |
94 GURL redirect_url(test_server()->GetURL( | 155 GURL redirect_url(embedded_test_server()->GetURL( |
95 "client-redirect?files/extensions/isolated_apps/app2/main.html")); | 156 "/extensions/isolated_apps/app2/redirect.html")); |
96 ui_test_utils::NavigateToURLWithDisposition( | 157 ui_test_utils::NavigateToURLWithDisposition( |
97 browser(), redirect_url, | 158 browser(), redirect_url, |
98 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 159 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
99 | 160 |
100 // Go back twice. | 161 // Go back twice. |
101 // If bug fixed, we cannot go back anymore. | 162 // If bug fixed, we cannot go back anymore. |
102 // If not fixed, we will redirect back to app2 and can go back again. | 163 // If not fixed, we will redirect back to app2 and can go back again. |
103 EXPECT_TRUE(chrome::CanGoBack(browser())); | 164 EXPECT_TRUE(chrome::CanGoBack(browser())); |
104 chrome::GoBack(browser(), CURRENT_TAB); | 165 chrome::GoBack(browser(), CURRENT_TAB); |
105 EXPECT_TRUE(chrome::CanGoBack(browser())); | 166 EXPECT_TRUE(chrome::CanGoBack(browser())); |
(...skipping 30 matching lines...) Expand all Loading... |
136 } | 197 } |
137 | 198 |
138 // Tests that cookies set within an isolated app are not visible to normal | 199 // Tests that cookies set within an isolated app are not visible to normal |
139 // pages or other apps. | 200 // pages or other apps. |
140 // | 201 // |
141 // TODO(ajwong): Also test what happens if an app spans multiple sites in its | 202 // TODO(ajwong): Also test what happens if an app spans multiple sites in its |
142 // extent. These origins should also be isolated, but still have origin-based | 203 // extent. These origins should also be isolated, but still have origin-based |
143 // separation as you would expect. | 204 // separation as you would expect. |
144 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) { | 205 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) { |
145 host_resolver()->AddRule("*", "127.0.0.1"); | 206 host_resolver()->AddRule("*", "127.0.0.1"); |
146 ASSERT_TRUE(test_server()->Start()); | 207 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
147 | 208 |
148 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); | 209 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); |
149 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2"))); | 210 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2"))); |
150 | 211 |
151 // The app under test acts on URLs whose host is "localhost", | 212 // The app under test acts on URLs whose host is "localhost", |
152 // so the URLs we navigate to must have host "localhost". | 213 // so the URLs we navigate to must have host "localhost". |
153 GURL base_url = test_server()->GetURL("files/extensions/isolated_apps/"); | 214 GURL base_url = embedded_test_server()->GetURL("/extensions/isolated_apps/"); |
154 GURL::Replacements replace_host; | 215 GURL::Replacements replace_host; |
155 std::string host_str("localhost"); // Must stay in scope with replace_host. | 216 std::string host_str("localhost"); // Must stay in scope with replace_host. |
156 replace_host.SetHostStr(host_str); | 217 replace_host.SetHostStr(host_str); |
157 base_url = base_url.ReplaceComponents(replace_host); | 218 base_url = base_url.ReplaceComponents(replace_host); |
158 | 219 |
159 ui_test_utils::NavigateToURLWithDisposition( | 220 ui_test_utils::NavigateToURLWithDisposition( |
160 browser(), base_url.Resolve("app1/main.html"), | 221 browser(), base_url.Resolve("app1/main.html"), |
161 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 222 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
162 ui_test_utils::NavigateToURLWithDisposition( | 223 ui_test_utils::NavigateToURLWithDisposition( |
163 browser(), base_url.Resolve("app2/main.html"), | 224 browser(), base_url.Resolve("app2/main.html"), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 EXPECT_TRUE(HasCookie(tab0, "app1=3")); | 296 EXPECT_TRUE(HasCookie(tab0, "app1=3")); |
236 EXPECT_FALSE(HasCookie(tab0, "app2")); | 297 EXPECT_FALSE(HasCookie(tab0, "app2")); |
237 EXPECT_FALSE(HasCookie(tab0, "normalPage")); | 298 EXPECT_FALSE(HasCookie(tab0, "normalPage")); |
238 | 299 |
239 } | 300 } |
240 | 301 |
241 // This test is disabled due to being flaky. http://crbug.com/145588 | 302 // This test is disabled due to being flaky. http://crbug.com/145588 |
242 // Ensure that cookies are not isolated if the isolated apps are not installed. | 303 // Ensure that cookies are not isolated if the isolated apps are not installed. |
243 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_NoCookieIsolationWithoutApp) { | 304 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_NoCookieIsolationWithoutApp) { |
244 host_resolver()->AddRule("*", "127.0.0.1"); | 305 host_resolver()->AddRule("*", "127.0.0.1"); |
245 ASSERT_TRUE(test_server()->Start()); | 306 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
246 | 307 |
247 // The app under test acts on URLs whose host is "localhost", | 308 // The app under test acts on URLs whose host is "localhost", |
248 // so the URLs we navigate to must have host "localhost". | 309 // so the URLs we navigate to must have host "localhost". |
249 GURL base_url = test_server()->GetURL("files/extensions/isolated_apps/"); | 310 GURL base_url = embedded_test_server()->GetURL("/extensions/isolated_apps/"); |
250 GURL::Replacements replace_host; | 311 GURL::Replacements replace_host; |
251 std::string host_str("localhost"); // Must stay in scope with replace_host. | 312 std::string host_str("localhost"); // Must stay in scope with replace_host. |
252 replace_host.SetHostStr(host_str); | 313 replace_host.SetHostStr(host_str); |
253 base_url = base_url.ReplaceComponents(replace_host); | 314 base_url = base_url.ReplaceComponents(replace_host); |
254 | 315 |
255 ui_test_utils::NavigateToURLWithDisposition( | 316 ui_test_utils::NavigateToURLWithDisposition( |
256 browser(), base_url.Resolve("app1/main.html"), | 317 browser(), base_url.Resolve("app1/main.html"), |
257 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 318 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
258 ui_test_utils::NavigateToURLWithDisposition( | 319 ui_test_utils::NavigateToURLWithDisposition( |
259 browser(), base_url.Resolve("app2/main.html"), | 320 browser(), base_url.Resolve("app2/main.html"), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // http://crbug.com/174926 | 375 // http://crbug.com/174926 |
315 #if defined(OS_WIN) && !defined(NDEBUG) | 376 #if defined(OS_WIN) && !defined(NDEBUG) |
316 #define MAYBE_SubresourceCookieIsolation DISABLED_SubresourceCookieIsolation | 377 #define MAYBE_SubresourceCookieIsolation DISABLED_SubresourceCookieIsolation |
317 #else | 378 #else |
318 #define MAYBE_SubresourceCookieIsolation SubresourceCookieIsolation | 379 #define MAYBE_SubresourceCookieIsolation SubresourceCookieIsolation |
319 #endif // defined(OS_WIN) && !defined(NDEBUG) | 380 #endif // defined(OS_WIN) && !defined(NDEBUG) |
320 | 381 |
321 // Tests that subresource and media requests use the app's cookie store. | 382 // Tests that subresource and media requests use the app's cookie store. |
322 // See http://crbug.com/141172. | 383 // See http://crbug.com/141172. |
323 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, MAYBE_SubresourceCookieIsolation) { | 384 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, MAYBE_SubresourceCookieIsolation) { |
| 385 embedded_test_server()->RegisterRequestHandler( |
| 386 base::Bind(&HandleExpectAndSetCookieRequest, embedded_test_server())); |
| 387 |
324 host_resolver()->AddRule("*", "127.0.0.1"); | 388 host_resolver()->AddRule("*", "127.0.0.1"); |
325 ASSERT_TRUE(test_server()->Start()); | 389 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
326 | 390 |
327 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); | 391 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); |
328 | 392 |
329 // The app under test acts on URLs whose host is "localhost", | 393 // The app under test acts on URLs whose host is "localhost", |
330 // so the URLs we navigate to must have host "localhost". | 394 // so the URLs we navigate to must have host "localhost". |
331 GURL root_url = test_server()->GetURL(std::string()); | 395 GURL root_url = embedded_test_server()->GetURL("/"); |
332 GURL base_url = test_server()->GetURL("files/extensions/isolated_apps/"); | 396 GURL base_url = embedded_test_server()->GetURL("/extensions/isolated_apps/"); |
333 GURL::Replacements replace_host; | 397 GURL::Replacements replace_host; |
334 std::string host_str("localhost"); // Must stay in scope with replace_host. | 398 std::string host_str("localhost"); // Must stay in scope with replace_host. |
335 replace_host.SetHostStr(host_str); | 399 replace_host.SetHostStr(host_str); |
336 root_url = root_url.ReplaceComponents(replace_host); | 400 root_url = root_url.ReplaceComponents(replace_host); |
337 base_url = base_url.ReplaceComponents(replace_host); | 401 base_url = base_url.ReplaceComponents(replace_host); |
338 | 402 |
339 // First set cookies inside and outside the app. | 403 // First set cookies inside and outside the app. |
340 ui_test_utils::NavigateToURLWithDisposition( | 404 ui_test_utils::NavigateToURLWithDisposition( |
341 browser(), root_url.Resolve("set-cookie?nonApp=1"), | 405 browser(), root_url.Resolve("expect-and-set-cookie?set=nonApp%3d1"), |
342 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 406 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
343 WebContents* tab0 = browser()->tab_strip_model()->GetWebContentsAt(0); | 407 WebContents* tab0 = browser()->tab_strip_model()->GetWebContentsAt(0); |
344 ASSERT_FALSE(GetInstalledApp(tab0)); | 408 ASSERT_FALSE(GetInstalledApp(tab0)); |
345 ui_test_utils::NavigateToURLWithDisposition( | 409 ui_test_utils::NavigateToURLWithDisposition( |
346 browser(), base_url.Resolve("app1/main.html"), | 410 browser(), base_url.Resolve("app1/main.html"), |
347 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 411 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
348 WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(1); | 412 WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(1); |
349 ASSERT_TRUE(GetInstalledApp(tab1)); | 413 ASSERT_TRUE(GetInstalledApp(tab1)); |
350 | 414 |
351 // Check that each tab sees its own cookie. | 415 // Check that each tab sees its own cookie. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 #define MAYBE_IsolatedAppProcessModel DISABLED_IsolatedAppProcessModel | 454 #define MAYBE_IsolatedAppProcessModel DISABLED_IsolatedAppProcessModel |
391 #else | 455 #else |
392 #define MAYBE_IsolatedAppProcessModel IsolatedAppProcessModel | 456 #define MAYBE_IsolatedAppProcessModel IsolatedAppProcessModel |
393 #endif // defined(OS_WIN) | 457 #endif // defined(OS_WIN) |
394 | 458 |
395 // Tests that isolated apps processes do not render top-level non-app pages. | 459 // Tests that isolated apps processes do not render top-level non-app pages. |
396 // This is true even in the case of the OAuth workaround for hosted apps, | 460 // This is true even in the case of the OAuth workaround for hosted apps, |
397 // where non-app popups may be kept in the hosted app process. | 461 // where non-app popups may be kept in the hosted app process. |
398 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, MAYBE_IsolatedAppProcessModel) { | 462 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, MAYBE_IsolatedAppProcessModel) { |
399 host_resolver()->AddRule("*", "127.0.0.1"); | 463 host_resolver()->AddRule("*", "127.0.0.1"); |
400 ASSERT_TRUE(test_server()->Start()); | 464 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
401 | 465 |
402 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); | 466 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); |
403 | 467 |
404 // The app under test acts on URLs whose host is "localhost", | 468 // The app under test acts on URLs whose host is "localhost", |
405 // so the URLs we navigate to must have host "localhost". | 469 // so the URLs we navigate to must have host "localhost". |
406 GURL base_url = test_server()->GetURL("files/extensions/isolated_apps/"); | 470 GURL base_url = embedded_test_server()->GetURL("/extensions/isolated_apps/"); |
407 GURL::Replacements replace_host; | 471 GURL::Replacements replace_host; |
408 std::string host_str("localhost"); // Must stay in scope with replace_host. | 472 std::string host_str("localhost"); // Must stay in scope with replace_host. |
409 replace_host.SetHostStr(host_str); | 473 replace_host.SetHostStr(host_str); |
410 base_url = base_url.ReplaceComponents(replace_host); | 474 base_url = base_url.ReplaceComponents(replace_host); |
411 | 475 |
412 // Create three tabs in the isolated app in different ways. | 476 // Create three tabs in the isolated app in different ways. |
413 ui_test_utils::NavigateToURLWithDisposition( | 477 ui_test_utils::NavigateToURLWithDisposition( |
414 browser(), base_url.Resolve("app1/main.html"), | 478 browser(), base_url.Resolve("app1/main.html"), |
415 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 479 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
416 ui_test_utils::NavigateToURLWithDisposition( | 480 ui_test_utils::NavigateToURLWithDisposition( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 GetRenderProcessHost()->GetID()); | 514 GetRenderProcessHost()->GetID()); |
451 } | 515 } |
452 | 516 |
453 // This test no longer passes, since we don't properly isolate sessionStorage | 517 // This test no longer passes, since we don't properly isolate sessionStorage |
454 // for isolated apps. This was broken as part of the changes for storage | 518 // for isolated apps. This was broken as part of the changes for storage |
455 // partition support for webview tags. | 519 // partition support for webview tags. |
456 // TODO(nasko): If isolated apps is no longer developed, this test should be | 520 // TODO(nasko): If isolated apps is no longer developed, this test should be |
457 // removed. http://crbug.com/159932 | 521 // removed. http://crbug.com/159932 |
458 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_SessionStorage) { | 522 IN_PROC_BROWSER_TEST_F(IsolatedAppTest, DISABLED_SessionStorage) { |
459 host_resolver()->AddRule("*", "127.0.0.1"); | 523 host_resolver()->AddRule("*", "127.0.0.1"); |
460 ASSERT_TRUE(test_server()->Start()); | 524 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
461 | 525 |
462 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); | 526 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); |
463 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2"))); | 527 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2"))); |
464 | 528 |
465 // The app under test acts on URLs whose host is "localhost", | 529 // The app under test acts on URLs whose host is "localhost", |
466 // so the URLs we navigate to must have host "localhost". | 530 // so the URLs we navigate to must have host "localhost". |
467 GURL base_url = test_server()->GetURL("files/extensions/isolated_apps/"); | 531 GURL base_url = embedded_test_server()->GetURL("/extensions/isolated_apps/"); |
468 GURL::Replacements replace_host; | 532 GURL::Replacements replace_host; |
469 std::string host_str("localhost"); // Must stay in scope with replace_host. | 533 std::string host_str("localhost"); // Must stay in scope with replace_host. |
470 replace_host.SetHostStr(host_str); | 534 replace_host.SetHostStr(host_str); |
471 base_url = base_url.ReplaceComponents(replace_host); | 535 base_url = base_url.ReplaceComponents(replace_host); |
472 | 536 |
473 // Enter some state into sessionStorage three times on the same origin, but | 537 // Enter some state into sessionStorage three times on the same origin, but |
474 // for three URLs that correspond to app1, app2, and a non-isolated site. | 538 // for three URLs that correspond to app1, app2, and a non-isolated site. |
475 ui_test_utils::NavigateToURLWithDisposition( | 539 ui_test_utils::NavigateToURLWithDisposition( |
476 browser(), base_url.Resolve("app1/main.html"), | 540 browser(), base_url.Resolve("app1/main.html"), |
477 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 541 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 EXPECT_EQ("ss_app2", result); | 580 EXPECT_EQ("ss_app2", result); |
517 | 581 |
518 ui_test_utils::NavigateToURLWithDisposition( | 582 ui_test_utils::NavigateToURLWithDisposition( |
519 browser(), base_url.Resolve("non_app/main.html"), | 583 browser(), base_url.Resolve("non_app/main.html"), |
520 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 584 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
521 ASSERT_TRUE(ExecuteScriptAndExtractString( | 585 ASSERT_TRUE(ExecuteScriptAndExtractString( |
522 browser()->tab_strip_model()->GetWebContentsAt(0), | 586 browser()->tab_strip_model()->GetWebContentsAt(0), |
523 kRetrieveSessionStorage.c_str(), &result)); | 587 kRetrieveSessionStorage.c_str(), &result)); |
524 EXPECT_EQ("ss_normal", result); | 588 EXPECT_EQ("ss_normal", result); |
525 } | 589 } |
OLD | NEW |