| 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" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 // Ensure first two tabs have installed apps. | 84 // Ensure first two tabs have installed apps. |
| 85 TabContents* tab1 = browser()->GetTabContentsAt(1); | 85 TabContents* tab1 = browser()->GetTabContentsAt(1); |
| 86 TabContents* tab2 = browser()->GetTabContentsAt(2); | 86 TabContents* tab2 = browser()->GetTabContentsAt(2); |
| 87 TabContents* tab3 = browser()->GetTabContentsAt(3); | 87 TabContents* tab3 = browser()->GetTabContentsAt(3); |
| 88 ASSERT_TRUE(GetInstalledApp(tab1)); | 88 ASSERT_TRUE(GetInstalledApp(tab1)); |
| 89 ASSERT_TRUE(GetInstalledApp(tab2)); | 89 ASSERT_TRUE(GetInstalledApp(tab2)); |
| 90 ASSERT_TRUE(!GetInstalledApp(tab3)); | 90 ASSERT_TRUE(!GetInstalledApp(tab3)); |
| 91 | 91 |
| 92 // Check that each tab sees its own cookie. | 92 // Check that each tab sees its own cookie. |
| 93 ASSERT_TRUE(HasCookie(tab1, "app1=3")); | 93 EXPECT_TRUE(HasCookie(tab1, "app1=3")); |
| 94 ASSERT_TRUE(HasCookie(tab2, "app2=4")); | 94 EXPECT_TRUE(HasCookie(tab2, "app2=4")); |
| 95 ASSERT_TRUE(HasCookie(tab3, "normalPage=5")); | 95 EXPECT_TRUE(HasCookie(tab3, "normalPage=5")); |
| 96 | 96 |
| 97 // Check that app1 tab cannot see the other cookies. | 97 // Check that app1 tab cannot see the other cookies. |
| 98 ASSERT_FALSE(HasCookie(tab1, "app2")); | 98 EXPECT_FALSE(HasCookie(tab1, "app2")); |
| 99 ASSERT_FALSE(HasCookie(tab1, "normalPage")); | 99 EXPECT_FALSE(HasCookie(tab1, "normalPage")); |
| 100 | 100 |
| 101 // Check that app2 tab cannot see the other cookies. | 101 // Check that app2 tab cannot see the other cookies. |
| 102 ASSERT_FALSE(HasCookie(tab2, "app1")); | 102 EXPECT_FALSE(HasCookie(tab2, "app1")); |
| 103 ASSERT_FALSE(HasCookie(tab2, "normalPage")); | 103 EXPECT_FALSE(HasCookie(tab2, "normalPage")); |
| 104 | 104 |
| 105 // Check that normal tab cannot see the other cookies. | 105 // Check that normal tab cannot see the other cookies. |
| 106 ASSERT_FALSE(HasCookie(tab3, "app1")); | 106 EXPECT_FALSE(HasCookie(tab3, "app1")); |
| 107 ASSERT_FALSE(HasCookie(tab3, "app2")); | 107 EXPECT_FALSE(HasCookie(tab3, "app2")); |
| 108 | 108 |
| 109 // Check that the non_app iframe cookie is associated with app1 and not the | 109 // Check that the non_app iframe cookie is associated with app1 and not the |
| 110 // normal tab. (For now, iframes are always rendered in their parent | 110 // normal tab. (For now, iframes are always rendered in their parent |
| 111 // process, even if they aren't in the app manifest.) | 111 // process, even if they aren't in the app manifest.) |
| 112 ASSERT_TRUE(HasCookie(tab1, "nonAppFrame=6")); | 112 EXPECT_TRUE(HasCookie(tab1, "nonAppFrame=6")); |
| 113 ASSERT_FALSE(HasCookie(tab3, "nonAppFrame")); | 113 EXPECT_FALSE(HasCookie(tab3, "nonAppFrame")); |
| 114 |
| 115 // Check that isolation persists even if the tab crashes and is reloaded. |
| 116 browser()->SelectNumberedTab(1); |
| 117 ui_test_utils::CrashTab(tab1); |
| 118 browser()->Reload(CURRENT_TAB); |
| 119 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
| 120 EXPECT_TRUE(HasCookie(tab1, "app1=3")); |
| 121 EXPECT_FALSE(HasCookie(tab1, "app2")); |
| 122 EXPECT_FALSE(HasCookie(tab1, "normalPage")); |
| 114 } | 123 } |
| 115 | 124 |
| 116 // Ensure that cookies are not isolated if the isolated apps are not installed. | 125 // Ensure that cookies are not isolated if the isolated apps are not installed. |
| 117 #if defined(OS_WIN) | 126 #if defined(OS_WIN) |
| 118 // Disabled due to http://crbug.com/89090. | 127 // Disabled due to http://crbug.com/89090. |
| 119 #define MAYBE_NoCookieIsolationWithoutApp DISABLED_NoCookieIsolationWithoutApp | 128 #define MAYBE_NoCookieIsolationWithoutApp DISABLED_NoCookieIsolationWithoutApp |
| 120 #else | 129 #else |
| 121 #define MAYBE_NoCookieIsolationWithoutApp NoCookieIsolationWithoutApp | 130 #define MAYBE_NoCookieIsolationWithoutApp NoCookieIsolationWithoutApp |
| 122 #endif | 131 #endif |
| 123 IN_PROC_BROWSER_TEST_F(IsolatedAppApiTest, NoCookieIsolationWithoutApp) { | 132 IN_PROC_BROWSER_TEST_F(IsolatedAppApiTest, NoCookieIsolationWithoutApp) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 148 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(1), "app2=4")); | 157 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(1), "app2=4")); |
| 149 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(1), "normalPage=5")); | 158 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(1), "normalPage=5")); |
| 150 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(1), "nonAppFrame=6")); | 159 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(1), "nonAppFrame=6")); |
| 151 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "app1=3")); | 160 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "app1=3")); |
| 152 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "normalPage=5")); | 161 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "normalPage=5")); |
| 153 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "nonAppFrame=6")); | 162 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(2), "nonAppFrame=6")); |
| 154 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(3), "app1=3")); | 163 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(3), "app1=3")); |
| 155 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(3), "app2=4")); | 164 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(3), "app2=4")); |
| 156 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(3), "nonAppFrame=6")); | 165 ASSERT_TRUE(HasCookie(browser()->GetTabContentsAt(3), "nonAppFrame=6")); |
| 157 } | 166 } |
| OLD | NEW |