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

Side by Side Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 1144473003: <webview>: Add JavaScript test for IndexedDB isolation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/isolation_indexeddb/main.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/process/process.h" 6 #include "base/process/process.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 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 EXPECT_STREQ("badval", output.c_str()); 1826 EXPECT_STREQ("badval", output.c_str());
1827 EXPECT_TRUE(ExecuteScriptAndExtractString(default_tag_contents1, 1827 EXPECT_TRUE(ExecuteScriptAndExtractString(default_tag_contents1,
1828 get_session_storage.c_str(), 1828 get_session_storage.c_str(),
1829 &output)); 1829 &output));
1830 EXPECT_STREQ("badval", output.c_str()); 1830 EXPECT_STREQ("badval", output.c_str());
1831 } 1831 }
1832 1832
1833 // This tests IndexedDB isolation for packaged apps with webview tags. It loads 1833 // This tests IndexedDB isolation for packaged apps with webview tags. It loads
1834 // an app with multiple webview tags and each tag creates an IndexedDB record, 1834 // an app with multiple webview tags and each tag creates an IndexedDB record,
1835 // which the test checks to ensure proper storage isolation is enforced. 1835 // which the test checks to ensure proper storage isolation is enforced.
1836 // This test is flaky. See http://crbug.com/248500. 1836 IN_PROC_BROWSER_TEST_F(WebViewTest, IndexedDBIsolation) {
1837 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_IndexedDBIsolation) {
1838 ASSERT_TRUE(StartEmbeddedTestServer()); 1837 ASSERT_TRUE(StartEmbeddedTestServer());
1839 GURL regular_url = embedded_test_server()->GetURL("/title1.html"); 1838 ASSERT_TRUE(RunPlatformAppTest(
1840 1839 "platform_apps/web_view/isolation_indexeddb")) << message_;
1841 content::WebContents* default_tag_contents1;
1842 content::WebContents* default_tag_contents2;
1843 content::WebContents* storage_contents1;
1844 content::WebContents* storage_contents2;
1845
1846 NavigateAndOpenAppForIsolation(regular_url, &default_tag_contents1,
1847 &default_tag_contents2, &storage_contents1,
1848 &storage_contents2, NULL, NULL, NULL);
1849
1850 // Initialize the storage for the first of the two tags that share a storage
1851 // partition.
1852 ExecuteScriptWaitForTitle(storage_contents1, "initIDB()", "idb created");
1853 ExecuteScriptWaitForTitle(storage_contents1, "addItemIDB(7, 'page1')",
1854 "addItemIDB complete");
1855 ExecuteScriptWaitForTitle(storage_contents1, "readItemIDB(7)",
1856 "readItemIDB complete");
1857
1858 std::string output;
1859 std::string get_value(
1860 "window.domAutomationController.send(getValueIDB() || 'badval')");
1861
1862 EXPECT_TRUE(ExecuteScriptAndExtractString(storage_contents1,
1863 get_value.c_str(), &output));
1864 EXPECT_STREQ("page1", output.c_str());
1865
1866 // Initialize the db in the second tag.
1867 ExecuteScriptWaitForTitle(storage_contents2, "initIDB()", "idb open");
1868
1869 // Since we share a partition, reading the value should return the existing
1870 // one.
1871 ExecuteScriptWaitForTitle(storage_contents2, "readItemIDB(7)",
1872 "readItemIDB complete");
1873 EXPECT_TRUE(ExecuteScriptAndExtractString(storage_contents2,
1874 get_value.c_str(), &output));
1875 EXPECT_STREQ("page1", output.c_str());
1876
1877 // Now write through the second tag and read it back.
1878 ExecuteScriptWaitForTitle(storage_contents2, "addItemIDB(7, 'page2')",
1879 "addItemIDB complete");
1880 ExecuteScriptWaitForTitle(storage_contents2, "readItemIDB(7)",
1881 "readItemIDB complete");
1882 EXPECT_TRUE(ExecuteScriptAndExtractString(storage_contents2,
1883 get_value.c_str(), &output));
1884 EXPECT_STREQ("page2", output.c_str());
1885
1886 // Reset the document title, otherwise the next call will not see a change and
1887 // will hang waiting for it.
1888 EXPECT_TRUE(content::ExecuteScript(storage_contents1,
1889 "document.title = 'foo'"));
1890
1891 // Read through the first tag to ensure we have the second value.
1892 ExecuteScriptWaitForTitle(storage_contents1, "readItemIDB(7)",
1893 "readItemIDB complete");
1894 EXPECT_TRUE(ExecuteScriptAndExtractString(storage_contents1,
1895 get_value.c_str(), &output));
1896 EXPECT_STREQ("page2", output.c_str());
1897
1898 // Now, let's confirm there is no database in the main browser and another
1899 // tag that doesn't share the same partition. Due to the IndexedDB API design,
1900 // open will succeed, but the version will be 1, since it creates the database
1901 // if it is not found. The two tags use database version 3, so we avoid
1902 // ambiguity.
1903 const char* script =
1904 "indexedDB.open('isolation').onsuccess = function(e) {"
1905 " if (e.target.result.version == 1)"
1906 " document.title = 'db not found';"
1907 " else "
1908 " document.title = 'error';"
1909 "}";
1910 ExecuteScriptWaitForTitle(browser()->tab_strip_model()->GetWebContentsAt(0),
1911 script, "db not found");
1912 ExecuteScriptWaitForTitle(default_tag_contents1, script, "db not found");
1913 } 1840 }
1914 1841
1915 // This test ensures that closing app window on 'loadcommit' does not crash. 1842 // This test ensures that closing app window on 'loadcommit' does not crash.
1916 // The test launches an app with guest and closes the window on loadcommit. It 1843 // The test launches an app with guest and closes the window on loadcommit. It
1917 // then launches the app window again. The process is repeated 3 times. 1844 // then launches the app window again. The process is repeated 3 times.
1918 // http://crbug.com/291278 1845 // http://crbug.com/291278
1919 #if defined(OS_WIN) 1846 #if defined(OS_WIN)
1920 #define MAYBE_CloseOnLoadcommit DISABLED_CloseOnLoadcommit 1847 #define MAYBE_CloseOnLoadcommit DISABLED_CloseOnLoadcommit
1921 #else 1848 #else
1922 #define MAYBE_CloseOnLoadcommit CloseOnLoadcommit 1849 #define MAYBE_CloseOnLoadcommit CloseOnLoadcommit
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 // This test verifies that the allowtransparency attribute properly propagates 2710 // This test verifies that the allowtransparency attribute properly propagates
2784 IN_PROC_BROWSER_TEST_F(WebViewTest, AllowTransparencyAndAllowScalingPropagate) { 2711 IN_PROC_BROWSER_TEST_F(WebViewTest, AllowTransparencyAndAllowScalingPropagate) {
2785 LoadAppWithGuest("web_view/simple"); 2712 LoadAppWithGuest("web_view/simple");
2786 2713
2787 ASSERT_TRUE(!!GetGuestWebContents()); 2714 ASSERT_TRUE(!!GetGuestWebContents());
2788 extensions::WebViewGuest* guest = 2715 extensions::WebViewGuest* guest =
2789 extensions::WebViewGuest::FromWebContents(GetGuestWebContents()); 2716 extensions::WebViewGuest::FromWebContents(GetGuestWebContents());
2790 ASSERT_TRUE(guest->allow_transparency()); 2717 ASSERT_TRUE(guest->allow_transparency());
2791 ASSERT_TRUE(guest->allow_scaling()); 2718 ASSERT_TRUE(guest->allow_scaling());
2792 } 2719 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/isolation_indexeddb/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698