summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/extension_storage_apitest.cc9
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc12
-rw-r--r--chrome/browser/tab_contents/render_view_host_delegate_helper.cc8
-rw-r--r--chrome/chrome.gyp1
-rw-r--r--chrome/common/render_messages.h2
-rw-r--r--chrome/renderer/render_thread.cc7
-rwxr-xr-xchrome/test/data/extensions/api_test/storage/api_test.js77
-rw-r--r--chrome/test/data/extensions/api_test/storage/background.html22
-rw-r--r--chrome/test/data/extensions/api_test/storage/manifest.json7
-rw-r--r--chrome/test/data/extensions/api_test/storage/tab.html17
-rw-r--r--webkit/glue/webpreferences.cc3
-rw-r--r--webkit/glue/webpreferences.h2
12 files changed, 152 insertions, 15 deletions
diff --git a/chrome/browser/extensions/extension_storage_apitest.cc b/chrome/browser/extensions/extension_storage_apitest.cc
new file mode 100644
index 0000000..b75cc0e
--- /dev/null
+++ b/chrome/browser/extensions/extension_storage_apitest.cc
@@ -0,0 +1,9 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_apitest.h"
+
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Storage) {
+ ASSERT_TRUE(RunExtensionTest("storage")) << message_;
+}
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index d028db5..7206dfc 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -208,10 +208,20 @@ bool RenderViewHost::CreateRenderView() {
modal_dialog_event.event = modal_dialog_event_handle;
#endif
+ // Force local storage to be enabled for extensions. This is so that we can
+ // enable extensions by default before databases, if necessary.
+ // TODO(aa): This should be removed when local storage and databases are
+ // enabled by default (bugs 4359 and 4360).
+ WebPreferences webkit_prefs = delegate_->GetWebkitPrefs();
+ if (delegate_->GetURL().SchemeIs(chrome::kExtensionScheme)) {
+ webkit_prefs.local_storage_enabled = true;
+ webkit_prefs.databases_enabled = true;
+ }
+
Send(new ViewMsg_New(GetNativeViewId(),
modal_dialog_event,
delegate_->GetRendererPrefs(),
- delegate_->GetWebkitPrefs(),
+ webkit_prefs,
routing_id()));
// Set the alternate error page, which is profile specific, in the renderer.
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
index 5146caf..184fc5e 100644
--- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
+++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
@@ -179,12 +179,10 @@ WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(
web_prefs.application_cache_enabled =
command_line.HasSwitch(switches::kEnableApplicationCache);
- // NOTE: We imply local storage enabledness for extensions because the
- // extensions team is beta testing local storage and we like to live on the
- // edge.
web_prefs.local_storage_enabled =
- command_line.HasSwitch(switches::kEnableLocalStorage) ||
- command_line.HasSwitch(switches::kEnableExtensions);
+ command_line.HasSwitch(switches::kEnableLocalStorage);
+ web_prefs.databases_enabled =
+ command_line.HasSwitch(switches::kEnableDatabases);
web_prefs.session_storage_enabled =
command_line.HasSwitch(switches::kEnableSessionStorage);
}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index a58ca7f..bd42785 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -53,6 +53,7 @@
'browser/extensions/extension_browsertests_misc.cc',
'browser/extensions/extension_shelf_model_unittest.cc',
'browser/extensions/extension_startup_unittest.cc',
+ 'browser/extensions/extension_storage_apitest.cc',
'browser/views/browser_views_accessibility_browsertest.cc',
'browser/views/find_bar_win_browsertest.cc',
# TODO(jam): http://crbug.com/15101 These tests fail on Linux and Mac.
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index aeda43d..32a2e33 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1622,6 +1622,7 @@ struct ParamTraits<WebPreferences> {
WriteParam(m, p.remote_fonts_enabled);
WriteParam(m, p.xss_auditor_enabled);
WriteParam(m, p.local_storage_enabled);
+ WriteParam(m, p.databases_enabled);
WriteParam(m, p.session_storage_enabled);
WriteParam(m, p.application_cache_enabled);
}
@@ -1656,6 +1657,7 @@ struct ParamTraits<WebPreferences> {
ReadParam(m, iter, &p->remote_fonts_enabled) &&
ReadParam(m, iter, &p->xss_auditor_enabled) &&
ReadParam(m, iter, &p->local_storage_enabled) &&
+ ReadParam(m, iter, &p->databases_enabled) &&
ReadParam(m, iter, &p->session_storage_enabled) &&
ReadParam(m, iter, &p->application_cache_enabled);
}
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index af5e4c5..1492e9d 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -415,13 +415,6 @@ void RenderThread::EnsureWebKitInitialized() {
if (RenderProcess::current()->initialized_media_library())
WebKit::enableMediaPlayer();
-
- // Note: We are forcing --enable-databases to on with --enable-extensions so
- // that extension developers can test databases.
- if (command_line.HasSwitch(switches::kEnableDatabases) ||
- command_line.HasSwitch(switches::kEnableExtensions)) {
- WebKit::enableDatabases();
- }
}
void RenderThread::OnExtensionMessageInvoke(const std::string& function_name,
diff --git a/chrome/test/data/extensions/api_test/storage/api_test.js b/chrome/test/data/extensions/api_test/storage/api_test.js
new file mode 100755
index 0000000..985cff3
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/storage/api_test.js
@@ -0,0 +1,77 @@
+// api_test.js
+// mini-framework for ExtensionApiTest browser tests
+// TODO(erikkay) - figure out a way to share this code across extensions
+
+var completed = false;
+var tests;
+var currentTest;
+
+function complete() {
+ completed = true;
+
+ // a bit of a hack just to try to get the script to stop running at this point
+ throw "completed";
+}
+
+function fail(message) {
+ if (completed) throw "completed";
+
+ var stack;
+ try {
+ crash.me += 0; // intentional exception to get the stack trace
+ } catch (e) {
+ stack = e.stack.split("\n");
+ stack = stack.slice(2); // remove title and fail()
+ stack = stack.join("\n");
+ }
+
+ if (!message) {
+ message = "FAIL (no message)";
+ }
+ message += "\n" + stack;
+ console.log("[FAIL] " + currentTest.name + ": " + message);
+ chrome.test.fail(message);
+ complete();
+}
+
+function allTestsSucceeded() {
+ console.log("All tests succeeded");
+ if (completed) throw "completed";
+
+ chrome.test.pass();
+ complete();
+}
+
+function runNextTest() {
+ currentTest = tests.shift();
+ if (!currentTest) {
+ allTestsSucceeded();
+ return;
+ }
+ currentTest.call();
+}
+
+function succeed() {
+ console.log("[SUCCESS] " + currentTest.name);
+ runNextTest();
+}
+
+window.onerror = function(message, url, code) {
+ if (completed) return;
+
+ fail(message);
+};
+
+function expectTrue(test, message) {
+ if (test !== true) {
+ if (typeof(test) == "string") {
+ if (message) {
+ message = test + "\n" + message;
+ } else {
+ message = test;
+ }
+ }
+ fail(message);
+ }
+}
+
diff --git a/chrome/test/data/extensions/api_test/storage/background.html b/chrome/test/data/extensions/api_test/storage/background.html
new file mode 100644
index 0000000..b704b2d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/storage/background.html
@@ -0,0 +1,22 @@
+<script>
+ // store some stuff in local storage
+ localStorage.foo = "bar";
+
+ // store some stuff in a database
+ var db = window.openDatabase("mydb2", "1.0", "database test");
+ db.transaction(function(tx) {
+ tx.executeSql("drop table if exists note");
+ tx.executeSql("create table note (body text)", []);
+ tx.executeSql("insert into note values ('hotdog')", []);
+ }, function(error) {
+ fail(error.message);
+ });
+
+ // 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. We'll just
+ // trust that if this next trick works, that the real testing for local
+ // storage is good enough to catch more subtle errors.
+ chrome.tabs.create({
+ url: "tab.html"
+ });
+</script>
diff --git a/chrome/test/data/extensions/api_test/storage/manifest.json b/chrome/test/data/extensions/api_test/storage/manifest.json
new file mode 100644
index 0000000..0e167e4
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/storage/manifest.json
@@ -0,0 +1,7 @@
+{
+ "name": "chrome.storage",
+ "version": "0.1",
+ "description": "sanity test that storage is always enabled for extensions",
+ "background_page": "background.html",
+ "permissions": ["tabs"]
+}
diff --git a/chrome/test/data/extensions/api_test/storage/tab.html b/chrome/test/data/extensions/api_test/storage/tab.html
new file mode 100644
index 0000000..b52fdc3
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/storage/tab.html
@@ -0,0 +1,17 @@
+<script src="api_test.js"></script>
+<script>
+ // Check that the localstorage stuff we stored is still there.
+ expectTrue(localStorage.foo == "bar");
+
+ // Check that the database stuff we stored is still there.
+ var db = window.openDatabase("mydb2", "1.0", "database test", 2048);
+ db.transaction(function(tx) {
+ tx.executeSql("select body from note", [], function(tx, results) {
+ expectTrue(results.rows.length == 1);
+ expectTrue(results.rows.item(0).body == "hotdog");
+ allTestsSucceeded();
+ });
+ }, function(error) {
+ fail(error.message);
+ });
+</script>
diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc
index e14788e..785bdbf 100644
--- a/webkit/glue/webpreferences.cc
+++ b/webkit/glue/webpreferences.cc
@@ -48,6 +48,7 @@ void WebPreferences::Apply(WebView* web_view) const {
settings->setDownloadableBinaryFontsEnabled(remote_fonts_enabled);
settings->setXSSAuditorEnabled(xss_auditor_enabled);
settings->setLocalStorageEnabled(local_storage_enabled);
+ settings->setDatabasesEnabled(WebKit::databasesEnabled() || databases_enabled);
settings->setSessionStorageEnabled(session_storage_enabled);
settings->setOfflineWebApplicationCacheEnabled(application_cache_enabled);
@@ -63,8 +64,6 @@ void WebPreferences::Apply(WebView* web_view) const {
// Turn this on to cause WebCore to paint the resize corner for us.
settings->setShouldPaintCustomScrollbars(true);
- settings->setDatabasesEnabled(WebKit::databasesEnabled());
-
// Mitigate attacks from local HTML files by not granting file:// URLs
// universal access.
settings->setAllowUniversalAccessFromFileURLs(false);
diff --git a/webkit/glue/webpreferences.h b/webkit/glue/webpreferences.h
index c48339fa..f0ab0bb 100644
--- a/webkit/glue/webpreferences.h
+++ b/webkit/glue/webpreferences.h
@@ -45,6 +45,7 @@ struct WebPreferences {
bool remote_fonts_enabled;
bool xss_auditor_enabled;
bool local_storage_enabled;
+ bool databases_enabled;
bool session_storage_enabled;
bool application_cache_enabled;
@@ -85,6 +86,7 @@ struct WebPreferences {
remote_fonts_enabled(false),
xss_auditor_enabled(false),
local_storage_enabled(false),
+ databases_enabled(false),
session_storage_enabled(false),
application_cache_enabled(false),
user_style_sheet_enabled(false) {