Title: [104865] trunk
Revision
104865
Author
[email protected]
Date
2012-01-12 15:12:29 -0800 (Thu, 12 Jan 2012)

Log Message

IndexedDB: Throw exception if IDBCursor.continue() called with key equal to current
https://bugs.webkit.org/show_bug.cgi?id=76100

Source/WebCore:

The fix for https://bugs.webkit.org/show_bug.cgi?id=74213 missed the "or equal" clause
in the spec.

Patch by Joshua Bell <[email protected]> on 2012-01-12
Reviewed by Tony Chang.

Test: storage/indexeddb/cursor-continue.html

* storage/IDBCursorBackendImpl.cpp:
(WebCore::IDBCursorBackendImpl::continueFunction):

LayoutTests:

The previously existing clauses that iterated a cursor over non-unique values
by specifing a key now fail per spec, so they are changed to simply call continue().

Patch by Joshua Bell <[email protected]> on 2012-01-12
Reviewed by Tony Chang.

* storage/indexeddb/cursor-continue-expected.txt:
* storage/indexeddb/cursor-continue.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (104864 => 104865)


--- trunk/LayoutTests/ChangeLog	2012-01-12 22:57:14 UTC (rev 104864)
+++ trunk/LayoutTests/ChangeLog	2012-01-12 23:12:29 UTC (rev 104865)
@@ -1,3 +1,16 @@
+2012-01-12  Joshua Bell  <[email protected]>
+
+        IndexedDB: Throw exception if IDBCursor.continue() called with key equal to current
+        https://bugs.webkit.org/show_bug.cgi?id=76100
+
+        The previously existing clauses that iterated a cursor over non-unique values 
+        by specifing a key now fail per spec, so they are changed to simply call continue().
+
+        Reviewed by Tony Chang.
+
+        * storage/indexeddb/cursor-continue-expected.txt:
+        * storage/indexeddb/cursor-continue.html:
+
 2012-01-12  Jon Lee  <[email protected]>
 
         Setting value on a select element to a non existing option value should clear selection

Modified: trunk/LayoutTests/storage/indexeddb/cursor-continue-expected.txt (104864 => 104865)


--- trunk/LayoutTests/storage/indexeddb/cursor-continue-expected.txt	2012-01-12 22:57:14 UTC (rev 104864)
+++ trunk/LayoutTests/storage/indexeddb/cursor-continue-expected.txt	2012-01-12 23:12:29 UTC (rev 104865)
@@ -40,17 +40,17 @@
 PASS event.target.result.primaryKey is 0
 event.target.result.continue(3.14159)
 PASS event.target.result.primaryKey is 3
-event.target.result.continue(3.14159)
+event.target.result.continue()
 PASS event.target.result.primaryKey is 4
-event.target.result.continue(3.14159)
+event.target.result.continue()
 PASS event.target.result.primaryKey is 5
 event.target.result.continue(12)
 PASS event.target.result.primaryKey is 7
 event.target.result.continue(date)
 PASS event.target.result.primaryKey is 9
-event.target.result.continue(date)
+event.target.result.continue()
 PASS event.target.result.primaryKey is 10
-event.target.result.continue(date)
+event.target.result.continue()
 PASS event.target.result.primaryKey is 11
 event.target.result.continue('A bit1')
 PASS event.target.result.primaryKey is 14
@@ -58,24 +58,24 @@
 PASS event.target.result.primaryKey is 16
 event.target.result.continue('the BIGGEST string')
 PASS event.target.result.primaryKey is 17
-event.target.result.continue('the BIGGEST string')
+event.target.result.continue()
 PASS event.target.result is null
 
 indexObject.openKeyCursor(null, IDBCursor.PREV)
 PASS event.target.result.primaryKey is 17
 event.target.result.continue('A bit2')
 PASS event.target.result.primaryKey is 15
-event.target.result.continue('A bit2')
+event.target.result.continue()
 PASS event.target.result.primaryKey is 14
 event.target.result.continue(date)
 PASS event.target.result.primaryKey is 10
-event.target.result.continue(date)
+event.target.result.continue()
 PASS event.target.result.primaryKey is 9
 event.target.result.continue(1)
 PASS event.target.result.primaryKey is 2
-event.target.result.continue(1)
+event.target.result.continue()
 PASS event.target.result.primaryKey is 1
-event.target.result.continue(1)
+event.target.result.continue()
 PASS event.target.result.primaryKey is 0
 event.target.result.continue()
 PASS event.target.result is null
@@ -88,6 +88,14 @@
 PASS Exception was thrown.
 PASS code is IDBDatabaseException.DATA_ERR
 
+indexObject.openKeyCursor(null, IDBCursor.NEXT)
+PASS event.target.result.primaryKey is 0
+event.target.result.continue(3.14159)
+PASS event.target.result.primaryKey is 3
+Expecting exception from event.target.result.continue(3.14159)
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
+
 indexObject.openKeyCursor(null, IDBCursor.PREV)
 PASS event.target.result.primaryKey is 17
 event.target.result.continue('A bit2')
@@ -95,6 +103,14 @@
 Expecting exception from event.target.result.continue('A bit3')
 PASS Exception was thrown.
 PASS code is IDBDatabaseException.DATA_ERR
+
+indexObject.openKeyCursor(null, IDBCursor.PREV)
+PASS event.target.result.primaryKey is 17
+event.target.result.continue('A bit2')
+PASS event.target.result.primaryKey is 15
+Expecting exception from event.target.result.continue('A bit2')
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/cursor-continue.html (104864 => 104865)


--- trunk/LayoutTests/storage/indexeddb/cursor-continue.html	2012-01-12 22:57:14 UTC (rev 104864)
+++ trunk/LayoutTests/storage/indexeddb/cursor-continue.html	2012-01-12 23:12:29 UTC (rev 104865)
@@ -101,10 +101,10 @@
         evalAndLog("event.target.result.continue(3.14159)");
     } else if (window.stage == 1) {
         shouldBe("event.target.result.primaryKey", "3");
-        evalAndLog("event.target.result.continue(3.14159)");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 2) {
         shouldBe("event.target.result.primaryKey", "4");
-        evalAndLog("event.target.result.continue(3.14159)");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 3) {
         shouldBe("event.target.result.primaryKey", "5");
         evalAndLog("event.target.result.continue(12)");
@@ -113,10 +113,10 @@
         evalAndLog("event.target.result.continue(date)");
     } else if (window.stage == 5) {
         shouldBe("event.target.result.primaryKey", "9");
-        evalAndLog("event.target.result.continue(date)");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 6) {
         shouldBe("event.target.result.primaryKey", "10");
-        evalAndLog("event.target.result.continue(date)");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 7) {
         shouldBe("event.target.result.primaryKey", "11");
         evalAndLog("event.target.result.continue('A bit1')");
@@ -128,7 +128,7 @@
         evalAndLog("event.target.result.continue('the BIGGEST string')");
     } else if (window.stage == 10) {
         shouldBe("event.target.result.primaryKey", "17");
-        evalAndLog("event.target.result.continue('the BIGGEST string')");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 11) {
         shouldBeNull("event.target.result");
         descendingTest();
@@ -155,28 +155,28 @@
         evalAndLog("event.target.result.continue('A bit2')");
     } else if (window.stage == 1) {
         shouldBe("event.target.result.primaryKey", "15");
-        evalAndLog("event.target.result.continue('A bit2')");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 2) {
         shouldBe("event.target.result.primaryKey", "14");
         evalAndLog("event.target.result.continue(date)");
     } else if (window.stage == 3) {
         shouldBe("event.target.result.primaryKey", "10");
-        evalAndLog("event.target.result.continue(date)");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 4) {
         shouldBe("event.target.result.primaryKey", "9");
         evalAndLog("event.target.result.continue(1)");
     } else if (window.stage == 5) {
         shouldBe("event.target.result.primaryKey", "2");
-        evalAndLog("event.target.result.continue(1)");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 6) {
         shouldBe("event.target.result.primaryKey", "1");
-        evalAndLog("event.target.result.continue(1)");
+        evalAndLog("event.target.result.continue()");
     } else if (window.stage == 7) {
         shouldBe("event.target.result.primaryKey", "0");
         evalAndLog("event.target.result.continue()");
     } else if (window.stage == 8) {
         shouldBeNull("event.target.result");
-        ascendingErrorTest();
+        ascendingErrorTestLessThan();
         return;
     } else {
         testFailed("Illegal stage.");
@@ -184,7 +184,7 @@
     window.stage++;
 }
 
-function ascendingErrorTest()
+function ascendingErrorTestLessThan()
 {
     debug("");
     var request = evalAndLog("indexObject.openKeyCursor(null, IDBCursor.NEXT)");
@@ -197,7 +197,7 @@
         } else if (window.stage == 1) {
             shouldBe("event.target.result.primaryKey", "3");
             evalAndExpectException("event.target.result.continue(1)", "IDBDatabaseException.DATA_ERR");
-            descendingErrorTest();
+            ascendingErrorTestEqual();
             return;
         } else {
            testFailed("Illegal stage.");
@@ -206,9 +206,31 @@
     };
 }
 
-function descendingErrorTest()
+function ascendingErrorTestEqual()
 {
     debug("");
+    var request = evalAndLog("indexObject.openKeyCursor(null, IDBCursor.NEXT)");
+    window.stage = 0;
+    request._onerror_ = unexpectedErrorCallback;
+    request._onsuccess_ = function() {
+        if (window.stage === 0) {
+            shouldBe("event.target.result.primaryKey", "0");
+            evalAndLog("event.target.result.continue(3.14159)");
+        } else if (window.stage == 1) {
+            shouldBe("event.target.result.primaryKey", "3");
+            evalAndExpectException("event.target.result.continue(3.14159)", "IDBDatabaseException.DATA_ERR");
+            descendingErrorTestGreaterThan();
+            return;
+        } else {
+           testFailed("Illegal stage.");
+        }
+        window.stage++;
+    };
+}
+
+function descendingErrorTestGreaterThan()
+{
+    debug("");
     var request = evalAndLog("indexObject.openKeyCursor(null, IDBCursor.PREV)");
     window.stage = 0;
     request._onerror_ = unexpectedErrorCallback;
@@ -219,6 +241,28 @@
         } else if (window.stage == 1) {
             shouldBe("event.target.result.primaryKey", "15");
             evalAndExpectException("event.target.result.continue('A bit3')", "IDBDatabaseException.DATA_ERR");
+            descendingErrorTestEqual();
+            return;
+        } else {
+           testFailed("Illegal stage.");
+        }
+        window.stage++;
+    };
+}
+
+function descendingErrorTestEqual()
+{
+    debug("");
+    var request = evalAndLog("indexObject.openKeyCursor(null, IDBCursor.PREV)");
+    window.stage = 0;
+    request._onerror_ = unexpectedErrorCallback;
+    request._onsuccess_ = function() {
+        if (window.stage == 0) {
+            shouldBe("event.target.result.primaryKey", "17");
+            evalAndLog("event.target.result.continue('A bit2')");
+        } else if (window.stage == 1) {
+            shouldBe("event.target.result.primaryKey", "15");
+            evalAndExpectException("event.target.result.continue('A bit2')", "IDBDatabaseException.DATA_ERR");
             done();
             return;
         } else {

Modified: trunk/Source/WebCore/ChangeLog (104864 => 104865)


--- trunk/Source/WebCore/ChangeLog	2012-01-12 22:57:14 UTC (rev 104864)
+++ trunk/Source/WebCore/ChangeLog	2012-01-12 23:12:29 UTC (rev 104865)
@@ -1,3 +1,18 @@
+2012-01-12  Joshua Bell  <[email protected]>
+
+        IndexedDB: Throw exception if IDBCursor.continue() called with key equal to current
+        https://bugs.webkit.org/show_bug.cgi?id=76100
+
+        The fix for https://bugs.webkit.org/show_bug.cgi?id=74213 missed the "or equal" clause
+        in the spec.
+
+        Reviewed by Tony Chang.
+
+        Test: storage/indexeddb/cursor-continue.html
+
+        * storage/IDBCursorBackendImpl.cpp:
+        (WebCore::IDBCursorBackendImpl::continueFunction):
+
 2012-01-12  Jon Lee  <[email protected]>
 
         Setting value on a select element to a non existing option value should clear selection

Modified: trunk/Source/WebCore/storage/IDBCursorBackendImpl.cpp (104864 => 104865)


--- trunk/Source/WebCore/storage/IDBCursorBackendImpl.cpp	2012-01-12 22:57:14 UTC (rev 104864)
+++ trunk/Source/WebCore/storage/IDBCursorBackendImpl.cpp	2012-01-12 23:12:29 UTC (rev 104865)
@@ -101,12 +101,12 @@
     if (m_cursor && key) {
         ASSERT(m_cursor->key());
         if (m_direction == IDBCursor::NEXT || m_direction == IDBCursor::NEXT_NO_DUPLICATE) {
-            if (key->isLessThan(m_cursor->key().get())) {
+            if (!m_cursor->key()->isLessThan(key.get())) {
                 ec = IDBDatabaseException::DATA_ERR;
                 return;
             }
         } else {
-            if (m_cursor->key()->isLessThan(key.get())) {
+            if (!key->isLessThan(m_cursor->key().get())) {
                 ec = IDBDatabaseException::DATA_ERR;
                 return;
             }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to