diff options
author | creis@google.com <creis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 22:45:09 +0000 |
---|---|---|
committer | creis@google.com <creis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 22:45:09 +0000 |
commit | d969667a1e558d2ba53e556233598cdc75d24678 (patch) | |
tree | 5b848ba7627e1240c0ef2855bf5780db83a027b7 /chrome/test | |
parent | 71e2f0a1ba62594c2cb555dd291810aaa7775779 (diff) | |
download | chromium_src-d969667a1e558d2ba53e556233598cdc75d24678.zip chromium_src-d969667a1e558d2ba53e556233598cdc75d24678.tar.gz chromium_src-d969667a1e558d2ba53e556233598cdc75d24678.tar.bz2 |
Initial support for partitioning cookies for isolated apps.
This CL adds experimental support for letting installed apps request isolated
storage in their manifest. An isolated app will have its own cookie store
that is not shared with other apps or normal pages, even if they share an
origin. The feature is currently behind a --enable-experimental-app-manifests
flag.
BUG=69335
TEST=ExtensionManifestTest.IsolatedApps
TEST=IsolatedAppApiTest.CookieIsolation*
Review URL: http://codereview.chromium.org/6201005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
10 files changed, 118 insertions, 1 deletions
diff --git a/chrome/test/data/extensions/api_test/app_process/manifest.json b/chrome/test/data/extensions/api_test/app_process/manifest.json index 2e35457..42a95fc 100644 --- a/chrome/test/data/extensions/api_test/app_process/manifest.json +++ b/chrome/test/data/extensions/api_test/app_process/manifest.json @@ -11,7 +11,7 @@ "http://localhost/files/extensions/api_test/app_process/path4" ], "launch": { - "web_url": "http://localhost:1337/files/extensions/api_test/app_process/path1/foo.html" + "web_url": "http://localhost/files/extensions/api_test/app_process/path1/foo.html" } } } diff --git a/chrome/test/data/extensions/api_test/isolated_apps/app1/main.html b/chrome/test/data/extensions/api_test/isolated_apps/app1/main.html new file mode 100644 index 0000000..427902c --- /dev/null +++ b/chrome/test/data/extensions/api_test/isolated_apps/app1/main.html @@ -0,0 +1,15 @@ +<html> +<body> +Isolated App 1 + +<script> + // Set a cookie within the app. + var expire = new Date(); + expire.setDate(expire.getDate() + 1); // tomorrow + document.cookie = "app1=3; path=/; expires=" + expire + ";" +</script> + +<!-- Include an iframe to a non-app URL. --> +<iframe src="../non_app/subframe.html"></iframe> +</body> +</html> diff --git a/chrome/test/data/extensions/api_test/isolated_apps/app1/manifest.json b/chrome/test/data/extensions/api_test/isolated_apps/app1/manifest.json new file mode 100644 index 0000000..2ef8d1c --- /dev/null +++ b/chrome/test/data/extensions/api_test/isolated_apps/app1/manifest.json @@ -0,0 +1,16 @@ +{ + "name": "isolated_app1", + "version": "0.1", + "description": "Tests isolation of stored data for apps.", + "app": { + "urls": [ + "http://localhost/files/extensions/api_test/isolated_apps/app1" + ], + "launch": { + "web_url": "http://localhost/files/extensions/api_test/isolated_apps/app1/main.html" + }, + "isolation": [ + "storage" + ] + } +} diff --git a/chrome/test/data/extensions/api_test/isolated_apps/app2/main.html b/chrome/test/data/extensions/api_test/isolated_apps/app2/main.html new file mode 100644 index 0000000..506e874 --- /dev/null +++ b/chrome/test/data/extensions/api_test/isolated_apps/app2/main.html @@ -0,0 +1,12 @@ +<html> +<body> +Isolated App 2 + +<script> + // Set a cookie within the app. + var expire = new Date(); + expire.setDate(expire.getDate() + 1); // tomorrow + document.cookie = "app2=4; path=/; expires=" + expire + ";" +</script> +</body> +</html> diff --git a/chrome/test/data/extensions/api_test/isolated_apps/app2/manifest.json b/chrome/test/data/extensions/api_test/isolated_apps/app2/manifest.json new file mode 100644 index 0000000..5ce184c --- /dev/null +++ b/chrome/test/data/extensions/api_test/isolated_apps/app2/manifest.json @@ -0,0 +1,16 @@ +{ + "name": "isolated_app2", + "version": "0.1", + "description": "Tests isolation of stored data for apps.", + "app": { + "urls": [ + "http://localhost/files/extensions/api_test/isolated_apps/app2" + ], + "launch": { + "web_url": "http://localhost/files/extensions/api_test/isolated_apps/app2/main.html" + }, + "isolation": [ + "storage" + ] + } +} diff --git a/chrome/test/data/extensions/api_test/isolated_apps/non_app/main.html b/chrome/test/data/extensions/api_test/isolated_apps/non_app/main.html new file mode 100644 index 0000000..ab8c9b31 --- /dev/null +++ b/chrome/test/data/extensions/api_test/isolated_apps/non_app/main.html @@ -0,0 +1,12 @@ +<html> +<body> +Normal page + +<script> + // Set a cookie outside any apps. + var expire = new Date(); + expire.setDate(expire.getDate() + 1); // tomorrow + document.cookie = "normalPage=5; path=/; expires=" + expire + ";" +</script> +</body> +</html> diff --git a/chrome/test/data/extensions/api_test/isolated_apps/non_app/subframe.html b/chrome/test/data/extensions/api_test/isolated_apps/non_app/subframe.html new file mode 100644 index 0000000..41fb7e7 --- /dev/null +++ b/chrome/test/data/extensions/api_test/isolated_apps/non_app/subframe.html @@ -0,0 +1,12 @@ +<html> +<body> +Normal page + +<script> + // Set a cookie from a page in an iframe. + var expire = new Date(); + expire.setDate(expire.getDate() + 1); // tomorrow + document.cookie = "nonAppFrame=6; path=/; expires=" + expire + ";" +</script> +</body> +</html> diff --git a/chrome/test/data/extensions/manifest_tests/isolated_app_valid.json b/chrome/test/data/extensions/manifest_tests/isolated_app_valid.json new file mode 100644 index 0000000..eb2ccb0 --- /dev/null +++ b/chrome/test/data/extensions/manifest_tests/isolated_app_valid.json @@ -0,0 +1,15 @@ +{ + "name": "test", + "version": "1", + "app": { + "urls": [ + "http://www.google.com/mail/" + ], + "launch": { + "web_url": "http://www.google.com/mail/" + }, + "isolation": [ + "storage" + ] + } +} diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index 2534ef0..a348337 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -563,6 +563,14 @@ URLRequestContextGetter* TestingProfile::GetRequestContext() { return request_context_.get(); } +URLRequestContextGetter* TestingProfile::GetRequestContextForPossibleApp( + const Extension* installed_app) { + if (installed_app != NULL && installed_app->is_storage_isolated()) + return GetRequestContextForIsolatedApp(installed_app->id()); + + return GetRequestContext(); +} + void TestingProfile::CreateRequestContext() { if (!request_context_) request_context_ = new TestURLRequestContextGetter(); @@ -590,6 +598,13 @@ UserStyleSheetWatcher* TestingProfile::GetUserStyleSheetWatcher() { return NULL; } +URLRequestContextGetter* TestingProfile::GetRequestContextForIsolatedApp( + const std::string& app_id) { + // We don't test isolated app storage here yet, so returning the same dummy + // context is sufficient for now. + return GetRequestContext(); +} + FindBarState* TestingProfile::GetFindBarState() { if (!find_bar_state_.get()) find_bar_state_.reset(new FindBarState()); diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 49063b5..3ae70ba 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -201,6 +201,8 @@ class TestingProfile : public Profile { // getter is currently only capable of returning a Context that helps test // the CookieMonster. See implementation comments for more details. virtual URLRequestContextGetter* GetRequestContext(); + virtual URLRequestContextGetter* GetRequestContextForPossibleApp( + const Extension* installed_app); void CreateRequestContext(); // Clears out the created request context (which must be done before shutting // down the IO thread to avoid leaks). @@ -208,6 +210,8 @@ class TestingProfile : public Profile { virtual URLRequestContextGetter* GetRequestContextForMedia(); virtual URLRequestContextGetter* GetRequestContextForExtensions(); + virtual URLRequestContextGetter* GetRequestContextForIsolatedApp( + const std::string& app_id); virtual net::SSLConfigService* GetSSLConfigService(); virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher(); |