IndexedDB: A null or undefined storeNames argument to IDBDatabase::transaction()...
authorjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2012 00:48:10 +0000 (00:48 +0000)
committerjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2012 00:48:10 +0000 (00:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90474

Reviewed by Tony Chang.

Source/WebCore:

Test: storage/indexeddb/transaction-basics.html

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::transaction):
* Modules/indexeddb/IDBDatabase.idl:

LayoutTests:

* storage/indexeddb/resources/transaction-basics.js:
(testInvalidMode):
(testDegenerateNames.request.onsuccess):
(testDegenerateNames.verifyDegenerateNames):
(testDegenerateNames):
* storage/indexeddb/transaction-basics-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@122173 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/resources/transaction-basics.js
LayoutTests/storage/indexeddb/transaction-basics-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.idl

index a949bb3..2a751d3 100644 (file)
@@ -1,3 +1,17 @@
+2012-07-09  Joshua Bell  <jsbell@chromium.org>
+
+        IndexedDB: A null or undefined storeNames argument to IDBDatabase::transaction() should be coerced to string
+        https://bugs.webkit.org/show_bug.cgi?id=90474
+
+        Reviewed by Tony Chang.
+
+        * storage/indexeddb/resources/transaction-basics.js:
+        (testInvalidMode):
+        (testDegenerateNames.request.onsuccess):
+        (testDegenerateNames.verifyDegenerateNames):
+        (testDegenerateNames):
+        * storage/indexeddb/transaction-basics-expected.txt:
+
 2012-07-09  Vincent Scheib  <scheib@chromium.org>
 
         Pointer Lock requestPointerLock rejects locking an element not in a document.
index a77861a..633ea99 100644 (file)
@@ -280,7 +280,32 @@ function testInvalidMode()
     debug("");
     debug("Verify that specifying an invalid mode raises an exception");
     evalAndExpectException("db.transaction(['storeName'], 'lsakjdf')", "IDBDatabaseException.TYPE_ERR", "'TypeError'");
-    finishJSTest();
+    testDegenerateNames();
+}
+
+function testDegenerateNames()
+{
+    debug("");
+    debug("Test that null and undefined are treated as strings");
+
+    evalAndExpectException("db.transaction(null)", "DOMException.NOT_FOUND_ERR", "'NotFoundError'");
+    evalAndExpectException("db.transaction(undefined)", "DOMException.NOT_FOUND_ERR", "'NotFoundError'");
+
+    request = evalAndLog("db.setVersion('funny names')");
+    request.onerror = unexpectedErrorCallback;
+    request.onsuccess = function () {
+        var trans = request.result;
+        evalAndLog("db.createObjectStore('null')");
+        evalAndLog("db.createObjectStore('undefined')");
+        trans.oncomplete = verifyDegenerateNames;
+    };
+    function verifyDegenerateNames() {
+        shouldNotThrow("transaction = db.transaction(null)");
+        shouldBeNonNull("transaction.objectStore('null')");
+        shouldNotThrow("transaction = db.transaction(undefined)");
+        shouldBeNonNull("transaction.objectStore('undefined')");
+        finishJSTest();
+    }
 }
 
 test();
index 792708e..caae8b4 100644 (file)
@@ -202,6 +202,23 @@ Expecting exception from db.transaction(['storeName'], 'lsakjdf')
 PASS Exception was thrown.
 PASS code is IDBDatabaseException.TYPE_ERR
 PASS ename is 'TypeError'
+
+Test that null and undefined are treated as strings
+Expecting exception from db.transaction(null)
+PASS Exception was thrown.
+PASS code is DOMException.NOT_FOUND_ERR
+PASS ename is 'NotFoundError'
+Expecting exception from db.transaction(undefined)
+PASS Exception was thrown.
+PASS code is DOMException.NOT_FOUND_ERR
+PASS ename is 'NotFoundError'
+db.setVersion('funny names')
+db.createObjectStore('null')
+db.createObjectStore('undefined')
+PASS transaction = db.transaction(null) did not throw exception.
+PASS transaction.objectStore('null') is non-null.
+PASS transaction = db.transaction(undefined) did not throw exception.
+PASS transaction.objectStore('undefined') is non-null.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index df817d4..e4ba8c0 100644 (file)
@@ -1,5 +1,18 @@
 2012-07-09  Joshua Bell  <jsbell@chromium.org>
 
+        IndexedDB: A null or undefined storeNames argument to IDBDatabase::transaction() should be coerced to string
+        https://bugs.webkit.org/show_bug.cgi?id=90474
+
+        Reviewed by Tony Chang.
+
+        Test: storage/indexeddb/transaction-basics.html
+
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::transaction):
+        * Modules/indexeddb/IDBDatabase.idl:
+
+2012-07-09  Joshua Bell  <jsbell@chromium.org>
+
         IndexedDB: Remove obsolete accessor plumbing
         https://bugs.webkit.org/show_bug.cgi?id=90812
 
index 632999d..35b5ca1 100644 (file)
@@ -207,7 +207,8 @@ PassRefPtr<IDBVersionChangeRequest> IDBDatabase::setVersion(ScriptExecutionConte
 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* context, PassRefPtr<DOMStringList> prpStoreNames, const String& modeString, ExceptionCode& ec)
 {
     RefPtr<DOMStringList> storeNames = prpStoreNames;
-    if (!storeNames || storeNames->isEmpty()) {
+    ASSERT(storeNames.get());
+    if (storeNames->isEmpty()) {
         ec = IDBDatabaseException::IDB_INVALID_ACCESS_ERR;
         return 0;
     }
index 240aee9..95f6c23 100644 (file)
@@ -45,17 +45,17 @@ module storage {
             raises (IDBDatabaseException);
         [CallWith=ScriptExecutionContext] IDBVersionChangeRequest setVersion(in DOMString version)
             raises (IDBDatabaseException);
-        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList? storeNames, in [Optional=DefaultIsNullString] DOMString mode)
+        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList storeNames, in [Optional=DefaultIsNullString] DOMString mode)
             raises (IDBDatabaseException);
-        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[]? storeNames, in [Optional=DefaultIsNullString] DOMString mode)
+        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[] storeNames, in [Optional=DefaultIsNullString] DOMString mode)
             raises (IDBDatabaseException);
         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in [Optional=DefaultIsNullString] DOMString mode)
             raises (IDBDatabaseException);
 
         // FIXME: remove these when https://bugs.webkit.org/show_bug.cgi?id=85326 is fixed.
-        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList? storeNames, in unsigned short mode)
+        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList storeNames, in unsigned short mode)
             raises (IDBDatabaseException);
-        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[]? storeNames, in unsigned short mode)
+        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[] storeNames, in unsigned short mode)
             raises (IDBDatabaseException);
         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in unsigned short mode)
             raises (IDBDatabaseException);