OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
19 #include "net/base/mock_host_resolver.h" | 19 #include "net/base/mock_host_resolver.h" |
20 | 20 |
| 21 using content::NavigationController; |
| 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 class IsolatedAppTest : public ExtensionBrowserTest { | 25 class IsolatedAppTest : public ExtensionBrowserTest { |
24 public: | 26 public: |
25 // Returns whether the given tab's current URL has the given cookie. | 27 // Returns whether the given tab's current URL has the given cookie. |
26 bool WARN_UNUSED_RESULT HasCookie(TabContents* contents, std::string cookie) { | 28 bool WARN_UNUSED_RESULT HasCookie(TabContents* contents, std::string cookie) { |
27 int value_size; | 29 int value_size; |
28 std::string actual_cookie; | 30 std::string actual_cookie; |
29 automation_util::GetCookies(contents->GetURL(), contents, &value_size, | 31 automation_util::GetCookies(contents->GetURL(), contents, &value_size, |
30 &actual_cookie); | 32 &actual_cookie); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // normal tab. (For now, iframes are always rendered in their parent | 113 // normal tab. (For now, iframes are always rendered in their parent |
112 // process, even if they aren't in the app manifest.) | 114 // process, even if they aren't in the app manifest.) |
113 EXPECT_TRUE(HasCookie(tab1, "nonAppFrame=6")); | 115 EXPECT_TRUE(HasCookie(tab1, "nonAppFrame=6")); |
114 EXPECT_FALSE(HasCookie(tab3, "nonAppFrame")); | 116 EXPECT_FALSE(HasCookie(tab3, "nonAppFrame")); |
115 | 117 |
116 // Check that isolation persists even if the tab crashes and is reloaded. | 118 // Check that isolation persists even if the tab crashes and is reloaded. |
117 browser()->SelectNumberedTab(1); | 119 browser()->SelectNumberedTab(1); |
118 ui_test_utils::CrashTab(tab1); | 120 ui_test_utils::CrashTab(tab1); |
119 ui_test_utils::WindowedNotificationObserver observer( | 121 ui_test_utils::WindowedNotificationObserver observer( |
120 content::NOTIFICATION_LOAD_STOP, | 122 content::NOTIFICATION_LOAD_STOP, |
121 content::Source<content::NavigationController>( | 123 content::Source<NavigationController>( |
122 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> | 124 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
123 GetController())); | 125 GetController())); |
124 browser()->Reload(CURRENT_TAB); | 126 browser()->Reload(CURRENT_TAB); |
125 observer.Wait(); | 127 observer.Wait(); |
126 EXPECT_TRUE(HasCookie(tab1, "app1=3")); | 128 EXPECT_TRUE(HasCookie(tab1, "app1=3")); |
127 EXPECT_FALSE(HasCookie(tab1, "app2")); | 129 EXPECT_FALSE(HasCookie(tab1, "app2")); |
128 EXPECT_FALSE(HasCookie(tab1, "normalPage")); | 130 EXPECT_FALSE(HasCookie(tab1, "normalPage")); |
129 } | 131 } |
130 | 132 |
131 // Ensure that cookies are not isolated if the isolated apps are not installed. | 133 // Ensure that cookies are not isolated if the isolated apps are not installed. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 EXPECT_NE(hosted1_host, web1_host); | 292 EXPECT_NE(hosted1_host, web1_host); |
291 EXPECT_NE(hosted1_host, extension1_host); | 293 EXPECT_NE(hosted1_host, extension1_host); |
292 | 294 |
293 // Web pages only share with each other. | 295 // Web pages only share with each other. |
294 EXPECT_EQ(web1_host, web2_host); | 296 EXPECT_EQ(web1_host, web2_host); |
295 EXPECT_NE(web1_host, extension1_host); | 297 EXPECT_NE(web1_host, extension1_host); |
296 | 298 |
297 // Extensions only share with each other. | 299 // Extensions only share with each other. |
298 EXPECT_EQ(extension1_host, extension2_host); | 300 EXPECT_EQ(extension1_host, extension2_host); |
299 } | 301 } |
OLD | NEW |