[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
jorlow at chromium.org
jorlow at chromium.org
Sun Feb 20 22:51:11 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit d189d2c53180a3a91dc9a0848c88423894864a32
Author: jorlow at chromium.org <jorlow at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 12 10:40:39 2011 +0000
2011-01-11 Jeremy Orlow <jorlow at chromium.org>
Reviewed by Nate Chapin.
Enforce READ_ONLY transactions in IndexedDB
https://bugs.webkit.org/show_bug.cgi?id=52229
Fix existing errors in tests + add a new test for
this issue.
* storage/indexeddb/cursor-delete-expected.txt:
* storage/indexeddb/cursor-delete.html:
* storage/indexeddb/cursor-index-delete-expected.txt:
* storage/indexeddb/cursor-index-delete.html:
* storage/indexeddb/database-quota-expected.txt:
* storage/indexeddb/database-quota.html:
* storage/indexeddb/objectstore-basics-expected.txt:
* storage/indexeddb/objectstore-basics.html:
* storage/indexeddb/objectstore-removeobjectstore-expected.txt:
* storage/indexeddb/objectstore-removeobjectstore.html:
* storage/indexeddb/transaction-basics-expected.txt:
* storage/indexeddb/transaction-basics.html:
* storage/indexeddb/transaction-crash-on-abort-expected.txt:
* storage/indexeddb/transaction-crash-on-abort.html:
* storage/indexeddb/transaction-read-only.html: Added.
2011-01-11 Jeremy Orlow <jorlow at chromium.org>
Reviewed by Nate Chapin.
Enforce READ_ONLY transactions in IndexedDB
https://bugs.webkit.org/show_bug.cgi?id=52229
Add READ_ONLY_ERR and return it whenever delete or put
are called. Note that IDBCursor's delete and update
are simply aliases for delete/put, which is why no
extra code is required to handle those cases.
Test: storage/indexeddb/transaction-read-only.html
* dom/ExceptionCode.cpp:
* storage/IDBCursorBackendImpl.cpp:
(WebCore::IDBCursorBackendImpl::deleteFunction):
* storage/IDBDatabase.idl:
* storage/IDBDatabaseException.h:
* storage/IDBDatabaseException.idl:
* storage/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::put):
(WebCore::IDBObjectStoreBackendImpl::deleteFunction):
(WebCore::IDBObjectStoreBackendImpl::deleteIndex):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75596 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6996754..3a0670a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,29 @@
+2011-01-11 Jeremy Orlow <jorlow at chromium.org>
+
+ Reviewed by Nate Chapin.
+
+ Enforce READ_ONLY transactions in IndexedDB
+ https://bugs.webkit.org/show_bug.cgi?id=52229
+
+ Fix existing errors in tests + add a new test for
+ this issue.
+
+ * storage/indexeddb/cursor-delete-expected.txt:
+ * storage/indexeddb/cursor-delete.html:
+ * storage/indexeddb/cursor-index-delete-expected.txt:
+ * storage/indexeddb/cursor-index-delete.html:
+ * storage/indexeddb/database-quota-expected.txt:
+ * storage/indexeddb/database-quota.html:
+ * storage/indexeddb/objectstore-basics-expected.txt:
+ * storage/indexeddb/objectstore-basics.html:
+ * storage/indexeddb/objectstore-removeobjectstore-expected.txt:
+ * storage/indexeddb/objectstore-removeobjectstore.html:
+ * storage/indexeddb/transaction-basics-expected.txt:
+ * storage/indexeddb/transaction-basics.html:
+ * storage/indexeddb/transaction-crash-on-abort-expected.txt:
+ * storage/indexeddb/transaction-crash-on-abort.html:
+ * storage/indexeddb/transaction-read-only.html: Added.
+
2011-01-11 Maciej Stachowiak <mjs at apple.com>
Reviewed by David Levin.
diff --git a/LayoutTests/storage/indexeddb/cursor-delete-expected.txt b/LayoutTests/storage/indexeddb/cursor-delete-expected.txt
index 1fdf9ed..8d1bba2 100644
--- a/LayoutTests/storage/indexeddb/cursor-delete-expected.txt
+++ b/LayoutTests/storage/indexeddb/cursor-delete-expected.txt
@@ -48,7 +48,7 @@ objectStore.add('myValue2', 'myKey2')
objectStore.add('myValue3', 'myKey3')
objectStore.add('myValue4', 'myKey4')
openCursor1
-trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)
+trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})
trans.objectStore('test').openCursor({range: keyRange})
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
@@ -85,9 +85,8 @@ PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
-WARN: shouldBe() expects string arguments
-PASS null is null
-trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)
+PASS event.result is null
+trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})
objectStore = trans.objectStore('test')
objectStore.add('myValue1', 'myKey1')
PASS 'onsuccess' in result is true
diff --git a/LayoutTests/storage/indexeddb/cursor-delete.html b/LayoutTests/storage/indexeddb/cursor-delete.html
index ce62d6a..9e1ddc3 100644
--- a/LayoutTests/storage/indexeddb/cursor-delete.html
+++ b/LayoutTests/storage/indexeddb/cursor-delete.html
@@ -59,7 +59,7 @@ function createAndPopulateObjectStore()
function openCursor()
{
debug("openCursor1");
- evalAndLog("trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)");
+ evalAndLog("trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})");
keyRange = webkitIDBKeyRange.lowerBound("myKey1");
result = evalAndLog("trans.objectStore('test').openCursor({range: keyRange})");
verifyResult(result);
@@ -86,13 +86,13 @@ function cursorSuccess()
function cursorEmpty()
{
verifySuccessEvent(event);
- shouldBeNull(event.result);
+ shouldBeNull("event.result");
trans.oncomplete = addObject;
}
function addObject()
{
- evalAndLog("trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)");
+ evalAndLog("trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})");
objectStore = evalAndLog("objectStore = trans.objectStore('test')");
result = evalAndLog("objectStore.add('myValue1', 'myKey1')");
verifyResult(result);
diff --git a/LayoutTests/storage/indexeddb/cursor-index-delete-expected.txt b/LayoutTests/storage/indexeddb/cursor-index-delete-expected.txt
index 4598556..27f3117 100644
--- a/LayoutTests/storage/indexeddb/cursor-index-delete-expected.txt
+++ b/LayoutTests/storage/indexeddb/cursor-index-delete-expected.txt
@@ -49,7 +49,7 @@ objectStore.add({x: 2}, 'myKey2')
objectStore.add({x: 3}, 'myKey3')
objectStore.add({x: 4}, 'myKey4')
openCursor1
-trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)
+trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})
trans.objectStore('test').index('testIndex').openCursor({range: keyRange})
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
@@ -87,7 +87,7 @@ PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.result is null
-trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)
+trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})
objectStore = trans.objectStore('test')
objectStore.add({x: 1}, 'myKey1')
PASS 'onsuccess' in result is true
diff --git a/LayoutTests/storage/indexeddb/cursor-index-delete.html b/LayoutTests/storage/indexeddb/cursor-index-delete.html
index ea10f02..1bddf63 100644
--- a/LayoutTests/storage/indexeddb/cursor-index-delete.html
+++ b/LayoutTests/storage/indexeddb/cursor-index-delete.html
@@ -61,7 +61,7 @@ function createAndPopulateObjectStoreAndIndex()
function openCursor()
{
debug("openCursor1");
- evalAndLog("trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)");
+ evalAndLog("trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})");
keyRange = webkitIDBKeyRange.lowerBound(1);
result = evalAndLog("trans.objectStore('test').index('testIndex').openCursor({range: keyRange})");
verifyResult(result);
@@ -95,7 +95,7 @@ function cursorEmpty()
function addObject()
{
- evalAndLog("trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)");
+ evalAndLog("trans = db.transaction({objectStoreNames: 'test', mode: webkitIDBTransaction.READ_WRITE})");
objectStore = evalAndLog("objectStore = trans.objectStore('test')");
result = evalAndLog("objectStore.add({x: 1}, 'myKey1')");
verifyResult(result);
diff --git a/LayoutTests/storage/indexeddb/database-quota-expected.txt b/LayoutTests/storage/indexeddb/database-quota-expected.txt
index 3ea24d9..0f06145 100644
--- a/LayoutTests/storage/indexeddb/database-quota-expected.txt
+++ b/LayoutTests/storage/indexeddb/database-quota-expected.txt
@@ -64,7 +64,7 @@ PASS db.objectStoreNames.length is 1
PASS db.objectStoreNames.contains('') is false
PASS db.objectStoreNames.contains('test456') is false
PASS db.objectStoreNames.contains('test123') is true
-trans = db.transaction()
+trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})
Creating 'data' which contains 64K of data
PASS data.length is 65536
store = trans.objectStore('test123')
diff --git a/LayoutTests/storage/indexeddb/database-quota.html b/LayoutTests/storage/indexeddb/database-quota.html
index b4207d4..d21b051 100644
--- a/LayoutTests/storage/indexeddb/database-quota.html
+++ b/LayoutTests/storage/indexeddb/database-quota.html
@@ -53,8 +53,8 @@ function createNewObjectStore()
shouldBe("db.objectStoreNames.length", "0");
shouldBe("db.objectStoreNames.contains('')", "false");
- objectStore = evalAndLog('db.createObjectStore("test123")');
- checkObjectStore();
+ objectStore = evalAndLog('db.createObjectStore("test123")');
+ checkObjectStore();
commitAndContinue();
}
@@ -64,54 +64,54 @@ function checkObjectStore()
shouldBe("db.objectStoreNames.length", "1");
shouldBe("db.objectStoreNames.contains('')", "false");
shouldBe("db.objectStoreNames.contains('test456')", "false");
- shouldBe("db.objectStoreNames.contains('test123')", "true");
-}
-
-function commitAndContinue()
-{
+ shouldBe("db.objectStoreNames.contains('test123')", "true");
+}
+
+function commitAndContinue()
+{
window.setTimeout(checkQuotaEnforcing, 0);
-}
-
-function checkQuotaEnforcing()
-{
- var trans = evalAndLog("trans = db.transaction()");
- trans.onabort = testComplete;
- trans.oncomplete = unexpectedCompleteCallback;
- debug("Creating 'data' which contains 64K of data");
- window.data = "X";
- for (var i = 0; i < 16; i++)
- data += data;
- shouldBe("data.length", "65536");
- window.dataAdded = 0;
- window.store = evalAndLog("store = trans.objectStore('test123')");
- addData();
-}
-
-function addData()
-{
- if (dataAdded < 5 * 1024 * 1024) {
+}
+
+function checkQuotaEnforcing()
+{
+ var trans = evalAndLog("trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
+ trans.onabort = testComplete;
+ trans.oncomplete = unexpectedCompleteCallback;
+ debug("Creating 'data' which contains 64K of data");
+ window.data = "X";
+ for (var i = 0; i < 16; i++)
+ data += data;
+ shouldBe("data.length", "65536");
+ window.dataAdded = 0;
+ window.store = evalAndLog("store = trans.objectStore('test123')");
+ addData();
+}
+
+function addData()
+{
+ if (dataAdded < 5 * 1024 * 1024) {
if (dataAdded > 0)
store = event.source;
- } else {
- testFailed("added more than quota");
- done();
- return;
- }
- dataAdded += 65536;
- result = store.add({x: data}, dataAdded);
- result.onsuccess = addData;
- result.onerror = logError;
-}
-
-function logError()
-{
- debug("Error function called: (" + event.code + ") " + event.message);
- verifyErrorEvent(event);
-}
-
-function testComplete()
-{
- testPassed("Adding data failed due to quota error. Data added was about " + Math.round(dataAdded / 1024 / 1024) + " MB");
+ } else {
+ testFailed("added more than quota");
+ done();
+ return;
+ }
+ dataAdded += 65536;
+ result = store.add({x: data}, dataAdded);
+ result.onsuccess = addData;
+ result.onerror = logError;
+}
+
+function logError()
+{
+ debug("Error function called: (" + event.code + ") " + event.message);
+ verifyErrorEvent(event);
+}
+
+function testComplete()
+{
+ testPassed("Adding data failed due to quota error. Data added was about " + Math.round(dataAdded / 1024 / 1024) + " MB");
done();
}
diff --git a/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt b/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt
index 6e74165..b842dcc 100644
--- a/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt
+++ b/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt
@@ -95,7 +95,7 @@ PASS store.indexNames[1] is null
PASS store.indexNames[100] is null
PASS store.indexNames.item(1) is null
PASS store.indexNames.item(100) is null
-transaction = db.transaction()
+transaction = db.transaction({mode: webkitIDBTransaction.READ_WRITE})
store = transaction.objectStore('storeName')
Try to insert data with a Date key:
store.add({x: 'foo'}, testDate)
@@ -137,7 +137,7 @@ PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.code is webkitIDBDatabaseException.UNKNOWN_ERR
-db.transaction()
+db.transaction({mode: webkitIDBTransaction.READ_WRITE})
store = transaction.objectStore('storeName')
store.add({x: 'othervalue'}, null)
PASS 'onsuccess' in result is true
@@ -158,7 +158,7 @@ PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.code is webkitIDBDatabaseException.DATA_ERR
-db.transaction()
+db.transaction({mode: webkitIDBTransaction.READ_WRITE})
store = transaction.objectStore('storeName')
store.add({x: null}, 'validkey')
PASS 'onsuccess' in result is true
@@ -179,7 +179,7 @@ PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.code is webkitIDBDatabaseException.DATA_ERR
-db.transaction()
+db.transaction({mode: webkitIDBTransaction.READ_WRITE})
store = transaction.objectStore('storeName')
store.get('key')
PASS 'onsuccess' in result is true
diff --git a/LayoutTests/storage/indexeddb/objectstore-basics.html b/LayoutTests/storage/indexeddb/objectstore-basics.html
index 144e296..d388aa0 100644
--- a/LayoutTests/storage/indexeddb/objectstore-basics.html
+++ b/LayoutTests/storage/indexeddb/objectstore-basics.html
@@ -141,7 +141,7 @@ var testDateB = new Date("Wed Jan 05 2011 15:54:49");
function addData()
{
- var transaction = evalAndLog("transaction = db.transaction()");
+ var transaction = evalAndLog("transaction = db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
transaction.onabort = unexpectedAbortCallback;
window.store = evalAndLog("store = transaction.objectStore('storeName')");
@@ -189,7 +189,7 @@ function addAgainFailure()
// FIXME: This error code needs to be specced.
shouldBe("event.code", "webkitIDBDatabaseException.UNKNOWN_ERR");
- transaction = evalAndLog("db.transaction()");
+ transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
transaction.onabort = unexpectedErrorCallback;
var store = evalAndLog("store = transaction.objectStore('storeName')");
@@ -205,7 +205,7 @@ function addWithNullKeyFailure()
verifyErrorEvent(event);
shouldBe("event.code", "webkitIDBDatabaseException.DATA_ERR");
- transaction = evalAndLog("db.transaction()");
+ transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
transaction.onabort = unexpectedErrorCallback;
var store = evalAndLog("store = transaction.objectStore('storeName')");
@@ -221,7 +221,7 @@ function addWithNullIndexFailure()
verifyErrorEvent(event);
shouldBe("event.code", "webkitIDBDatabaseException.DATA_ERR");
- transaction = evalAndLog("db.transaction()");
+ transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
transaction.onabort = unexpectedErrorCallback;
var store = evalAndLog("store = transaction.objectStore('storeName')");
diff --git a/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt b/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt
index e45ff73..37492db 100644
--- a/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt
+++ b/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt
@@ -61,7 +61,7 @@ PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
-db.transaction()
+db.transaction({mode: webkitIDBTransaction.READ_WRITE})
store = transaction.objectStore('storeName')
store.get('key')
PASS 'onsuccess' in result is true
@@ -102,7 +102,7 @@ trans = event.result
PASS trans !== null is true
db.deleteObjectStore('storeName')
db.createObjectStore('storeName', null)
-db.transaction()
+db.transaction({mode: webkitIDBTransaction.READ_WRITE})
store = transaction.objectStore('storeName')
store.get('key')
PASS 'onsuccess' in result is true
diff --git a/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html b/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html
index c531dcf..a08f071 100644
--- a/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html
+++ b/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html
@@ -59,7 +59,7 @@ function getValue()
{
verifySuccessEvent(event);
- transaction = evalAndLog("db.transaction()");
+ transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
transaction.onabort = unexpectedErrorCallback;
var store = evalAndLog("store = transaction.objectStore('storeName')");
@@ -99,7 +99,7 @@ function createObjectStoreAgain()
function getValueAgain()
{
- transaction = evalAndLog("db.transaction()");
+ transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
transaction.onabort = unexpectedErrorCallback;
var store = evalAndLog("store = transaction.objectStore('storeName')");
diff --git a/LayoutTests/storage/indexeddb/transaction-basics-expected.txt b/LayoutTests/storage/indexeddb/transaction-basics-expected.txt
index a3bd90a..f026154 100644
--- a/LayoutTests/storage/indexeddb/transaction-basics-expected.txt
+++ b/LayoutTests/storage/indexeddb/transaction-basics-expected.txt
@@ -172,7 +172,7 @@ trans = event.result
PASS trans !== null is true
Deleted all object stores.
db.createObjectStore('storeName', null)
-db.transaction()
+db.transaction({mode: webkitIDBTransaction.READ_WRITE})
store = transaction.objectStore('storeName')
PASS store.name is "storeName"
Abort event fired:
diff --git a/LayoutTests/storage/indexeddb/transaction-basics.html b/LayoutTests/storage/indexeddb/transaction-basics.html
index cd42419..8995e6d 100644
--- a/LayoutTests/storage/indexeddb/transaction-basics.html
+++ b/LayoutTests/storage/indexeddb/transaction-basics.html
@@ -1,28 +1,28 @@
-<html>
-<head>
-<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
-<script src="../../fast/js/resources/js-test-pre.js"></script>
-<script src="../../fast/js/resources/js-test-post-function.js"></script>
-<script src="resources/shared.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-<script>
-
-description("Test IndexedDB transaction basics.");
-if (window.layoutTestController)
- layoutTestController.waitUntilDone();
-
-function test()
-{
- shouldBeTrue("'webkitIndexedDB' in window");
- shouldBeFalse("webkitIndexedDB == null");
-
- result = evalAndLog("webkitIndexedDB.open('name')");
- verifyResult(result);
- result.onsuccess = openSuccess;
- result.onerror = unexpectedErrorCallback;
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test IndexedDB transaction basics.");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function test()
+{
+ shouldBeTrue("'webkitIndexedDB' in window");
+ shouldBeFalse("webkitIndexedDB == null");
+
+ result = evalAndLog("webkitIndexedDB.open('name')");
+ verifyResult(result);
+ result.onsuccess = openSuccess;
+ result.onerror = unexpectedErrorCallback;
}
function openSuccess()
@@ -184,7 +184,7 @@ function checkMetadataEmpty()
{
shouldBe("window.db.objectStoreNames", "[]");
shouldBe("window.db.objectStoreNames.length", "0");
- shouldBe("window.db.objectStoreNames.contains('storeFail')", "false");
+ shouldBe("window.db.objectStoreNames.contains('storeFail')", "false");
}
function checkMetadataExistingObjectStore()
@@ -192,63 +192,63 @@ function checkMetadataExistingObjectStore()
shouldBe("db.objectStoreNames", "['storeFail']");
shouldBe("db.objectStoreNames.length", "1");
shouldBe("db.objectStoreNames.contains('storeFail')", "true");
-}
-
-function setNewVersion()
-{
- result = evalAndLog("db.setVersion('new version')");
- verifyResult(result);
- result.onsuccess = setVersionSuccess;
- result.onerror = unexpectedErrorCallback;
-}
-
-function setVersionSuccess()
-{
- debug("setVersionSuccess():");
- verifySuccessEvent(event);
- window.trans = evalAndLog("trans = event.result");
- shouldBeTrue("trans !== null");
- trans.onabort = unexpectedAbortCallback;
- trans.oncomplete = completeCallback;
- window.completeEventFired = false;
-
- deleteAllObjectStores(db, createObjectStoreAndStartTransaction);
+}
+
+function setNewVersion()
+{
+ result = evalAndLog("db.setVersion('new version')");
+ verifyResult(result);
+ result.onsuccess = setVersionSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function setVersionSuccess()
+{
+ debug("setVersionSuccess():");
+ verifySuccessEvent(event);
+ window.trans = evalAndLog("trans = event.result");
+ shouldBeTrue("trans !== null");
+ trans.onabort = unexpectedAbortCallback;
+ trans.oncomplete = completeCallback;
+ window.completeEventFired = false;
+
+ deleteAllObjectStores(db, createObjectStoreAndStartTransaction);
}
function createObjectStoreAndStartTransaction()
{
- evalAndLog("db.createObjectStore('storeName', null)");
- transaction = evalAndLog("db.transaction()");
- transaction.onabort = abortCallback;
- var store = evalAndLog("store = transaction.objectStore('storeName')");
- shouldBeEqualToString("store.name", "storeName");
-}
-
-function completeCallback()
-{
- verifyCompleteEvent(event);
- window.completeEventFired = true;
-}
-
-function abortCallback()
-{
- verifyAbortEvent(event);
- checkForCompleteEvent();
-}
-
-function checkForCompleteEvent()
-{
- if (completeEventFired) {
- testPassed("oncomplete event had fired");
- done();
- } else
- setTimeout(checkForCompleteEvent, 1);
-}
-
-var successfullyParsed = true;
-
-test();
-
-</script>
-</body>
-</html>
+ evalAndLog("db.createObjectStore('storeName', null)");
+ transaction = evalAndLog("db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
+ transaction.onabort = abortCallback;
+ var store = evalAndLog("store = transaction.objectStore('storeName')");
+ shouldBeEqualToString("store.name", "storeName");
+}
+
+function completeCallback()
+{
+ verifyCompleteEvent(event);
+ window.completeEventFired = true;
+}
+
+function abortCallback()
+{
+ verifyAbortEvent(event);
+ checkForCompleteEvent();
+}
+
+function checkForCompleteEvent()
+{
+ if (completeEventFired) {
+ testPassed("oncomplete event had fired");
+ done();
+ } else
+ setTimeout(checkForCompleteEvent, 1);
+}
+
+var successfullyParsed = true;
+
+test();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/storage/indexeddb/transaction-crash-on-abort-expected.txt b/LayoutTests/storage/indexeddb/transaction-crash-on-abort-expected.txt
index 413643c..139189e 100644
--- a/LayoutTests/storage/indexeddb/transaction-crash-on-abort-expected.txt
+++ b/LayoutTests/storage/indexeddb/transaction-crash-on-abort-expected.txt
@@ -24,7 +24,7 @@ PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
db = event.result
-db.transaction([])
+db.transaction()
window.gc()
PASS successfullyParsed is true
diff --git a/LayoutTests/storage/indexeddb/transaction-crash-on-abort.html b/LayoutTests/storage/indexeddb/transaction-crash-on-abort.html
index 1b13c87..92aeb31 100644
--- a/LayoutTests/storage/indexeddb/transaction-crash-on-abort.html
+++ b/LayoutTests/storage/indexeddb/transaction-crash-on-abort.html
@@ -23,16 +23,16 @@ function test()
verifyResult(result);
result.onsuccess = openSuccess;
result.onerror = unexpectedErrorCallback;
-}
-
-function openSuccess()
-{
- debug("openSuccess():");
- verifySuccessEvent(event);
- db = evalAndLog("db = event.result");
- evalAndLog("db.transaction([])");
- evalAndLog("window.gc()");
- done();
+}
+
+function openSuccess()
+{
+ debug("openSuccess():");
+ verifySuccessEvent(event);
+ db = evalAndLog("db = event.result");
+ evalAndLog("db.transaction()");
+ evalAndLog("window.gc()");
+ done();
}
var successfullyParsed = true;
diff --git a/LayoutTests/storage/indexeddb/transaction-read-only.html b/LayoutTests/storage/indexeddb/transaction-read-only.html
new file mode 100644
index 0000000..a4130d0
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/transaction-read-only.html
@@ -0,0 +1,80 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test read-only transactions in IndexedDB.");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function test()
+{
+ shouldBeTrue("'webkitIndexedDB' in window");
+ shouldBeFalse("webkitIndexedDB == null");
+
+ result = evalAndLog("webkitIndexedDB.open('name')");
+ verifyResult(result);
+ result.onsuccess = openSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+ debug("openSuccess():");
+ verifySuccessEvent(event);
+ window.db = evalAndLog("db = event.result");
+ result = evalAndLog("result = db.setVersion('version 1')");
+ result.onsuccess = cleanDatabase;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function cleanDatabase()
+{
+ verifySuccessEvent(event);
+ deleteAllObjectStores(db, setVersionStuff);
+}
+
+function setVersionStuff()
+{
+ event.result.oncomplete = setVersionDone;
+ event.result.onabort = unexpectedAbortCallback;
+ store = evalAndLog("store = db.createObjectStore('store')");
+ evalAndLog("store.put('x', 'y')");
+}
+
+function setVersionDone()
+{
+ trans = evalAndLog("trans = db.transaction()");
+ evalAndExpectException("trans.objectStore('store').put('a', 'b')", "webkitIDBDatabaseException.READ_ONLY_ERR");
+
+ trans = evalAndLog("trans = db.transaction()");
+ evalAndExpectException("trans.objectStore('store').delete('x')", "webkitIDBDatabaseException.READ_ONLY_ERR");
+
+ trans = evalAndLog("trans = db.transaction()");
+ cur = evalAndLog("cur = trans.objectStore('store').openCursor()");
+ cur.onsuccess = gotCursor;
+ cur.onerror = unexpectedErrorCallback;
+}
+
+function gotCursor()
+{
+ shouldBeFalse("!event.result");
+ evalAndExpectException("event.result.delete()", "webkitIDBDatabaseException.READ_ONLY_ERR");
+
+ done();
+}
+
+var successfullyParsed = true;
+
+test();
+
+</script>
+</body>
+</html>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 4a9f06b..7591a68 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2011-01-11 Jeremy Orlow <jorlow at chromium.org>
+
+ Reviewed by Nate Chapin.
+
+ Enforce READ_ONLY transactions in IndexedDB
+ https://bugs.webkit.org/show_bug.cgi?id=52229
+
+ Add READ_ONLY_ERR and return it whenever delete or put
+ are called. Note that IDBCursor's delete and update
+ are simply aliases for delete/put, which is why no
+ extra code is required to handle those cases.
+
+ Test: storage/indexeddb/transaction-read-only.html
+
+ * dom/ExceptionCode.cpp:
+ * storage/IDBCursorBackendImpl.cpp:
+ (WebCore::IDBCursorBackendImpl::deleteFunction):
+ * storage/IDBDatabase.idl:
+ * storage/IDBDatabaseException.h:
+ * storage/IDBDatabaseException.idl:
+ * storage/IDBObjectStoreBackendImpl.cpp:
+ (WebCore::IDBObjectStoreBackendImpl::put):
+ (WebCore::IDBObjectStoreBackendImpl::deleteFunction):
+ (WebCore::IDBObjectStoreBackendImpl::deleteIndex):
+
2011-01-11 Philippe Normand <pnormand at igalia.com>
Reviewed by Eric Seidel.
diff --git a/Source/WebCore/dom/ExceptionCode.cpp b/Source/WebCore/dom/ExceptionCode.cpp
index 7e7e0c9..1118a1a 100644
--- a/Source/WebCore/dom/ExceptionCode.cpp
+++ b/Source/WebCore/dom/ExceptionCode.cpp
@@ -222,7 +222,8 @@ static const char* const idbDatabaseExceptionNames[] = {
"RECOVERABLE_ERR",
"TRANSIENT_ERR",
"TIMEOUT_ERR",
- "DEADLOCK_ERR"
+ "DEADLOCK_ERR",
+ "READ_ONLY_ERR"
};
static const char* const idbDatabaseExceptionDescriptions[] = {
@@ -236,7 +237,8 @@ static const char* const idbDatabaseExceptionDescriptions[] = {
"RECOVERABLE_ERR", // FIXME: This isn't even used.
"TRANSIENT_ERR", // FIXME: This isn't even used.
"TIMEOUT_ERR", // This can't be thrown.
- "DEADLOCK_ERR" // This can't be thrown.
+ "DEADLOCK_ERR", // This can't be thrown.
+ "Write operations cannot be preformed on a read-only transaction."
};
#endif
diff --git a/Source/WebCore/storage/IDBCursorBackendImpl.cpp b/Source/WebCore/storage/IDBCursorBackendImpl.cpp
index 9b4e4f1..d75e28d 100644
--- a/Source/WebCore/storage/IDBCursorBackendImpl.cpp
+++ b/Source/WebCore/storage/IDBCursorBackendImpl.cpp
@@ -166,12 +166,6 @@ void IDBCursorBackendImpl::deleteFunction(PassRefPtr<IDBCallbacks> prpCallbacks,
return;
}
- // FIXME: Check that the transaction is READ_WRITE
- // if (m_transaction->mode() == IDBTransaction::READ_ONLY) {
- // FIXME: We must return READ_ONLY_ERR here. Fix this when we update IDBDatabaseException to match the spec.
- // ec = IDBDatabaseException::NOT_ALLOWED_ERR;
- // return;
- // }
RefPtr<IDBKey> key = m_currentIDBKeyValue ? m_currentIDBKeyValue : m_currentKey;
m_objectStore->deleteFunction(key.release(), prpCallbacks, m_transaction.get(), ec);
}
diff --git a/Source/WebCore/storage/IDBDatabase.idl b/Source/WebCore/storage/IDBDatabase.idl
index c6edd48..7eb43e9 100644
--- a/Source/WebCore/storage/IDBDatabase.idl
+++ b/Source/WebCore/storage/IDBDatabase.idl
@@ -38,7 +38,7 @@ module storage {
raises (IDBDatabaseException);
[CallWith=ScriptExecutionContext] IDBRequest setVersion(in DOMString version)
raises (IDBDatabaseException);
- [CallWith=ScriptExecutionContext] IDBTransaction transaction (in [Optional] OptionsObject optionsObject)
+ [CallWith=ScriptExecutionContext] IDBTransaction transaction(in [Optional] OptionsObject optionsObject)
raises (IDBDatabaseException);
// FIXME: Implement.
//void close();
diff --git a/Source/WebCore/storage/IDBDatabaseException.h b/Source/WebCore/storage/IDBDatabaseException.h
index 936b05a..174fe5b 100644
--- a/Source/WebCore/storage/IDBDatabaseException.h
+++ b/Source/WebCore/storage/IDBDatabaseException.h
@@ -53,7 +53,8 @@ public:
RECOVERABLE_ERR = IDBDatabaseExceptionOffset + 8,
TRANSIENT_ERR = IDBDatabaseExceptionOffset + 9,
TIMEOUT_ERR = IDBDatabaseExceptionOffset + 10,
- DEADLOCK_ERR = IDBDatabaseExceptionOffset + 11
+ DEADLOCK_ERR = IDBDatabaseExceptionOffset + 11,
+ READ_ONLY_ERR = IDBDatabaseExceptionOffset + 12
};
static int ErrorCodeToExceptionCode(int errorCode)
diff --git a/Source/WebCore/storage/IDBDatabaseException.idl b/Source/WebCore/storage/IDBDatabaseException.idl
index a56f4c7..9027e05 100644
--- a/Source/WebCore/storage/IDBDatabaseException.idl
+++ b/Source/WebCore/storage/IDBDatabaseException.idl
@@ -50,6 +50,7 @@ module storage {
const unsigned short TRANSIENT_ERR = 9;
const unsigned short TIMEOUT_ERR = 10;
const unsigned short DEADLOCK_ERR = 11;
+ const unsigned short READ_ONLY_ERR = 12;
};
}
diff --git a/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp b/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
index 22d3b8d..396f544 100644
--- a/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
+++ b/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
@@ -179,6 +179,11 @@ static bool putIndexData(SQLiteDatabase& db, IDBKey* key, int64_t indexId, int64
void IDBObjectStoreBackendImpl::put(PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> prpKey, bool addOnly, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
{
+ if (transactionPtr->mode() == IDBTransaction::READ_ONLY) {
+ ec = IDBDatabaseException::READ_ONLY_ERR;
+ return;
+ }
+
RefPtr<IDBObjectStoreBackendImpl> objectStore = this;
RefPtr<SerializedScriptValue> value = prpValue;
RefPtr<IDBKey> key = prpKey;
@@ -277,9 +282,15 @@ void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr<
void IDBObjectStoreBackendImpl::deleteFunction(PassRefPtr<IDBKey> prpKey, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
{
+ if (transaction->mode() == IDBTransaction::READ_ONLY) {
+ ec = IDBDatabaseException::READ_ONLY_ERR;
+ return;
+ }
+
RefPtr<IDBObjectStoreBackendImpl> objectStore = this;
RefPtr<IDBKey> key = prpKey;
RefPtr<IDBCallbacks> callbacks = prpCallbacks;
+
if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::deleteInternal, objectStore, key, callbacks)))
ec = IDBDatabaseException::NOT_ALLOWED_ERR;
}
@@ -386,6 +397,11 @@ static void doDelete(SQLiteDatabase& db, const char* sql, int64_t id)
void IDBObjectStoreBackendImpl::deleteIndex(const String& name, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
{
+ if (transaction->mode() != IDBTransaction::VERSION_CHANGE) {
+ ec = IDBDatabaseException::NOT_ALLOWED_ERR;
+ return;
+ }
+
RefPtr<IDBIndexBackendImpl> index = m_indexes.get(name);
if (!index) {
ec = IDBDatabaseException::NOT_FOUND_ERR;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list