Changeset 59540 in webkit
- Timestamp:
- May 15, 2010 9:36:56 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 10 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r59535 r59540 1 2010-05-15 Eric Uhrhane <ericu@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Add bindings for async DB API in Workers. 6 https://bugs.webkit.org/show_bug.cgi?id=34992 7 8 * storage/change-version-handle-reuse.html: Refactored to share code with the worker version of the test. 9 * storage/change-version-handle-reuse-expected.html: Removed reference to reloading, which this test doesn't do. 10 * storage/change-version-handle-reuse.js: This is the extracted shared core of the test. 11 * storage/execute-sql-args.html: Refactored to share code with the worker version of the test. 12 * storage/execute-sql-args.js: This is the extracted shared core of the test. 13 14 These are the worker versions of the tests; they're tiny shims around shared code. 15 * fast/workers/storage/execute-sql-args-worker-expected.txt: Added. 16 * fast/workers/storage/execute-sql-args-worker.html: Added. 17 * fast/workers/storage/change-version-handle-reuse-worker-expected.txt: Added. 18 * fast/workers/storage/change-version-handle-reuse-worker.html: Added. 19 This file gets included from worker database tests; it does all the boilerplate that's needed on the DOM side. 20 * fast/workers/storage/resources/database-worker-controller.js: Added. 21 This file is the boilerplate for the worker side of the database tests. It will import and run the actual test on command, and will report back completion and exceptions. 22 * fast/workers/storage/resources/database-worker.js: Added. 23 1 24 2010-05-15 Xan Lopez <xlopez@igalia.com> 2 25 -
trunk/LayoutTests/fast/workers/storage/change-version-handle-reuse-worker-expected.txt
r59539 r59540 1 This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions. Also, reloading the page should not cause an assertion failure.1 This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions. 2 2 changeVersion: transaction callback 3 3 changeVersion: success callback -
trunk/LayoutTests/storage/change-version-handle-reuse-expected.txt
r58597 r59540 1 This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions. Also, reloading the page should not cause an assertion failure.1 This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions. 2 2 changeVersion: transaction callback 3 3 changeVersion: success callback -
trunk/LayoutTests/storage/change-version-handle-reuse.html
r58597 r59540 1 1 <html> 2 2 <head> 3 <script src="change-version-handle-reuse.js"></script> 3 4 <script> 5 6 var DB_TEST_SUFFIX = "_dom"; 7 4 8 function log(message) 5 9 { 6 document.getElementById(" result").innerText += message + "\n";10 document.getElementById("console").innerText += message + "\n"; 7 11 } 8 12 9 function finishTest() 10 { 11 log("TEST COMPLETE."); 12 13 if (window.layoutTestController) 14 layoutTestController.notifyDone(); 15 } 16 17 function runTest() 13 function setupAndRunTest() 18 14 { 19 15 if (window.layoutTestController) { … … 22 18 } 23 19 24 document.getElementById(" result").innerText = "";20 document.getElementById("console").innerText = ""; 25 21 26 try { 27 db = openDatabase("ChangeVersion", "", "Test that changing a database version doesn\'t kill our handle to it", 1); 28 var version = db.version; 29 var newVersion = version ? (parseInt(version) + 1).toString() : "1"; 30 db.changeVersion(version, newVersion, function(tx) { 31 log("changeVersion: transaction callback"); 32 }, function(error) { 33 log("changeVersion: error callback: " + error.message); 34 }, function() { 35 log("changeVersion: success callback"); 36 }); 37 38 setTimeout(runTest2, 1000); 39 40 } catch (e) { 41 log("changeVersion exception: " + e); 42 finishTest(); 43 } 44 } 45 46 function runTest2() 47 { 48 try { 49 db.transaction(function(tx) { 50 tx.executeSql("SELECT * from FooBar", [], function(tx) { 51 log("transaction: statement callback"); 52 finishTest(); 53 }, function(tx, error) { 54 log("transaction: statement error callback: " + error.message); 55 finishTest(); 56 }); 57 }); 58 } catch (e) { 59 log("transaction exception: " + e); 60 finishTest(); 61 } 22 runTest(); 62 23 } 63 24 </script> 64 25 </head> 65 <body onload=" runTest()">66 <div>This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions. Also, reloading the page should not cause an assertion failure.67 <pre id=" result">26 <body onload="setupAndRunTest()"> 27 <div>This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions. 28 <pre id="console"> 68 29 FAILURE: test didn't run. 69 30 </pre> -
trunk/LayoutTests/storage/change-version-handle-reuse.js
r59539 r59540 1 <html>2 <head>3 <script>4 function log(message)5 {6 document.getElementById("result").innerText += message + "\n";7 }8 9 1 function finishTest() 10 2 { … … 17 9 function runTest() 18 10 { 19 if (window.layoutTestController) {20 layoutTestController.waitUntilDone();21 layoutTestController.dumpAsText();22 }23 24 document.getElementById("result").innerText = "";25 26 11 try { 27 db = openDatabase("ChangeVersion" , "", "Test that changing a database version doesn\'t kill our handle to it", 1);12 db = openDatabase("ChangeVersion" + DB_TEST_SUFFIX, "", "Test that changing a database version doesn't kill our handle to it", 1); 28 13 var version = db.version; 29 14 var newVersion = version ? (parseInt(version) + 1).toString() : "1"; … … 34 19 }, function() { 35 20 log("changeVersion: success callback"); 21 runTest2(); 36 22 }); 37 38 setTimeout(runTest2, 1000);39 23 40 24 } catch (e) { … … 61 45 } 62 46 } 63 </script>64 </head>65 <body onload="runTest()">66 <div>This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions. Also, reloading the page should not cause an assertion failure.67 <pre id="result">68 FAILURE: test didn't run.69 </pre>70 </body>71 </html> -
trunk/LayoutTests/storage/execute-sql-args.html
r58597 r59540 2 2 3 3 <head> 4 <script src="execute-sql-args.js"></script> 4 5 <script> 5 6 6 var throwOnToStringObject = { }; 7 throwOnToStringObject.toString = function () { throw "Cannot call toString on this object." }; 7 var DB_TEST_SUFFIX = "_dom"; 8 8 9 var throwOnGetLengthObject = { }; 10 throwOnGetLengthObject.__defineGetter__("length", function () { throw "Cannot get length of this object."; }); 11 12 var throwOnGetZeroObject = { length: 1 }; 13 throwOnGetZeroObject.__defineGetter__("0", function () { throw "Cannot get 0 property of this object."; }); 14 15 var expectNoException = [ 16 'null', 17 'undefined', 18 '0', 19 '""', 20 '"", null', 21 '"", undefined', 22 '"", []', 23 '"", [ "arg0" ]', 24 '"", { }', 25 '"", { length: 0 }', 26 '"", { length: 1, 0: "arg0" }', 27 '"", null, null', 28 '"", null, undefined', 29 '"", null, { }', 30 '"", null, null, null', 31 '"", null, null, undefined', 32 '"", null, null, { }', 33 ]; 34 35 var expectException = [ 36 '', 37 'throwOnToStringObject', 38 '"", throwOnGetLengthObject', 39 '"", throwOnGetZeroObject', 40 '"", [ throwOnToStringObject ]', 41 '"", 0', 42 '"", ""', 43 '"", null, 0', 44 '"", null, ""', 45 '"", null, null, 0', 46 '"", null, null, ""', 47 ]; 48 49 function writeMessageToLog(message) 9 function log(message) 50 10 { 51 11 document.getElementById("console").innerText += message + "\n"; 52 12 } 53 13 54 function tryExecuteSql(transaction, parameterList) 55 { 56 try { 57 eval('transaction.executeSql(' + parameterList + ')'); 58 return null; 59 } catch (exception) { 60 return exception; 61 } 62 } 63 64 function runTransactionTest(transaction, parameterList, expectException) 65 { 66 var exception = tryExecuteSql(transaction, parameterList); 67 if (expectException) { 68 if (exception) 69 writeMessageToLog("PASS. executeSql(" + parameterList + ") threw an exception as expected."); 70 else 71 writeMessageToLog("*FAIL*. executeSql(" + parameterList + ") did not throw an exception"); 72 } else { 73 if (exception) 74 writeMessageToLog("*FAIL*. executeSql(" + parameterList + ") threw an exception: " + exception); 75 else 76 writeMessageToLog("PASS. executeSql(" + parameterList + ") did not throw an exception"); 77 } 78 } 79 80 function runTransactionTests(transaction) 81 { 82 for (i in expectNoException) 83 runTransactionTest(transaction, expectNoException[i], false); 84 for (i in expectException) 85 runTransactionTest(transaction, expectException[i], true); 86 87 if (window.layoutTestController) 88 layoutTestController.notifyDone(); 89 } 90 91 function runTest() 14 function setupAndRunTest() 92 15 { 93 16 if (window.layoutTestController) { … … 95 18 layoutTestController.waitUntilDone(); 96 19 } 97 98 var db = openDatabase("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1); 99 db.transaction(runTransactionTests); 20 runTest(); 100 21 } 101 22 … … 103 24 </head> 104 25 105 <body onload=" runTest()">26 <body onload="setupAndRunTest()"> 106 27 <pre id="console"></pre> 107 28 </body> -
trunk/LayoutTests/storage/execute-sql-args.js
r59539 r59540 1 <html>2 3 <head>4 <script>5 6 1 var throwOnToStringObject = { }; 7 2 throwOnToStringObject.toString = function () { throw "Cannot call toString on this object." }; … … 47 42 ]; 48 43 49 function writeMessageToLog(message)50 {51 document.getElementById("console").innerText += message + "\n";52 }53 54 44 function tryExecuteSql(transaction, parameterList) 55 45 { … … 67 57 if (expectException) { 68 58 if (exception) 69 writeMessageToLog("PASS. executeSql(" + parameterList + ") threw an exception as expected.");59 log("PASS. executeSql(" + parameterList + ") threw an exception as expected."); 70 60 else 71 writeMessageToLog("*FAIL*. executeSql(" + parameterList + ") did not throw an exception");61 log("*FAIL*. executeSql(" + parameterList + ") did not throw an exception"); 72 62 } else { 73 63 if (exception) 74 writeMessageToLog("*FAIL*. executeSql(" + parameterList + ") threw an exception: " + exception);64 log("*FAIL*. executeSql(" + parameterList + ") threw an exception: " + exception); 75 65 else 76 writeMessageToLog("PASS. executeSql(" + parameterList + ") did not throw an exception");66 log("PASS. executeSql(" + parameterList + ") did not throw an exception"); 77 67 } 78 68 } … … 91 81 function runTest() 92 82 { 93 if (window.layoutTestController) {94 layoutTestController.dumpAsText();95 layoutTestController.waitUntilDone();96 }97 83 98 var db = openDatabase("ExecuteSQLArgsTest" , "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);84 var db = openDatabase("ExecuteSQLArgsTest" + DB_TEST_SUFFIX, "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1); 99 85 db.transaction(runTransactionTests); 100 86 } 101 102 </script>103 </head>104 105 <body onload="runTest()">106 <pre id="console"></pre>107 </body>108 109 </html> -
trunk/WebCore/ChangeLog
r59537 r59540 1 2010-05-15 Eric Uhrhane <ericu@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Add bindings for async DB API in Workers. 6 https://bugs.webkit.org/show_bug.cgi?id=34992 7 8 Tests: storage/change-version-handle-reuse-worker.html 9 storage/execute-sql-args-worker.html 10 11 * bindings/js/JSWorkerContextCustom.cpp: Add openDatabase binding. 12 (WebCore::JSWorkerContext::openDatabase): 13 14 * bindings/v8/custom/V8WorkerContextCustom.cpp: Add openDatabase stub; Chromium will need work both in V8 and in the browser process before we can turn this on there. 15 (WebCore::V8WorkerContext::openDatabaseCallback): 16 17 Add NoStaticTables flags to all objects now shared with workers. 18 * storage/Database.idl: 19 * storage/SQLError.idl: 20 * storage/SQLResultSet.idl: 21 * storage/SQLResultSetRowList.idl: 22 * storage/SQLTransaction.idl: 23 24 * workers/WorkerContext.h: Add databaseExceededQuota. 25 * workers/WorkerContext.cpp: 26 (WebCore::WorkerContext::databaseExceededQuota): Add stub implementation for testing; you just get 5MB for now. 27 (WebCore::WorkerContext::openDatabase): Remove invalid assertion. 28 29 Add the IDL for the call to openDatabase. 30 * workers/WorkerContext.idl: 31 1 32 2010-05-15 Leandro Pereira <leandro@profusion.mobi> 2 33 -
trunk/WebCore/bindings/js/JSWorkerContextCustom.cpp
r59113 r59540 31 31 32 32 #if ENABLE(DATABASE) 33 #include "Database.h" 34 #include "JSDatabase.h" 33 35 #include "JSDatabaseCallback.h" 34 36 #include "JSDatabaseSync.h" … … 148 150 149 151 #if ENABLE(DATABASE) 150 JSValue JSWorkerContext::openDatabase Sync(ExecState* exec, const ArgList& args)151 { 152 JSValue JSWorkerContext::openDatabase(ExecState* exec, const ArgList& args) 153 { 152 154 if (args.size() < 4) { 153 155 setDOMException(exec, SYNTAX_ERR); … … 181 183 creationCallback = JSDatabaseCallback::create(asObject(args.at(4)), globalObject()); 182 184 } 185 186 ExceptionCode ec = 0; 187 JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec))); 188 setDOMException(exec, ec); 189 return result; 190 } 191 192 JSValue JSWorkerContext::openDatabaseSync(ExecState* exec, const ArgList& args) 193 { 194 if (args.size() < 4) { 195 setDOMException(exec, SYNTAX_ERR); 196 return jsUndefined(); 197 } 198 199 String name = ustringToString(args.at(0).toString(exec)); 200 if (exec->hadException()) 201 return jsUndefined(); 202 203 String version = ustringToString(args.at(1).toString(exec)); 204 if (exec->hadException()) 205 return jsUndefined(); 206 207 String displayName = ustringToString(args.at(2).toString(exec)); 208 if (exec->hadException()) 209 return jsUndefined(); 210 211 // args.at(3) = estimated size 212 unsigned long estimatedSize = args.at(3).toUInt32(exec); 213 if (exec->hadException()) 214 return jsUndefined(); 215 216 RefPtr<DatabaseCallback> creationCallback; 217 if (args.size() >= 5) { 218 if (!args.at(4).isObject()) { 219 setDOMException(exec, TYPE_MISMATCH_ERR); 220 return jsUndefined(); 221 } 222 223 creationCallback = JSDatabaseCallback::create(asObject(args.at(4)), globalObject()); 224 } 183 225 184 226 ExceptionCode ec = 0; -
trunk/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp
r59096 r59540 35 35 36 36 #if ENABLE(DATABASE) 37 #include "V8Database.h" 37 38 #include "V8DatabaseCallback.h" 38 39 #include "V8DatabaseSync.h" … … 143 144 144 145 #if ENABLE(DATABASE) 146 v8::Handle<v8::Value> V8WorkerContext::openDatabaseCallback(const v8::Arguments& args) 147 { 148 INC_STATS("DOM.WorkerContext.openDatabase()"); 149 // Implementation coming soon. 150 return throwError(NOT_SUPPORTED_ERR); 151 } 152 145 153 v8::Handle<v8::Value> V8WorkerContext::openDatabaseSyncCallback(const v8::Arguments& args) 146 154 { -
trunk/WebCore/workers/WorkerContext.cpp
r58989 r59540 33 33 34 34 #include "ActiveDOMObject.h" 35 #include "DatabaseTracker.h" 35 36 #include "DOMTimer.h" 36 37 #include "DOMWindow.h" … … 271 272 PassRefPtr<Database> WorkerContext::openDatabase(const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec) 272 273 { 274 if (!securityOrigin()->canAccessDatabase() || !Database::isAvailable()) { 275 ec = SECURITY_ERR; 276 return 0; 277 } 278 279 return Database::openDatabase(this, name, version, displayName, estimatedSize, creationCallback, ec); 280 } 281 282 void WorkerContext::databaseExceededQuota(const String&) 283 { 284 #if !PLATFORM(CHROMIUM) 285 // FIXME: This needs a real implementation; this is a temporary solution for testing. 286 const unsigned long long defaultQuota = 5 * 1024 * 1024; 287 DatabaseTracker::tracker().setQuota(securityOrigin(), defaultQuota); 288 #endif 289 } 290 291 PassRefPtr<DatabaseSync> WorkerContext::openDatabaseSync(const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec) 292 { 273 293 if (!securityOrigin()->canAccessDatabase()) { 274 294 ec = SECURITY_ERR; … … 276 296 } 277 297 278 ASSERT(Database::isAvailable());279 if (!Database::isAvailable())280 return 0;281 282 return Database::openDatabase(this, name, version, displayName, estimatedSize, creationCallback, ec);283 }284 285 PassRefPtr<DatabaseSync> WorkerContext::openDatabaseSync(const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec)286 {287 if (!securityOrigin()->canAccessDatabase()) {288 ec = SECURITY_ERR;289 return 0;290 }291 292 298 ASSERT(DatabaseSync::isAvailable()); 293 299 if (!DatabaseSync::isAvailable()) -
trunk/WebCore/workers/WorkerContext.h
r58989 r59540 111 111 // Not implemented yet. 112 112 virtual bool isDatabaseReadOnly() const { return false; } 113 // Not implemented yet.114 virtual void databaseExceededQuota(const String&) { }113 // Not implemented for real yet. 114 virtual void databaseExceededQuota(const String&); 115 115 #endif 116 116 virtual bool isContextThread() const; -
trunk/WebCore/workers/WorkerContext.idl
r58989 r59540 50 50 [Custom] void importScripts(/*[Variadic] in DOMString urls */); 51 51 attribute [Replaceable] WorkerNavigator navigator; 52 53 52 #if defined(ENABLE_DATABASE) && ENABLE_DATABASE 54 // Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize); 55 [EnableAtRuntime, Custom] DatabaseSync openDatabaseSync(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in DatabaseCallback creationCallback); 53 [EnabledAtRuntime, Custom] Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in DatabaseCallback creationCallback) 54 raises(DOMException); 55 [EnabledAtRuntime, Custom] DatabaseSync openDatabaseSync(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in DatabaseCallback creationCallback); 56 56 #endif 57 57
Note: See TracChangeset
for help on using the changeset viewer.