Skip to content
Permalink
Browse files
WebCore: Adding support for the optional creation callback that could be
passed to openDatabase().

Reviewed by Adam Barth.

Test: storage/open-database-creation-callback.html

https://bugs.webkit.org/show_bug.cgi?id=34726

* Android.jscbindings.mk
* Android.v8bindings.mk
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::openDatabase):
* bindings/js/JSDatabaseCallback.cpp: Added.
(WebCore::JSDatabaseCallback::JSDatabaseCallback):
(WebCore::JSDatabaseCallback::~JSDatabaseCallback):
(WebCore::JSDatabaseCallback::handleEvent):
* bindings/js/JSDatabaseCallback.h: Added.
(WebCore::JSDatabaseCallback::create):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::openDatabaseCallback):
* bindings/v8/custom/V8DatabaseCallback.cpp: Added.
(WebCore::V8DatabaseCallback::V8DatabaseCallback):
(WebCore::V8DatabaseCallback::~V8DatabaseCallback):
(WebCore::V8DatabaseCallback::handleEvent):
* bindings/v8/custom/V8DatabaseCallback.h: Added.
(WebCore::V8DatabaseCallback::create):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::openDatabase):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* storage/Database.cpp:
(WebCore::DatabaseCreationCallbackTask::create):
(WebCore::DatabaseCreationCallbackTask::performTask):
(WebCore::DatabaseCreationCallbackTask::DatabaseCreationCallbackTask):
(WebCore::Database::openDatabase):
(WebCore::Database::Database):
(WebCore::Database::performOpenAndVerify):
(WebCore::Database::performCreationCallback):
* storage/Database.h:
(WebCore::Database::isNew):
* storage/DatabaseCallback.h: Added.
(WebCore::DatabaseCallback::~DatabaseCallback):
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::openDatabase):
* workers/WorkerContext.h:

LayoutTests: Adding a test to test the creation callback passed to
openDatabase() and another one to make sure it is executed in the
correct world.

Reviewed by Adam Barth.

Also, fixing fast/frames/sandboxed-iframe-storage.html: calling
openDatabase() without at least 4 parameters should always fail,
because the database name, version, description and estimated size
are not optional according to the spec.

https://bugs.webkit.org/show_bug.cgi?id=34726

* fast/frames/resources/sandboxed-iframe-storage-allowed.html:
* fast/frames/resources/sandboxed-iframe-storage-disallowed.html:
* fast/frames/sandboxed-iframe-storage-expected.txt:
* platform/qt/Skipped:
* storage/open-database-creation-callback-expected.txt: Added.
* storage/open-database-creation-callback.html: Added.
* storage/open-database-creation-callback-isolated-world-expected.txt: Added.
* storage/open-database-creation-callback-isolated-world.html: Added.



Canonical link: https://commits.webkit.org/46890@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55593 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Dumitru Daniliuc committed Mar 5, 2010
1 parent 5d26777 commit 52ffa8bee4b630966de6adfcdd62bbb8b8c3ab2d
Showing 32 changed files with 721 additions and 24 deletions.
@@ -1,3 +1,27 @@
2010-03-04 Dumitru Daniliuc <dumi@chromium.org>

Reviewed by Adam Barth.

Adding a test to test the creation callback passed to
openDatabase() and another one to make sure it is executed in the
correct world.

Also, fixing fast/frames/sandboxed-iframe-storage.html: calling
openDatabase() without at least 4 parameters should always fail,
because the database name, version, description and estimated size
are not optional according to the spec.

https://bugs.webkit.org/show_bug.cgi?id=34726

* fast/frames/resources/sandboxed-iframe-storage-allowed.html:
* fast/frames/resources/sandboxed-iframe-storage-disallowed.html:
* fast/frames/sandboxed-iframe-storage-expected.txt:
* platform/qt/Skipped:
* storage/open-database-creation-callback-expected.txt: Added.
* storage/open-database-creation-callback.html: Added.
* storage/open-database-creation-callback-isolated-world-expected.txt: Added.
* storage/open-database-creation-callback-isolated-world.html: Added.

2010-03-05 Brian Weinstein <bweinstein@apple.com>

Update getComputedStyle results on Windows.
@@ -6,7 +6,7 @@
<script>

window.onload = function() {
shouldBeTrue("window.openDatabase() != null");
shouldBeTrue("window.openDatabase('SandboxedIframeStorageAllowed', '1.0', '', 1) != null");
shouldBeTrue("window.localStorage != null");
shouldBeTrue("window.sessionStorage != null");
}
@@ -6,7 +6,7 @@
<script>

window.onload = function() {
shouldBeTrue("window.openDatabase() == null");
shouldBeTrue("window.openDatabase('SandboxedIframeStorageDisallowed', '1.0', '', 1) == null");
shouldBeTrue("window.localStorage == null");
shouldBeTrue("window.sessionStorage == null");
}
@@ -14,15 +14,15 @@ TEST COMPLETE
--------
Frame: '<!--framePath //<!--frame0-->-->'
--------
PASS window.openDatabase() == null is true
PASS window.openDatabase('SandboxedIframeStorageDisallowed', '1.0', '', 1) == null is true
PASS window.localStorage == null is true
PASS window.sessionStorage == null is true


--------
Frame: '<!--framePath //<!--frame1-->-->'
--------
PASS window.openDatabase() != null is true
PASS window.openDatabase('SandboxedIframeStorageAllowed', '1.0', '', 1) != null is true
PASS window.localStorage != null is true
PASS window.sessionStorage != null is true

@@ -5095,3 +5095,6 @@ java
# see https://bugs.webkit.org/show_bug.cgi?id=33180.
# Core functionality is tested in plugins/private-browsing-mode-2.html
plugins/private-browsing-mode.html

# Qt's DRT doesn't not seem to support the layoutTestController.evaluateScriptInIsolatedWorld() call.
storage/open-database-creation-callback-isolated-world.html
@@ -0,0 +1,2 @@
This test tests openDatabase()'s creation callback.

@@ -0,0 +1,3 @@
ALERT: undefined
This test tests that the openDatabase() creation callback is called in the right world.

@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<body>
This test tests that the openDatabase() creation callback is called in the right world.
<div id="console"></div>
<script>
function done()
{
if (window.layoutTestController)
layoutTestController.notifyDone();
}

function creationCallback(db)
{
alert("FAIL: Visible in isolated world.");
done();
}

document.body.foo = "FAIL: document.body.foo visible in isolated world.";

if (window.layoutTestController) {
layoutTestController.clearAllDatabases();
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
layoutTestController.evaluateScriptInIsolatedWorld(
0,
"function creationCallback(db)\n" +
"{\n" +
" alert(document.body.foo);\n" +
" window.location='javascript:done()';\n" +
"}\n" +
"var db = openDatabase('OpenDatabaseCreationCallbackIsolatedWorld', '1.0', '', 1, creationCallback);");
}
</script>
</body>
</html>
@@ -0,0 +1,90 @@
<html>
<head>
<script>
function log(message)
{
document.getElementById("console").innerHTML += message + "<br>";
}

function finishTest()
{
if (window.layoutTestController)
layoutTestController.notifyDone();
}

function runTest()
{
if (window.layoutTestController) {
layoutTestController.clearAllDatabases();
layoutTestController.setDatabaseQuota(32768);
layoutTestController.dumpDatabaseCallbacks();
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}

var transactionsRun = 0;

// Open a new database with a creation callback, and make sure the creation callback is queued
var creationCallbackCalled1 = false;
var db1 = openDatabase("OpenDatabaseCreationCallback1", "1.0", "", 1,
function(db) {
creationCallbackCalled1 = true;
if (db.version != "") {
log("Creation callback was called with a database with version " +
db.version + "; empty string expected.");
finishTest();
}
});

// Putting this code inside a transaction on 'db1' makes sure that it is executed after
// the creation callback is.
db1.transaction(function(tx) {
if (!creationCallbackCalled1) {
log("Creation callback for db1 was not called.");
finishTest();
}
if (++transactionsRun == 2)
finishTest();
});

// Try to open another handle to the same database.
// Since the version of this database is "" (empty string), openDatabase() should return
// a null handle and throw a INVALID_STATE_ERR exception.
var db1Fail = null;
try {
db1Fail = openDatabase("OpenDatabaseCreationCallback1", "1.0", "", 1);
log("This statement should not have been executed; an INVALID_STATE_ERR exception should've been thrown.");
finishTest();
} catch(err) {
if (db1Fail) {
log("db1Fail should have been null.");
finishTest();
}
}

// Open a handle to another database, first without a creation callback, then with one.
// Make sure the creation callback is not called.
var creationCallbackCalled2 = false;
var db2 = openDatabase("OpenDatabaseCreationCallback2", "1.0", "", 1);
db2 = openDatabase("OpenDatabaseCreationCallback2", "1.0", "", 1,
function(db) { creationCallbackCalled2 = true; });
db2.transaction(function(tx) {
if (creationCallbackCalled2) {
log("Creation callback for db2 should not have been called.");
finishTest();
}
if (++transactionsRun == 2)
finishTest();
});
}

</script>
</head>

<body onload="runTest()">
This test tests openDatabase()'s creation callback.
<pre id="console">
</pre>
</body>

</html>
@@ -80,6 +80,7 @@ LOCAL_SRC_FILES += \
bindings/js/JSCustomSQLTransactionCallback.cpp \
bindings/js/JSCustomSQLTransactionErrorCallback.cpp \
bindings/js/JSCustomVoidCallback.cpp \
bindings/js/JSDatabaseCallback.cpp \
bindings/js/JSDesktopNotificationsCustom.cpp \
bindings/js/JSDOMApplicationCacheCustom.cpp \
bindings/js/JSDOMBinding.cpp \
@@ -108,6 +108,7 @@ LOCAL_SRC_FILES += \
bindings/v8/custom/V8DOMSelectionCustom.cpp \
bindings/v8/custom/V8DOMWindowCustom.cpp \
bindings/v8/custom/V8DataGridColumnListCustom.cpp \
bindings/v8/custom/V8DatabaseCallback.cpp \
bindings/v8/custom/V8DatabaseCustom.cpp \
bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp \
bindings/v8/custom/V8DocumentCustom.cpp \
@@ -1,3 +1,57 @@
2010-03-04 Dumitru Daniliuc <dumi@chromium.org>

Reviewed by Adam Barth.

Adding support for the optional creation callback that could be
passed to openDatabase().

Test: storage/open-database-creation-callback.html

https://bugs.webkit.org/show_bug.cgi?id=34726

* Android.jscbindings.mk
* Android.v8bindings.mk
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::openDatabase):
* bindings/js/JSDatabaseCallback.cpp: Added.
(WebCore::JSDatabaseCallback::JSDatabaseCallback):
(WebCore::JSDatabaseCallback::~JSDatabaseCallback):
(WebCore::JSDatabaseCallback::handleEvent):
* bindings/js/JSDatabaseCallback.h: Added.
(WebCore::JSDatabaseCallback::create):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::openDatabaseCallback):
* bindings/v8/custom/V8DatabaseCallback.cpp: Added.
(WebCore::V8DatabaseCallback::V8DatabaseCallback):
(WebCore::V8DatabaseCallback::~V8DatabaseCallback):
(WebCore::V8DatabaseCallback::handleEvent):
* bindings/v8/custom/V8DatabaseCallback.h: Added.
(WebCore::V8DatabaseCallback::create):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::openDatabase):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* storage/Database.cpp:
(WebCore::DatabaseCreationCallbackTask::create):
(WebCore::DatabaseCreationCallbackTask::performTask):
(WebCore::DatabaseCreationCallbackTask::DatabaseCreationCallbackTask):
(WebCore::Database::openDatabase):
(WebCore::Database::Database):
(WebCore::Database::performOpenAndVerify):
(WebCore::Database::performCreationCallback):
* storage/Database.h:
(WebCore::Database::isNew):
* storage/DatabaseCallback.h: Added.
(WebCore::DatabaseCallback::~DatabaseCallback):
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::openDatabase):
* workers/WorkerContext.h:

2010-03-05 Chris Marrin <cmarrin@apple.com>

Reviewed by Simon Fraser.
@@ -2230,6 +2230,8 @@ webcore_sources += \
WebCore/bindings/js/JSCustomSQLTransactionCallback.h \
WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp \
WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h \
WebCore/bindings/js/JSDatabaseCallback.cpp \
WebCore/bindings/js/JSDatabaseCallback.h \
WebCore/bindings/js/JSDatabaseCustom.cpp \
WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp \
WebCore/bindings/js/JSSQLTransactionCustom.cpp \
@@ -2250,6 +2252,7 @@ webcore_sources += \
WebCore/storage/Database.h \
WebCore/storage/DatabaseAuthorizer.cpp \
WebCore/storage/DatabaseAuthorizer.h \
WebCore/storage/DatabaseCallback.h \
WebCore/storage/DatabaseDetails.h \
WebCore/storage/DatabaseTask.cpp \
WebCore/storage/DatabaseTask.h \
@@ -703,6 +703,8 @@
'bindings/v8/custom/V8CustomVoidCallback.h',
'bindings/v8/custom/V8CustomXPathNSResolver.cpp',
'bindings/v8/custom/V8CustomXPathNSResolver.h',
'bindings/v8/custom/V8DatabaseCallback.cpp',
'bindings/v8/custom/V8DatabaseCallback.h',
'bindings/v8/custom/V8DatabaseCustom.cpp',
'bindings/v8/custom/V8DataGridColumnListCustom.cpp',
'bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp',
@@ -3221,6 +3223,7 @@
'storage/Database.h',
'storage/DatabaseAuthorizer.cpp',
'storage/DatabaseAuthorizer.h',
'storage/DatabaseCallback.h',
'storage/DatabaseDetails.h',
'storage/DatabaseTask.cpp',
'storage/DatabaseTask.h',
@@ -1012,6 +1012,7 @@ HEADERS += \
bindings/js/JSCustomSQLTransactionErrorCallback.h \
bindings/js/JSCustomVoidCallback.h \
bindings/js/JSCustomXPathNSResolver.h \
bindings/js/JSDatabaseCallback.h \
bindings/js/JSDataGridDataSource.h \
bindings/js/JSDOMBinding.h \
bindings/js/JSDOMGlobalObject.h \
@@ -2221,6 +2222,7 @@ contains(DEFINES, ENABLE_DATABASE=1) {
bindings/js/JSCustomSQLStatementErrorCallback.cpp \
bindings/js/JSCustomSQLTransactionCallback.cpp \
bindings/js/JSCustomSQLTransactionErrorCallback.cpp \
bindings/js/JSDatabaseCallback.cpp \
bindings/js/JSDatabaseCustom.cpp \
bindings/js/JSSQLResultSetRowListCustom.cpp \
bindings/js/JSSQLTransactionCustom.cpp
@@ -2231,6 +2233,7 @@ contains(DEFINES, ENABLE_DOM_STORAGE=1) {
storage/ChangeVersionWrapper.h \
storage/DatabaseAuthorizer.h \
storage/Database.h \
storage/DatabaseCallback.h \
storage/DatabaseTask.h \
storage/DatabaseThread.h \
storage/DatabaseTracker.h \
@@ -35367,6 +35367,14 @@
RelativePath="..\bindings\js\JSCustomXPathNSResolver.h"
>
</File>
<File
RelativePath="..\bindings\js\JSDatabaseCallback.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSDatabaseCallback.h"
>
</File>
<File
RelativePath="..\bindings\js\JSDatabaseCustom.cpp"
>
@@ -42288,6 +42296,10 @@
RelativePath="..\storage\DatabaseAuthorizer.h"
>
</File>
<File
RelativePath="..\storage\DatabaseCallback.h"
>
</File>
<File
RelativePath="..\storage\DatabaseTask.cpp"
>

0 comments on commit 52ffa8b

Please sign in to comment.