| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/ui/native_app_window.h" | 5 #include "apps/ui/native_app_window.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/apps/app_browsertest_util.h" | 10 #include "chrome/browser/apps/app_browsertest_util.h" |
| (...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyWebView())); | 1269 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyWebView())); |
| 1270 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 1270 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 1271 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); | 1271 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); |
| 1272 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyBackground())); | 1272 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyBackground())); |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 // This tests cookie isolation for packaged apps with webview tags. It navigates | 1275 // This tests cookie isolation for packaged apps with webview tags. It navigates |
| 1276 // the main browser window to a page that sets a cookie and loads an app with | 1276 // the main browser window to a page that sets a cookie and loads an app with |
| 1277 // multiple webview tags. Each tag sets a cookie and the test checks the proper | 1277 // multiple webview tags. Each tag sets a cookie and the test checks the proper |
| 1278 // storage isolation is enforced. | 1278 // storage isolation is enforced. |
| 1279 // This test is disabled due to being flaky. http://crbug.com/294196 | 1279 IN_PROC_BROWSER_TEST_F(WebViewTest, CookieIsolation) { |
| 1280 #if defined(OS_WIN) | |
| 1281 #define MAYBE_CookieIsolation DISABLED_CookieIsolation | |
| 1282 #else | |
| 1283 #define MAYBE_CookieIsolation CookieIsolation | |
| 1284 #endif | |
| 1285 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_CookieIsolation) { | |
| 1286 ASSERT_TRUE(StartEmbeddedTestServer()); | 1280 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 1287 const std::string kExpire = | 1281 const std::string kExpire = |
| 1288 "var expire = new Date(Date.now() + 24 * 60 * 60 * 1000);"; | 1282 "var expire = new Date(Date.now() + 24 * 60 * 60 * 1000);"; |
| 1289 std::string cookie_script1(kExpire); | 1283 std::string cookie_script1(kExpire); |
| 1290 cookie_script1.append( | 1284 cookie_script1.append( |
| 1291 "document.cookie = 'guest1=true; path=/; expires=' + expire + ';';"); | 1285 "document.cookie = 'guest1=true; path=/; expires=' + expire + ';';"); |
| 1292 std::string cookie_script2(kExpire); | 1286 std::string cookie_script2(kExpire); |
| 1293 cookie_script2.append( | 1287 cookie_script2.append( |
| 1294 "document.cookie = 'guest2=true; path=/; expires=' + expire + ';';"); | 1288 "document.cookie = 'guest2=true; path=/; expires=' + expire + ';';"); |
| 1295 | 1289 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 &cookie_size, &cookie_value); | 1420 &cookie_size, &cookie_value); |
| 1427 EXPECT_EQ("persist1=true", cookie_value); | 1421 EXPECT_EQ("persist1=true", cookie_value); |
| 1428 ui_test_utils::GetCookies(GURL("http://localhost"), | 1422 ui_test_utils::GetCookies(GURL("http://localhost"), |
| 1429 persistent_partition_contents3, | 1423 persistent_partition_contents3, |
| 1430 &cookie_size, &cookie_value); | 1424 &cookie_size, &cookie_value); |
| 1431 EXPECT_EQ("persist2=true", cookie_value); | 1425 EXPECT_EQ("persist2=true", cookie_value); |
| 1432 } | 1426 } |
| 1433 | 1427 |
| 1434 // This is the post-reset portion of the StoragePersistence test. See | 1428 // This is the post-reset portion of the StoragePersistence test. See |
| 1435 // PRE_StoragePersistence for main comment. | 1429 // PRE_StoragePersistence for main comment. |
| 1436 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_StoragePersistence) { | 1430 IN_PROC_BROWSER_TEST_F(WebViewTest, StoragePersistence) { |
| 1437 ASSERT_TRUE(StartEmbeddedTestServer()); | 1431 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 1438 | 1432 |
| 1439 // We don't care where the main browser is on this test. | 1433 // We don't care where the main browser is on this test. |
| 1440 GURL blank_url("about:blank"); | 1434 GURL blank_url("about:blank"); |
| 1441 | 1435 |
| 1442 // The first two partitions will be used to set cookies and ensure they are | 1436 // The first two partitions will be used to set cookies and ensure they are |
| 1443 // shared. The named partition is used to ensure that cookies are isolated | 1437 // shared. The named partition is used to ensure that cookies are isolated |
| 1444 // between partitions within the same app. | 1438 // between partitions within the same app. |
| 1445 content::WebContents* cookie_contents1; | 1439 content::WebContents* cookie_contents1; |
| 1446 content::WebContents* cookie_contents2; | 1440 content::WebContents* cookie_contents2; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 ui_test_utils::GetCookies(GURL("http://localhost"), | 1479 ui_test_utils::GetCookies(GURL("http://localhost"), |
| 1486 persistent_partition_contents2, | 1480 persistent_partition_contents2, |
| 1487 &cookie_size, &cookie_value); | 1481 &cookie_size, &cookie_value); |
| 1488 EXPECT_EQ("persist1=true", cookie_value); | 1482 EXPECT_EQ("persist1=true", cookie_value); |
| 1489 ui_test_utils::GetCookies(GURL("http://localhost"), | 1483 ui_test_utils::GetCookies(GURL("http://localhost"), |
| 1490 persistent_partition_contents3, | 1484 persistent_partition_contents3, |
| 1491 &cookie_size, &cookie_value); | 1485 &cookie_size, &cookie_value); |
| 1492 EXPECT_EQ("persist2=true", cookie_value); | 1486 EXPECT_EQ("persist2=true", cookie_value); |
| 1493 } | 1487 } |
| 1494 | 1488 |
| 1495 #if defined(OS_WIN) | |
| 1496 // This test is very flaky on Win Aura, Win XP, Win 7. http://crbug.com/248873 | |
| 1497 #define MAYBE_DOMStorageIsolation DISABLED_DOMStorageIsolation | |
| 1498 #else | |
| 1499 #define MAYBE_DOMStorageIsolation DOMStorageIsolation | |
| 1500 #endif | |
| 1501 | |
| 1502 // This tests DOM storage isolation for packaged apps with webview tags. It | 1489 // This tests DOM storage isolation for packaged apps with webview tags. It |
| 1503 // loads an app with multiple webview tags and each tag sets DOM storage | 1490 // loads an app with multiple webview tags and each tag sets DOM storage |
| 1504 // entries, which the test checks to ensure proper storage isolation is | 1491 // entries, which the test checks to ensure proper storage isolation is |
| 1505 // enforced. | 1492 // enforced. |
| 1506 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_DOMStorageIsolation) { | 1493 IN_PROC_BROWSER_TEST_F(WebViewTest, DOMStorageIsolation) { |
| 1507 ASSERT_TRUE(StartEmbeddedTestServer()); | 1494 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 1508 GURL regular_url = embedded_test_server()->GetURL("/title1.html"); | 1495 GURL regular_url = embedded_test_server()->GetURL("/title1.html"); |
| 1509 | 1496 |
| 1510 std::string output; | 1497 std::string output; |
| 1511 std::string get_local_storage("window.domAutomationController.send(" | 1498 std::string get_local_storage("window.domAutomationController.send(" |
| 1512 "window.localStorage.getItem('foo') || 'badval')"); | 1499 "window.localStorage.getItem('foo') || 'badval')"); |
| 1513 std::string get_session_storage("window.domAutomationController.send(" | 1500 std::string get_session_storage("window.domAutomationController.send(" |
| 1514 "window.sessionStorage.getItem('bar') || 'badval')"); | 1501 "window.sessionStorage.getItem('bar') || 'badval')"); |
| 1515 | 1502 |
| 1516 content::WebContents* default_tag_contents1; | 1503 content::WebContents* default_tag_contents1; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 EXPECT_TRUE(ExecuteScriptAndExtractString(default_tag_contents1, | 1567 EXPECT_TRUE(ExecuteScriptAndExtractString(default_tag_contents1, |
| 1581 get_local_storage.c_str(), | 1568 get_local_storage.c_str(), |
| 1582 &output)); | 1569 &output)); |
| 1583 EXPECT_STREQ("badval", output.c_str()); | 1570 EXPECT_STREQ("badval", output.c_str()); |
| 1584 EXPECT_TRUE(ExecuteScriptAndExtractString(default_tag_contents1, | 1571 EXPECT_TRUE(ExecuteScriptAndExtractString(default_tag_contents1, |
| 1585 get_session_storage.c_str(), | 1572 get_session_storage.c_str(), |
| 1586 &output)); | 1573 &output)); |
| 1587 EXPECT_STREQ("badval", output.c_str()); | 1574 EXPECT_STREQ("badval", output.c_str()); |
| 1588 } | 1575 } |
| 1589 | 1576 |
| 1590 // See crbug.com/248500 | |
| 1591 #if defined(OS_WIN) | |
| 1592 #define MAYBE_IndexedDBIsolation DISABLED_IndexedDBIsolation | |
| 1593 #else | |
| 1594 #define MAYBE_IndexedDBIsolation IndexedDBIsolation | |
| 1595 #endif | |
| 1596 | |
| 1597 // This tests IndexedDB isolation for packaged apps with webview tags. It loads | 1577 // This tests IndexedDB isolation for packaged apps with webview tags. It loads |
| 1598 // an app with multiple webview tags and each tag creates an IndexedDB record, | 1578 // an app with multiple webview tags and each tag creates an IndexedDB record, |
| 1599 // which the test checks to ensure proper storage isolation is enforced. | 1579 // which the test checks to ensure proper storage isolation is enforced. |
| 1600 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_IndexedDBIsolation) { | 1580 IN_PROC_BROWSER_TEST_F(WebViewTest, IndexedDBIsolation) { |
| 1601 ASSERT_TRUE(StartEmbeddedTestServer()); | 1581 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 1602 GURL regular_url = embedded_test_server()->GetURL("/title1.html"); | 1582 GURL regular_url = embedded_test_server()->GetURL("/title1.html"); |
| 1603 | 1583 |
| 1604 content::WebContents* default_tag_contents1; | 1584 content::WebContents* default_tag_contents1; |
| 1605 content::WebContents* default_tag_contents2; | 1585 content::WebContents* default_tag_contents2; |
| 1606 content::WebContents* storage_contents1; | 1586 content::WebContents* storage_contents1; |
| 1607 content::WebContents* storage_contents2; | 1587 content::WebContents* storage_contents2; |
| 1608 | 1588 |
| 1609 NavigateAndOpenAppForIsolation(regular_url, &default_tag_contents1, | 1589 NavigateAndOpenAppForIsolation(regular_url, &default_tag_contents1, |
| 1610 &default_tag_contents2, &storage_contents1, | 1590 &default_tag_contents2, &storage_contents1, |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2164 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestFindAPI_findupdate) { | 2144 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestFindAPI_findupdate) { |
| 2165 TestHelper("testFindAPI_findupdate", "web_view/shim", NO_TEST_SERVER); | 2145 TestHelper("testFindAPI_findupdate", "web_view/shim", NO_TEST_SERVER); |
| 2166 } | 2146 } |
| 2167 | 2147 |
| 2168 // <webview> screenshot capture fails with ubercomp. | 2148 // <webview> screenshot capture fails with ubercomp. |
| 2169 // See http://crbug.com/327035. | 2149 // See http://crbug.com/327035. |
| 2170 IN_PROC_BROWSER_TEST_F(WebViewCaptureTest, | 2150 IN_PROC_BROWSER_TEST_F(WebViewCaptureTest, |
| 2171 DISABLED_Shim_ScreenshotCapture) { | 2151 DISABLED_Shim_ScreenshotCapture) { |
| 2172 TestHelper("testScreenshotCapture", "web_view/shim", NO_TEST_SERVER); | 2152 TestHelper("testScreenshotCapture", "web_view/shim", NO_TEST_SERVER); |
| 2173 } | 2153 } |
| OLD | NEW |