Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1620)

Unified Diff: chrome/browser/extensions/isolated_app_browsertest.cc

Issue 10779005: Reorder CookieIsolation so that the intentional Crash occurs after tab ExecuteJavaScript. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/isolated_app_browsertest.cc
diff --git a/chrome/browser/extensions/isolated_app_browsertest.cc b/chrome/browser/extensions/isolated_app_browsertest.cc
index 9e7a7515fbbacbdf73cebd497e6633a9053ab6ab..d63a6c6415ad67e9e672cf3238277fa18513636d 100644
--- a/chrome/browser/extensions/isolated_app_browsertest.cc
+++ b/chrome/browser/extensions/isolated_app_browsertest.cc
@@ -115,6 +115,35 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) {
ASSERT_TRUE(GetInstalledApp(tab2));
ASSERT_TRUE(!GetInstalledApp(tab3));
+ // Check that tabs see cannot each other's localStorage even though they are
+ // in the same origin.
+ RenderViewHost* app1_rvh = tab1->GetRenderViewHost();
+ RenderViewHost* app2_rvh = tab2->GetRenderViewHost();
+ RenderViewHost* non_app_rvh = tab3->GetRenderViewHost();
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
+ app1_rvh, L"", L"window.localStorage.setItem('testdata', 'ls_app1');"));
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
+ app2_rvh, L"", L"window.localStorage.setItem('testdata', 'ls_app2');"));
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
+ non_app_rvh, L"",
+ L"window.localStorage.setItem('testdata', 'ls_normal');"));
+
+ ASSERT_TRUE(ExecuteJavaScript(
+ app1_rvh, L"", L"window.localStorage.getItem('testdata');"));
+
+ const std::wstring& kRetrieveLocalStorage =
+ WrapForJavascriptAndExtract(L"window.localStorage.getItem('testdata')");
+ std::string result;
+ ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
+ app1_rvh, L"", kRetrieveLocalStorage.c_str(), &result));
+ EXPECT_EQ("ls_app1", result);
+ ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
+ app2_rvh, L"", kRetrieveLocalStorage.c_str(), &result));
+ EXPECT_EQ("ls_app2", result);
+ ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
+ non_app_rvh, L"", kRetrieveLocalStorage.c_str(), &result));
+ EXPECT_EQ("ls_normal", result);
+
// Check that each tab sees its own cookie.
EXPECT_TRUE(HasCookie(tab1, "app1=3"));
EXPECT_TRUE(HasCookie(tab2, "app2=4"));
@@ -151,34 +180,6 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) {
EXPECT_FALSE(HasCookie(tab1, "app2"));
EXPECT_FALSE(HasCookie(tab1, "normalPage"));
- // Check that tabs see cannot each other's localStorage even though they are
- // in the same origin.
- RenderViewHost* app1_rvh = tab1->GetRenderViewHost();
- RenderViewHost* app2_rvh = tab2->GetRenderViewHost();
- RenderViewHost* non_app_rvh = tab3->GetRenderViewHost();
- ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
- app1_rvh, L"", L"window.localStorage.setItem('testdata', 'ls_app1');"));
- ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
- app2_rvh, L"", L"window.localStorage.setItem('testdata', 'ls_app2');"));
- ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
- non_app_rvh, L"",
- L"window.localStorage.setItem('testdata', 'ls_normal');"));
-
- ASSERT_TRUE(ExecuteJavaScript(
- app1_rvh, L"", L"window.localStorage.getItem('testdata');"));
-
- const std::wstring& kRetrieveLocalStorage =
- WrapForJavascriptAndExtract(L"window.localStorage.getItem('testdata')");
- std::string result;
- ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
- app1_rvh, L"", kRetrieveLocalStorage.c_str(), &result));
- EXPECT_EQ("ls_app1", result);
- ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
- app2_rvh, L"", kRetrieveLocalStorage.c_str(), &result));
- EXPECT_EQ("ls_app2", result);
- ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
- non_app_rvh, L"", kRetrieveLocalStorage.c_str(), &result));
- EXPECT_EQ("ls_normal", result);
}
// Ensure that cookies are not isolated if the isolated apps are not installed.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698