Title: [193364] trunk
Revision
193364
Author
beid...@apple.com
Date
2015-12-03 12:07:00 -0800 (Thu, 03 Dec 2015)

Log Message

Modern IDB: storage/indexeddb/cursor-advance.html fails.
https://bugs.webkit.org/show_bug.cgi?id=151731

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (At least one failing test now passes).

* Modules/indexeddb/IDBCursor.h:
* Modules/indexeddb/IDBCursor.idl:

* Modules/indexeddb/client/IDBCursorImpl.cpp:
(WebCore::IDBClient::IDBCursor::advance): Return a custom exception message for TypeError.
* Modules/indexeddb/client/IDBCursorImpl.h:

* Modules/indexeddb/legacy/LegacyCursor.cpp:
(WebCore::LegacyCursor::advance):
* Modules/indexeddb/legacy/LegacyCursor.h:

* bindings/js/JSDOMBinding.cpp:
(WebCore::createDOMException):
(WebCore::setDOMException):
* bindings/js/JSDOMBinding.h:

* bindings/scripts/IDLAttributes.txt:

* inspector/InspectorIndexedDBAgent.cpp:

LayoutTests:

* platform/mac-wk1/TestExpectations:
* storage/indexeddb/cursor-advance-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (193363 => 193364)


--- trunk/LayoutTests/ChangeLog	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/LayoutTests/ChangeLog	2015-12-03 20:07:00 UTC (rev 193364)
@@ -1,3 +1,13 @@
+2015-12-03  Brady Eidson  <beid...@apple.com>
+
+        Modern IDB: storage/indexeddb/cursor-advance.html fails.
+        https://bugs.webkit.org/show_bug.cgi?id=151731
+
+        Reviewed by Alex Christensen.
+
+        * platform/mac-wk1/TestExpectations:
+        * storage/indexeddb/cursor-advance-expected.txt:
+
 2015-12-03  Brent Fulgham  <bfulg...@apple.com>
 
         Allow _javascript_ to iterate over plugins for local files

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (193363 => 193364)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-12-03 20:07:00 UTC (rev 193364)
@@ -75,6 +75,7 @@
 storage/indexeddb/basics.html [ Pass ]
 storage/indexeddb/create-and-remove-object-store.html [ Pass ]
 storage/indexeddb/create-object-store-options.html [ Pass ]
+storage/indexeddb/cursor-advance.html [ Pass ]
 storage/indexeddb/cursor-basics.html [ Pass ]
 storage/indexeddb/cursor-cast.html [ Pass ]
 storage/indexeddb/cursor-finished.html [ Pass ]

Modified: trunk/LayoutTests/storage/indexeddb/cursor-advance-expected.txt (193363 => 193364)


--- trunk/LayoutTests/storage/indexeddb/cursor-advance-expected.txt	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/LayoutTests/storage/indexeddb/cursor-advance-expected.txt	2015-12-03 20:07:00 UTC (rev 193364)
@@ -181,13 +181,13 @@
 PASS cursor.advance(0) threw TypeError: Failed to execute 'advance' on 'IDBCursor': A count argument with value 0 (zero) was supplied, must be greater than 0.
 Expecting TypeError exception from cursor.advance(-1)
 PASS Exception was thrown.
-PASS cursor.advance(-1) threw TypeError: Failed to execute 'advance' on 'IDBCursor': Value is outside the 'unsigned long' value range.
+PASS cursor.advance(-1) threw TypeError: Value -1 is outside the range [0, 4294967295]
 Expecting TypeError exception from cursor.advance(0x100000000)
 PASS Exception was thrown.
-PASS cursor.advance(0x100000000) threw TypeError: Failed to execute 'advance' on 'IDBCursor': Value is outside the 'unsigned long' value range.
+PASS cursor.advance(0x100000000) threw TypeError: Value 4294967296 is outside the range [0, 4294967295]
 Expecting TypeError exception from cursor.advance(0x20000000000000)
 PASS Exception was thrown.
-PASS cursor.advance(0x20000000000000) threw TypeError: Failed to execute 'advance' on 'IDBCursor': Value is outside the 'unsigned long' value range.
+PASS cursor.advance(0x20000000000000) threw TypeError: Value 9007199254740992 is outside the range [0, 4294967295]
 
 testEdges():
 trans = db.transaction(objectStoreName, 'readonly')

Modified: trunk/Source/WebCore/ChangeLog (193363 => 193364)


--- trunk/Source/WebCore/ChangeLog	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/ChangeLog	2015-12-03 20:07:00 UTC (rev 193364)
@@ -1,3 +1,32 @@
+2015-12-03  Brady Eidson  <beid...@apple.com>
+
+        Modern IDB: storage/indexeddb/cursor-advance.html fails.
+        https://bugs.webkit.org/show_bug.cgi?id=151731
+
+        Reviewed by Alex Christensen.
+
+        No new tests (At least one failing test now passes).
+
+        * Modules/indexeddb/IDBCursor.h:
+        * Modules/indexeddb/IDBCursor.idl:
+        
+        * Modules/indexeddb/client/IDBCursorImpl.cpp:
+        (WebCore::IDBClient::IDBCursor::advance): Return a custom exception message for TypeError.
+        * Modules/indexeddb/client/IDBCursorImpl.h:
+        
+        * Modules/indexeddb/legacy/LegacyCursor.cpp:
+        (WebCore::LegacyCursor::advance):
+        * Modules/indexeddb/legacy/LegacyCursor.h:
+        
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::createDOMException):
+        (WebCore::setDOMException):
+        * bindings/js/JSDOMBinding.h:
+        
+        * bindings/scripts/IDLAttributes.txt:
+        
+        * inspector/InspectorIndexedDBAgent.cpp:
+
 2015-12-03  Brent Fulgham  <bfulg...@apple.com>
 
         Allow _javascript_ to iterate over plugins for local files

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h (193363 => 193364)


--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h	2015-12-03 20:07:00 UTC (rev 193364)
@@ -44,7 +44,7 @@
 class IDBRequest;
 class ScriptExecutionContext;
 
-typedef int ExceptionCode;
+struct ExceptionCodeWithMessage;
 
 class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor> {
 public:
@@ -66,7 +66,7 @@
     virtual IDBAny* source() = 0;
 
     virtual RefPtr<IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) = 0;
-    virtual void advance(unsigned long, ExceptionCode&) = 0;
+    virtual void advance(unsigned long, ExceptionCodeWithMessage&) = 0;
     // FIXME: Try to modify the code generator so this overload is unneeded.
     virtual void continueFunction(ScriptExecutionContext*, ExceptionCode&) = 0;
     virtual void continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) = 0;

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl (193363 => 193364)


--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl	2015-12-03 20:07:00 UTC (rev 193364)
@@ -34,7 +34,7 @@
     readonly attribute any primaryKey;
 
     [CallWith=ScriptState, RaisesException] IDBRequest update(any value);
-    [RaisesException] void advance([EnforceRange] unsigned long count);
+    [RaisesExceptionWithMessage] void advance([EnforceRange] unsigned long count);
     [CallWith=ScriptExecutionContext, ImplementedAs=continueFunction, RaisesException] void continue(optional any key);
     [CallWith=ScriptExecutionContext, ImplementedAs=deleteFunction, RaisesException] IDBRequest delete();
 };

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp (193363 => 193364)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp	2015-12-03 20:07:00 UTC (rev 193364)
@@ -144,32 +144,33 @@
     return request;
 }
 
-void IDBCursor::advance(unsigned long count, ExceptionCode& ec)
+void IDBCursor::advance(unsigned long count, ExceptionCodeWithMessage& ec)
 {
     LOG(IndexedDB, "IDBCursor::advance");
 
     if (!m_request) {
-        ec = IDBDatabaseException::InvalidStateError;
+        ec.code = IDBDatabaseException::InvalidStateError;
         return;
     }
     
     if (!count) {
-        ec = TypeError;
+        ec.code = TypeError;
+        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': A count argument with value 0 (zero) was supplied, must be greater than 0.");
         return;
     }
 
     if (sourcesDeleted()) {
-        ec = IDBDatabaseException::InvalidStateError;
+        ec.code = IDBDatabaseException::InvalidStateError;
         return;
     }
 
     if (!transaction().isActive()) {
-        ec = IDBDatabaseException::TransactionInactiveError;
+        ec.code = IDBDatabaseException::TransactionInactiveError;
         return;
     }
 
     if (!m_gotValue) {
-        ec = IDBDatabaseException::InvalidStateError;
+        ec.code = IDBDatabaseException::InvalidStateError;
         return;
     }
 

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h (193363 => 193364)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h	2015-12-03 20:07:00 UTC (rev 193364)
@@ -56,7 +56,7 @@
     virtual IDBAny* source() override final;
 
     virtual RefPtr<WebCore::IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) override final;
-    virtual void advance(unsigned long, ExceptionCode&) override final;
+    virtual void advance(unsigned long, ExceptionCodeWithMessage&) override final;
     virtual void continueFunction(ScriptExecutionContext*, ExceptionCode&) override final;
     virtual void continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
     virtual RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&) override final;

Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyCursor.cpp (193363 => 193364)


--- trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyCursor.cpp	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyCursor.cpp	2015-12-03 20:07:00 UTC (rev 193364)
@@ -127,29 +127,29 @@
     return objectStore->put(IDBDatabaseBackend::CursorUpdate, LegacyAny::create(this), state, value, m_currentPrimaryKey, ec);
 }
 
-void LegacyCursor::advance(unsigned long count, ExceptionCode& ec)
+void LegacyCursor::advance(unsigned long count, ExceptionCodeWithMessage& ec)
 {
-    ec = 0;
+    ec.code = 0;
     LOG(StorageAPI, "LegacyCursor::advance");
     if (!m_gotValue) {
-        ec = IDBDatabaseException::InvalidStateError;
+        ec.code = IDBDatabaseException::InvalidStateError;
         return;
     }
 
     if (!m_transaction->isActive()) {
-        ec = IDBDatabaseException::TransactionInactiveError;
+        ec.code = IDBDatabaseException::TransactionInactiveError;
         return;
     }
 
     if (!count) {
-        ec = TypeError;
+        ec.code = TypeError;
         return;
     }
 
     m_request->setPendingCursor(this);
     m_gotValue = false;
-    m_backend->advance(count, m_request, ec);
-    ASSERT(!ec);
+    m_backend->advance(count, m_request, ec.code);
+    ASSERT(!ec.code);
 }
 
 void LegacyCursor::continueFunction(ScriptExecutionContext* context, const Deprecated::ScriptValue& keyValue, ExceptionCode& ec)

Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyCursor.h (193363 => 193364)


--- trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyCursor.h	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyCursor.h	2015-12-03 20:07:00 UTC (rev 193364)
@@ -62,7 +62,7 @@
     IDBAny* source() override;
 
     RefPtr<IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) override;
-    void advance(unsigned long, ExceptionCode&) override;
+    void advance(unsigned long, ExceptionCodeWithMessage&) override;
     // FIXME: Try to modify the code generator so this overload is unneeded.
     void continueFunction(ScriptExecutionContext*, ExceptionCode& ec) override { continueFunction(static_cast<IDBKey*>(nullptr), ec); }
     void continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override;

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (193363 => 193364)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2015-12-03 20:07:00 UTC (rev 193364)
@@ -223,25 +223,39 @@
         errorObject = toJS(exec, globalObject, interfaceName::create(description)); \
         break;
 
-JSValue createDOMException(ExecState* exec, ExceptionCode ec)
+static JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String* message)
 {
     if (!ec)
         return jsUndefined();
 
     // FIXME: Handle other WebIDL exception types.
-    if (ec == TypeError)
-        return createTypeError(exec);
-    if (ec == RangeError)
-        return createRangeError(exec, ASCIILiteral("Bad value"));
+    if (ec == TypeError) {
+        if (!message || message->isEmpty())
+            return createTypeError(exec);
+        return createTypeError(exec, *message);
+    }
 
+    if (ec == RangeError) {
+        if (!message || message->isEmpty())
+            return createRangeError(exec, ASCIILiteral("Bad value"));
+        return createRangeError(exec, *message);
+    }
 
     // FIXME: All callers to setDOMException need to pass in the right global object
-    // for now, we're going to assume the lexicalGlobalObject.  Which is wrong in cases like this:
+    // for now, we're going to assume the lexicalGlobalObject. Which is wrong in cases like this:
     // frames[0].document.createElement(null, null); // throws an exception which should have the subframes prototypes.
     JSDOMGlobalObject* globalObject = deprecatedGlobalObjectForPrototype(exec);
 
     ExceptionCodeDescription description(ec);
 
+    CString messageCString;
+    if (message)
+        messageCString = message->utf8();
+    if (message && !message->isEmpty()) {
+        // It is safe to do this because the char* contents of the CString are copied into a new WTF::String before the CString is destroyed.
+        description.description = messageCString.data();
+    }
+
     JSValue errorObject;
     switch (description.type) {
         DOM_EXCEPTION_INTERFACES_FOR_EACH(TRY_TO_CREATE_EXCEPTION)
@@ -252,6 +266,16 @@
     return errorObject;
 }
 
+static JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String& message)
+{
+    return createDOMException(exec, ec, &message);
+}
+
+JSValue createDOMException(ExecState* exec, ExceptionCode ec)
+{
+    return createDOMException(exec, ec, nullptr);
+}
+
 void setDOMException(ExecState* exec, ExceptionCode ec)
 {
     if (!ec || exec->hadException())
@@ -260,6 +284,14 @@
     exec->vm().throwException(exec, createDOMException(exec, ec));
 }
 
+void setDOMException(JSC::ExecState* exec, const ExceptionCodeWithMessage& ec)
+{
+    if (!ec.code || exec->hadException())
+        return;
+
+    exec->vm().throwException(exec, createDOMException(exec, ec.code, ec.message));
+}
+
 #undef TRY_TO_CREATE_EXCEPTION
 
 bool shouldAllowAccessToNode(ExecState* exec, Node* node)

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (193363 => 193364)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2015-12-03 20:07:00 UTC (rev 193364)
@@ -68,8 +68,7 @@
 class URL;
 class Node;
 
-typedef int ExceptionCode;
-
+struct ExceptionCodeWithMessage;
 struct ExceptionDetails {
     String message;
     int lineNumber { 0 };
@@ -77,6 +76,8 @@
     String sourceURL;
 };
 
+typedef int ExceptionCode;
+
 DOMWindow& activeDOMWindow(JSC::ExecState*);
 DOMWindow& firstDOMWindow(JSC::ExecState*);
 
@@ -289,6 +290,7 @@
 
 // Convert a DOM implementation exception code into a _javascript_ exception in the execution state.
 WEBCORE_EXPORT void setDOMException(JSC::ExecState*, ExceptionCode);
+void setDOMException(JSC::ExecState*, const ExceptionCodeWithMessage&);
 
 JSC::JSValue jsString(JSC::ExecState*, const URL&); // empty if the URL is null
 

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (193363 => 193364)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt	2015-12-03 20:07:00 UTC (rev 193364)
@@ -107,6 +107,7 @@
 Private
 PutForwards=*
 RaisesException
+RaisesExceptionWithMessage
 Reflect=*
 Replaceable
 ReplaceableConstructor

Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (193363 => 193364)


--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2015-12-03 20:06:17 UTC (rev 193363)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2015-12-03 20:07:00 UTC (rev 193364)
@@ -455,9 +455,9 @@
         RefPtr<IDBCursorWithValue> idbCursor = requestResult->idbCursorWithValue();
 
         if (m_skipCount) {
-            ExceptionCode ec = 0;
+            ExceptionCodeWithMessage ec;
             idbCursor->advance(m_skipCount, ec);
-            if (ec)
+            if (ec.code)
                 m_requestCallback->sendFailure("Could not advance cursor.");
             m_skipCount = 0;
             return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to