Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This test tests openDatabase()'s creation callback. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALERT: undefined | ||
This test tests that the openDatabase() creation callback is called in the right world. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.