Diff
Modified: trunk/LayoutTests/ChangeLog (96630 => 96631)
--- trunk/LayoutTests/ChangeLog 2011-10-04 19:22:00 UTC (rev 96630)
+++ trunk/LayoutTests/ChangeLog 2011-10-04 19:35:23 UTC (rev 96631)
@@ -1,3 +1,15 @@
+2011-10-04 Joshua Bell <[email protected]>
+
+ IndexedDB add() should fail if key is NaN
+ https://bugs.webkit.org/show_bug.cgi?id=62286
+
+ Reviewed by Tony Chang.
+
+ Tests for NaN and other invalid IndexedDB keys.
+
+ * storage/indexeddb/invalid-keys-expected.txt: Added.
+ * storage/indexeddb/invalid-keys.html: Added.
+
2011-10-04 Young Han Lee <[email protected]>
HTML canvas strokes with dash and dashOffset
Added: trunk/LayoutTests/storage/indexeddb/invalid-keys-expected.txt (0 => 96631)
--- trunk/LayoutTests/storage/indexeddb/invalid-keys-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/invalid-keys-expected.txt 2011-10-04 19:35:23 UTC (rev 96631)
@@ -0,0 +1,63 @@
+Test IndexedDB invalid keys
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
+PASS indexedDB == null is false
+IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;
+PASS IDBDatabaseException == null is false
+indexedDB.open(name, description)
+db = event.target.result
+request = db.setVersion('1')
+Deleted all object stores.
+db.createObjectStore('foo');
+Expecting exception from request = objectStore.put('value', void 0)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', null)
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
+Expecting exception from request = objectStore.put('value', (function() { return arguments; }()))
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', true)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', false)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', new Error)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', function () {})
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', JSON)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', Math)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', NaN)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', {})
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', /regex/)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', window)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', window.document)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+Expecting exception from request = objectStore.put('value', window.document.body)
+PASS Exception was thrown.
+FAIL code should be 5. Was 17.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/storage/indexeddb/invalid-keys.html (0 => 96631)
--- trunk/LayoutTests/storage/indexeddb/invalid-keys.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/invalid-keys.html 2011-10-04 19:35:23 UTC (rev 96631)
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test IndexedDB invalid keys");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function test()
+{
+ indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
+ shouldBeFalse("indexedDB == null");
+ IDBDatabaseException = evalAndLog("IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;");
+ shouldBeFalse("IDBDatabaseException == null");
+
+ name = window.location.pathname;
+ description = "My Test Database";
+ request = evalAndLog("indexedDB.open(name, description)");
+ request._onsuccess_ = openSuccess;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+ db = evalAndLog("db = event.target.result");
+
+ request = evalAndLog("request = db.setVersion('1')");
+ request._onsuccess_ = testGroup1;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function testGroup1()
+{
+ deleteAllObjectStores(db);
+
+ objectStore = evalAndLog("db.createObjectStore('foo');");
+ testInvalidKeys();
+}
+
+function testInvalidKeys()
+{
+ var invalidKeys = [
+ "void 0", // Undefined
+ "null", // Null
+ "(function() { return arguments; }())", // Arguments
+ "true", // Boolean
+ "false", // Boolean
+ "new Error", // Error
+ "function () {}", // Function
+ "JSON", // JSON
+ "Math", // Math
+ "NaN", // Number (special case)
+ "{}", // Object
+ "/regex/", // RegExp
+ "window", // global
+ "window.document", // HTMLDocument
+ "window.document.body" // HTMLBodyElement
+ ];
+
+ invalidKeys.forEach(function(key) {
+ evalAndExpectException("request = objectStore.put('value', " + key + ")", "IDBDatabaseException.DATA_ERR");
+ });
+
+ done();
+}
+
+var successfullyParsed = true;
+
+test();
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (96630 => 96631)
--- trunk/Source/WebCore/ChangeLog 2011-10-04 19:22:00 UTC (rev 96630)
+++ trunk/Source/WebCore/ChangeLog 2011-10-04 19:35:23 UTC (rev 96631)
@@ -1,3 +1,17 @@
+2011-10-04 Joshua Bell <[email protected]>
+
+ IndexedDB add() should fail if key is NaN
+ https://bugs.webkit.org/show_bug.cgi?id=62286
+
+ Reviewed by Tony Chang.
+
+ Test: storage/indexeddb/invalid-keys.html
+
+ Implement special case - numbers are valid keys, except for NaN.
+
+ * bindings/v8/IDBBindingUtilities.cpp:
+ (WebCore::createIDBKeyFromValue):
+
2011-10-04 Mark Hahnenberg <[email protected]>
Add static ClassInfo structs to classes that override JSCell::getCallData
Modified: trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp (96630 => 96631)
--- trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp 2011-10-04 19:22:00 UTC (rev 96630)
+++ trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp 2011-10-04 19:35:23 UTC (rev 96631)
@@ -42,7 +42,7 @@
{
if (value->IsNull())
return IDBKey::createNull();
- if (value->IsNumber())
+ if (value->IsNumber() && !isnan(value->NumberValue()))
return IDBKey::createNumber(value->NumberValue());
if (value->IsString())
return IDBKey::createString(v8ValueToWebCoreString(value));