Diff
Modified: trunk/LayoutTests/ChangeLog (106826 => 106827)
--- trunk/LayoutTests/ChangeLog 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/ChangeLog 2012-02-06 19:50:11 UTC (rev 106827)
@@ -1,3 +1,23 @@
+2012-02-06 Eugene Girard <[email protected]>
+
+ IndexedDB createObjectStore should throw if options arg is invalid (not an object).
+ Added unit tests to test invalid arguments.
+ storage/indexddb/transaction-basics was modified only to correct calls that would
+ now throw.
+ https://bugs.webkit.org/show_bug.cgi?id=58471
+
+ Reviewed by Adam Barth.
+
+ * storage/indexeddb/create-object-store-options-expected.txt:
+ * storage/indexeddb/create-object-store-options.html:
+ * storage/indexeddb/index-basics-expected.txt:
+ * storage/indexeddb/index-basics.html:
+ * storage/indexeddb/resources/shared.js:
+ (evalAndExpectExceptionClass):
+ * storage/indexeddb/transaction-basics-expected.txt:
+ * storage/indexeddb/transaction-basics.html:
+ * storage/indexeddb/tutorial.html:
+
2012-02-06 Jesus Sanchez-Palencia <[email protected]>
[Qt][WK2] http/tests/loading/state-object-security-exception.html fails
Modified: trunk/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt (106826 => 106827)
--- trunk/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt 2012-02-06 19:50:11 UTC (rev 106827)
@@ -15,6 +15,12 @@
trans = db.transaction(['a', 'b'], webkitIDBTransaction.READ_WRITE)
PASS trans.mode is webkitIDBTransaction.READ_WRITE
trans.objectStore('a').put({'a': 0})
+Expecting TypeError exception from db.createObjectStore('d', 'bar');
+PASS Exception was thrown.
+PASS db.createObjectStore('d', 'bar'); threw TypeError: Not an object.
+Expecting TypeError exception from db.createObjectStore('e', false);
+PASS Exception was thrown.
+PASS db.createObjectStore('e', false); threw TypeError: Not an object.
trans.objectStore('b').put({'a': 0}, 0)
trans.objectStore('a').get(0)
PASS event.target.result.a is {a: 0}
Modified: trunk/LayoutTests/storage/indexeddb/create-object-store-options.html (106826 => 106827)
--- trunk/LayoutTests/storage/indexeddb/create-object-store-options.html 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/storage/indexeddb/create-object-store-options.html 2012-02-06 19:50:11 UTC (rev 106827)
@@ -47,6 +47,9 @@
req = evalAndLog("trans.objectStore('a').put({'a': 0})");
req._onsuccess_ = putB;
req._onerror_ = unexpectedErrorCallback;
+
+ evalAndExpectExceptionClass("db.createObjectStore('d', 'bar');", "TypeError");
+ evalAndExpectExceptionClass("db.createObjectStore('e', false);", "TypeError");
}
function putB()
Modified: trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt (106826 => 106827)
--- trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt 2012-02-06 19:50:11 UTC (rev 106827)
@@ -12,8 +12,8 @@
Deleted all object stores.
db.createObjectStore('storeName', null)
store.createIndex('indexName', 'x')
-store.createIndex('indexName2', 'y', false)
-store.createIndex('zIndex', 'z', true)
+store.createIndex('indexName2', 'y', {unique: false})
+store.createIndex('zIndex', 'z', {unique: true})
PASS 'name' in indexObject is true
PASS indexObject.name is "indexName"
PASS 'objectStore' in indexObject is true
Modified: trunk/LayoutTests/storage/indexeddb/index-basics.html (106826 => 106827)
--- trunk/LayoutTests/storage/indexeddb/index-basics.html 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/storage/indexeddb/index-basics.html 2012-02-06 19:50:11 UTC (rev 106827)
@@ -39,8 +39,8 @@
window.store = evalAndLog("db.createObjectStore('storeName', null)");
window.indexObject = evalAndLog("store.createIndex('indexName', 'x')");
- window.indexObject2 = evalAndLog("store.createIndex('indexName2', 'y', false)");
- window.indexObject3 = evalAndLog("store.createIndex('zIndex', 'z', true)");
+ window.indexObject2 = evalAndLog("store.createIndex('indexName2', 'y', {unique: false})");
+ window.indexObject3 = evalAndLog("store.createIndex('zIndex', 'z', {unique: true})");
addData();
}
Modified: trunk/LayoutTests/storage/indexeddb/resources/shared.js (106826 => 106827)
--- trunk/LayoutTests/storage/indexeddb/resources/shared.js 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/storage/indexeddb/resources/shared.js 2012-02-06 19:50:11 UTC (rev 106827)
@@ -50,6 +50,21 @@
}
}
+function evalAndExpectExceptionClass(cmd, expected)
+{
+ debug("Expecting " + expected + " exception from " + cmd);
+ try {
+ eval(cmd);
+ testFailed("No exception thrown!" );
+ } catch (e) {
+ testPassed("Exception was thrown.");
+ if (eval("e instanceof " + expected))
+ testPassed(cmd + " threw " + e);
+ else
+ testFailed("Expected " + expected + " but saw " + e);
+ }
+}
+
function deleteAllObjectStores(db)
{
while (db.objectStoreNames.length)
Modified: trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt (106826 => 106827)
--- trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt 2012-02-06 19:50:11 UTC (rev 106827)
@@ -23,7 +23,7 @@
trans = event.target.result
PASS trans !== null is true
store = db.createObjectStore('storeFail', null)
-index = store.createIndex('indexFail', 'x', false)
+index = store.createIndex('indexFail', 'x')
db.deleteObjectStore('storeFail')
store.deleteIndex('indexFail')
@@ -36,11 +36,11 @@
trans = event.target.result
PASS trans !== null is true
store = db.createObjectStore('storeFail', null)
-index = store.createIndex('indexFail', 'x', false)
+index = store.createIndex('indexFail', 'x')
db.deleteObjectStore('storeFail')
store.deleteIndex('indexFail')
store = db.createObjectStore('storeFail', null)
-index = store.createIndex('indexFail', 'x', false)
+index = store.createIndex('indexFail', 'x')
testSetVersionAbort3():
PASS event.cancelable is false
@@ -53,7 +53,7 @@
trans = event.target.result
PASS trans !== null is true
store = db.createObjectStore('storeFail', null)
-index = store.createIndex('indexFail', 'x', false)
+index = store.createIndex('indexFail', 'x')
testInactiveAbortedTransaction():
Expecting exception from index.openCursor()
@@ -99,7 +99,7 @@
trans = event.target.result
PASS trans !== null is true
store = db.createObjectStore('storeFail', null)
-index = store.createIndex('indexFail', 'x', false)
+index = store.createIndex('indexFail', 'x')
testInactiveCompletedTransaction():
Expecting exception from index.openCursor()
Modified: trunk/LayoutTests/storage/indexeddb/transaction-basics.html (106826 => 106827)
--- trunk/LayoutTests/storage/indexeddb/transaction-basics.html 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/storage/indexeddb/transaction-basics.html 2012-02-06 19:50:11 UTC (rev 106827)
@@ -56,7 +56,7 @@
trans._oncomplete_ = unexpectedCompleteCallback;
var store = evalAndLog("store = db.createObjectStore('storeFail', null)");
- var index = evalAndLog("index = store.createIndex('indexFail', 'x', false)");
+ var index = evalAndLog("index = store.createIndex('indexFail', 'x')");
evalAndLog("db.deleteObjectStore('storeFail')");
evalAndLog("store.deleteIndex('indexFail')");
@@ -82,13 +82,13 @@
trans._oncomplete_ = unexpectedCompleteCallback;
var store = evalAndLog("store = db.createObjectStore('storeFail', null)");
- var index = evalAndLog("index = store.createIndex('indexFail', 'x', false)");
+ var index = evalAndLog("index = store.createIndex('indexFail', 'x')");
evalAndLog("db.deleteObjectStore('storeFail')");
evalAndLog("store.deleteIndex('indexFail')");
var store = evalAndLog("store = db.createObjectStore('storeFail', null)");
- var index = evalAndLog("index = store.createIndex('indexFail', 'x', false)");
+ var index = evalAndLog("index = store.createIndex('indexFail', 'x')");
trans.abort();
}
@@ -113,7 +113,7 @@
trans._oncomplete_ = unexpectedCompleteCallback;
store = evalAndLog("store = db.createObjectStore('storeFail', null)");
- index = evalAndLog("index = store.createIndex('indexFail', 'x', false)");
+ index = evalAndLog("index = store.createIndex('indexFail', 'x')");
trans.abort();
}
@@ -155,7 +155,7 @@
trans._onabort_ = unexpectedAbortCallback;
store = evalAndLog("store = db.createObjectStore('storeFail', null)");
- index = evalAndLog("index = store.createIndex('indexFail', 'x', false)");
+ index = evalAndLog("index = store.createIndex('indexFail', 'x')");
trans._oncomplete_ = testInactiveCompletedTransaction;
}
Modified: trunk/LayoutTests/storage/indexeddb/tutorial.html (106826 => 106827)
--- trunk/LayoutTests/storage/indexeddb/tutorial.html 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/LayoutTests/storage/indexeddb/tutorial.html 2012-02-06 19:50:11 UTC (rev 106827)
@@ -180,8 +180,8 @@
// indexes for a persons first and last name. Indexes can optionally be specified to not be
// unique, which is good in the case of names. The first parameter is the name of the index.
// Second is the key path. The third specifies uniqueness.
- var fname = objectStore.createIndex("fname", "fname", false);
- var lname = objectStore.createIndex("lname", "lname", false);
+ var fname = objectStore.createIndex("fname", "fname", { unique: false});
+ var lname = objectStore.createIndex("lname", "lname", { unique: false});
// Note that if you wanted to delete these indexes, you can either call objectStore.deleteIndex
// or simply delete the objectStores that own the indexes.
Modified: trunk/Source/WebCore/ChangeLog (106826 => 106827)
--- trunk/Source/WebCore/ChangeLog 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/Source/WebCore/ChangeLog 2012-02-06 19:50:11 UTC (rev 106827)
@@ -1,3 +1,20 @@
+2012-02-06 Eugene Girard <[email protected]>
+
+ IndexedDB createObjectStore should throw if options arg is invalid
+ Added logic to OptionsObject to determine if an invalid object was created.
+ _javascript_ bindings now detect invalid OptionsObject's and throw TypeError when found.
+ https://bugs.webkit.org/show_bug.cgi?id=58471
+
+ Reviewed by Adam Barth.
+
+ Test: storage/indexeddb/createObjectStore-bad-options.html
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateParametersCheck):
+ * bindings/v8/OptionsObject.cpp:
+ (WebCore::OptionsObject::isObject):
+ * bindings/v8/OptionsObject.h:
+
2012-02-06 Sheriff Bot <[email protected]>
Unreviewed, rolling out r106797 and r106806.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (106826 => 106827)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-02-06 19:50:11 UTC (rev 106827)
@@ -1595,6 +1595,13 @@
}
$parameterCheckString .= " EXCEPTION_BLOCK($nativeType, $parameterName, " .
JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterMissingPolicy)") . ");\n";
+ if ($nativeType eq 'OptionsObject') {
+ $parameterCheckString .= " if (args.Length() > $paramIndex && !$parameterName.isUndefinedOrNull() && !$parameterName.isObject()) {\n";
+ $parameterCheckString .= " ec = TYPE_MISMATCH_ERR;\n";
+ $parameterCheckString .= " V8Proxy::setDOMException(ec);\n";
+ $parameterCheckString .= " return throwError(\"Not an object.\", V8Proxy::TypeError);\n";
+ $parameterCheckString .= " }\n";
+ }
}
if ($parameter->extendedAttributes->{"IsIndex"}) {
Modified: trunk/Source/WebCore/bindings/v8/OptionsObject.cpp (106826 => 106827)
--- trunk/Source/WebCore/bindings/v8/OptionsObject.cpp 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/Source/WebCore/bindings/v8/OptionsObject.cpp 2012-02-06 19:50:11 UTC (rev 106827)
@@ -64,6 +64,11 @@
return *this;
}
+bool OptionsObject::isObject() const
+{
+ return !isUndefinedOrNull() && m_options->IsObject();
+}
+
bool OptionsObject::isUndefinedOrNull() const
{
if (m_options.IsEmpty())
Modified: trunk/Source/WebCore/bindings/v8/OptionsObject.h (106826 => 106827)
--- trunk/Source/WebCore/bindings/v8/OptionsObject.h 2012-02-06 19:50:03 UTC (rev 106826)
+++ trunk/Source/WebCore/bindings/v8/OptionsObject.h 2012-02-06 19:50:11 UTC (rev 106827)
@@ -49,6 +49,7 @@
OptionsObject& operator=(const OptionsObject&);
+ bool isObject() const;
bool isUndefinedOrNull() const;
bool get(const String&, bool&) const;