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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/automation/automation_util.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
10 #include "chrome/browser/extensions/extension_host.h" | 11 #include "chrome/browser/extensions/extension_host.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/extension_test_message_listener.h" | 13 #include "chrome/browser/extensions/extension_test_message_listener.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 15 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 173 } |
173 | 174 |
174 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Restrictions) { | 175 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Restrictions) { |
175 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restrictions")) << message_; | 176 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restrictions")) << message_; |
176 } | 177 } |
177 | 178 |
178 // Tests that platform apps can use the chrome.windows.* API. | 179 // Tests that platform apps can use the chrome.windows.* API. |
179 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApi) { | 180 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApi) { |
180 ASSERT_TRUE(RunPlatformAppTest("platform_apps/windows_api")) << message_; | 181 ASSERT_TRUE(RunPlatformAppTest("platform_apps/windows_api")) << message_; |
181 } | 182 } |
| 183 |
| 184 // Tests that platform apps have isolated storage by default. |
| 185 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Isolation) { |
| 186 ASSERT_TRUE(StartTestServer()); |
| 187 |
| 188 // Load a (non-app) page under the "localhost" origin that sets a cookie. |
| 189 GURL set_cookie_url = test_server()->GetURL( |
| 190 "files/extensions/platform_apps/isolation/set_cookie.html"); |
| 191 GURL::Replacements replace_host; |
| 192 std::string host_str("localhost"); // Must stay in scope with replace_host. |
| 193 replace_host.SetHostStr(host_str); |
| 194 set_cookie_url = set_cookie_url.ReplaceComponents(replace_host); |
| 195 |
| 196 ui_test_utils::NavigateToURLWithDisposition( |
| 197 browser(), set_cookie_url, |
| 198 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 199 |
| 200 // Make sure the cookie is set. |
| 201 int cookie_size; |
| 202 std::string cookie_value; |
| 203 automation_util::GetCookies( |
| 204 set_cookie_url, |
| 205 browser()->GetWebContentsAt(0), |
| 206 &cookie_size, |
| 207 &cookie_value); |
| 208 ASSERT_EQ("testCookie=1", cookie_value); |
| 209 |
| 210 // Let the platform app request the same URL, and make sure that it doesn't |
| 211 // see the cookie. |
| 212 ASSERT_TRUE(RunPlatformAppTest("platform_apps/isolation")) << message_; |
| 213 } |
OLD | NEW |