diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 20:36:52 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 20:36:52 +0000 |
commit | a140203129a6d64cc02a90a6455bab31a94decb4 (patch) | |
tree | f5074c13a62f5b1372c9ca2dbcb4024cf9dbd8c8 /chrome | |
parent | 518eb7ca68a1cd8a12a621cdd784ce0e1e6310ad (diff) | |
download | chromium_src-a140203129a6d64cc02a90a6455bab31a94decb4.zip chromium_src-a140203129a6d64cc02a90a6455bab31a94decb4.tar.gz chromium_src-a140203129a6d64cc02a90a6455bab31a94decb4.tar.bz2 |
Add an extension API test to catch cookie regressions.
BUG=34649
Review URL: http://codereview.chromium.org/573032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38239 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 49 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_storage_apitest.cc b/chrome/browser/extensions/extension_storage_apitest.cc index 823cd19..f3745fb 100644 --- a/chrome/browser/extensions/extension_storage_apitest.cc +++ b/chrome/browser/extensions/extension_storage_apitest.cc @@ -12,3 +12,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Storage) { ASSERT_TRUE(RunExtensionTest("storage")) << message_; } + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Cookies) { + ASSERT_TRUE(RunExtensionTest("cookies")) << message_; +} diff --git a/chrome/test/data/extensions/api_test/cookies/background.html b/chrome/test/data/extensions/api_test/cookies/background.html new file mode 100644 index 0000000..b5f199a --- /dev/null +++ b/chrome/test/data/extensions/api_test/cookies/background.html @@ -0,0 +1,16 @@ +<script>
+ // Ensure we started with an empty profile.
+ chrome.test.assertEq(document.cookie, "");
+
+ // Set some cookies with a few different modifiers.
+ var expire = new Date();
+ expire.setDate(expire.getDate() + 1); // tomorrow
+ document.cookie = "a=1";
+ document.cookie = "b=2; path=/; domain=" + location.host;
+ document.cookie = "c=3; path=/; expires=" + expire +
+ "; domain=" + location.host;
+
+ // Open a tab. This doesn't really prove we're writing to disk, but it is
+ // difficult to prove that without shutting down the process.
+ chrome.tabs.create({url: "tab.html"});
+</script>
diff --git a/chrome/test/data/extensions/api_test/cookies/manifest.json b/chrome/test/data/extensions/api_test/cookies/manifest.json new file mode 100644 index 0000000..ebc11a5 --- /dev/null +++ b/chrome/test/data/extensions/api_test/cookies/manifest.json @@ -0,0 +1,7 @@ +{
+ "name": "chrome.cookies",
+ "version": "0.1",
+ "description": "sanity test that cookies can be set and read from extensions",
+ "background_page": "background.html",
+ "permissions": ["tabs"]
+}
diff --git a/chrome/test/data/extensions/api_test/cookies/tab.html b/chrome/test/data/extensions/api_test/cookies/tab.html new file mode 100644 index 0000000..4bf795a --- /dev/null +++ b/chrome/test/data/extensions/api_test/cookies/tab.html @@ -0,0 +1,22 @@ +<script>
+function readCookie(name) {
+ var nameEQ = name + "=";
+ var cookies = document.cookie.split(';');
+ for(var i=0; i < cookies.length; i++) {
+ var c = cookies[i];
+ while (c.charAt(0)==' ')
+ c = c.substring(1);
+ if (c.indexOf(nameEQ) == 0)
+ return c.substring(nameEQ.length);
+ }
+ return null;
+}
+
+chrome.test.runTests([function readCookies() {
+ chrome.test.assertEq(readCookie("a"), "1");
+ chrome.test.assertEq(readCookie("b"), "2");
+ chrome.test.assertEq(readCookie("c"), "3");
+ chrome.test.assertEq(readCookie("nonexistant"), null);
+ chrome.test.succeed();
+}]);
+</script>
|