Changeset 73605 in webkit


Ignore:
Timestamp:
Dec 9, 2010 4:29:55 AM (13 years ago)
Author:
jorlow@chromium.org
Message:

2010-12-07 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Steve Block.

IndexedDB returns the wrong exceptions
https://bugs.webkit.org/show_bug.cgi?id=50632

  • storage/indexeddb/constants-expected.txt:
  • storage/indexeddb/constants.html:
  • storage/indexeddb/objectstore-removeobjectstore-expected.txt:
  • storage/indexeddb/objectstore-removeobjectstore.html:

2010-12-07 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Steve Block.

IndexedDB returns the wrong exceptions
https://bugs.webkit.org/show_bug.cgi?id=50632

IndexedDB exceptions need to have an offset so they can
be distinguished from DOM exceptions. We also need to
add strings for the various exceptions. Lastly, make
IDBDatabaseException use the common exception base class.

  • bindings/js/JSDOMBinding.cpp: (WebCore::setDOMException):
  • bindings/v8/V8Proxy.cpp: (WebCore::V8Proxy::setDOMException):
  • dom/ExceptionCode.cpp: (WebCore::getExceptionCodeDescription):
  • dom/ExceptionCode.h:
  • storage/IDBDatabaseError.h: (WebCore::IDBDatabaseError::code):
  • storage/IDBDatabaseException.h: (WebCore::IDBDatabaseException::create): (WebCore::IDBDatabaseException::ErrorCodeToExceptionCode): (WebCore::IDBDatabaseException::IDBDatabaseException):
  • storage/IDBDatabaseException.idl:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r73601 r73605  
     12010-12-07  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        IndexedDB returns the wrong exceptions
     6        https://bugs.webkit.org/show_bug.cgi?id=50632
     7
     8        * storage/indexeddb/constants-expected.txt:
     9        * storage/indexeddb/constants.html:
     10        * storage/indexeddb/objectstore-removeobjectstore-expected.txt:
     11        * storage/indexeddb/objectstore-removeobjectstore.html:
     12
    1132010-12-09  Pavel Feldman  <pfeldman@chromium.org>
    214
  • trunk/LayoutTests/storage/indexeddb/constants-expected.txt

    r72767 r73605  
    55
    66PASS webkitIDBDatabaseException.UNKNOWN_ERR is 1
    7 PASS webkitIDBDatabaseException.NON_TRANSIENT_ERR is 1
    8 PASS webkitIDBDatabaseException.NOT_FOUND_ERR is 2
    9 PASS webkitIDBDatabaseException.CONSTRAINT_ERR is 3
    10 PASS webkitIDBDatabaseException.DATA_ERR is 4
    11 PASS webkitIDBDatabaseException.NOT_ALLOWED_ERR is 5
    12 PASS webkitIDBDatabaseException.SERIAL_ERR is 11
    13 PASS webkitIDBDatabaseException.RECOVERABLE_ERR is 21
    14 PASS webkitIDBDatabaseException.TRANSIENT_ERR is 31
    15 PASS webkitIDBDatabaseException.TIMEOUT_ERR is 32
    16 PASS webkitIDBDatabaseException.DEADLOCK_ERR is 33
     7PASS webkitIDBDatabaseException.NON_TRANSIENT_ERR is 2
     8PASS webkitIDBDatabaseException.NOT_FOUND_ERR is 3
     9PASS webkitIDBDatabaseException.CONSTRAINT_ERR is 4
     10PASS webkitIDBDatabaseException.DATA_ERR is 5
     11PASS webkitIDBDatabaseException.NOT_ALLOWED_ERR is 6
     12PASS webkitIDBDatabaseException.SERIAL_ERR is 7
     13PASS webkitIDBDatabaseException.RECOVERABLE_ERR is 8
     14PASS webkitIDBDatabaseException.TRANSIENT_ERR is 9
     15PASS webkitIDBDatabaseException.TIMEOUT_ERR is 10
     16PASS webkitIDBDatabaseException.DEADLOCK_ERR is 11
    1717PASS webkitIDBRequest.LOADING is 1
    1818PASS webkitIDBRequest.DONE is 2
  • trunk/LayoutTests/storage/indexeddb/constants.html

    r72767 r73605  
    1818{
    1919    shouldBe("webkitIDBDatabaseException.UNKNOWN_ERR", "1");
    20     shouldBe("webkitIDBDatabaseException.NON_TRANSIENT_ERR", "1");
    21     shouldBe("webkitIDBDatabaseException.NOT_FOUND_ERR", "2");
    22     shouldBe("webkitIDBDatabaseException.CONSTRAINT_ERR", "3");
    23     shouldBe("webkitIDBDatabaseException.DATA_ERR", "4");
    24     shouldBe("webkitIDBDatabaseException.NOT_ALLOWED_ERR", "5");
    25     shouldBe("webkitIDBDatabaseException.SERIAL_ERR", "11");
    26     shouldBe("webkitIDBDatabaseException.RECOVERABLE_ERR", "21");
    27     shouldBe("webkitIDBDatabaseException.TRANSIENT_ERR", "31");
    28     shouldBe("webkitIDBDatabaseException.TIMEOUT_ERR", "32");
    29     shouldBe("webkitIDBDatabaseException.DEADLOCK_ERR", "33");
     20    shouldBe("webkitIDBDatabaseException.NON_TRANSIENT_ERR", "2");
     21    shouldBe("webkitIDBDatabaseException.NOT_FOUND_ERR", "3");
     22    shouldBe("webkitIDBDatabaseException.CONSTRAINT_ERR", "4");
     23    shouldBe("webkitIDBDatabaseException.DATA_ERR", "5");
     24    shouldBe("webkitIDBDatabaseException.NOT_ALLOWED_ERR", "6");
     25    shouldBe("webkitIDBDatabaseException.SERIAL_ERR", "7");
     26    shouldBe("webkitIDBDatabaseException.RECOVERABLE_ERR", "8");
     27    shouldBe("webkitIDBDatabaseException.TRANSIENT_ERR", "9");
     28    shouldBe("webkitIDBDatabaseException.TIMEOUT_ERR", "10");
     29    shouldBe("webkitIDBDatabaseException.DEADLOCK_ERR", "11");
    3030
    3131    shouldBe("webkitIDBRequest.LOADING", "1");
  • trunk/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt

    r72771 r73605  
    122122PASS event.target.readyState is event.target.DONE
    123123
    124 PASS event.code is 2
     124PASS event.code is webkitIDBDatabaseException.NOT_FOUND_ERR
    125125PASS event.source.indexNames.contains('indexName') is false
    126126PASS successfullyParsed is true
  • trunk/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html

    r72771 r73605  
    113113{
    114114    verifyErrorEvent(event);
    115     shouldBe("event.code", "2");
     115    shouldBe("event.code", "webkitIDBDatabaseException.NOT_FOUND_ERR");
    116116    shouldBeFalse("event.source.indexNames.contains('indexName')");
    117117
  • trunk/WebCore/ChangeLog

    r73603 r73605  
     12010-12-07  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        IndexedDB returns the wrong exceptions
     6        https://bugs.webkit.org/show_bug.cgi?id=50632
     7
     8        IndexedDB exceptions need to have an offset so they can
     9        be distinguished from DOM exceptions.  We also need to
     10        add strings for the various exceptions.  Lastly, make
     11        IDBDatabaseException use the common exception base class.
     12
     13        * bindings/js/JSDOMBinding.cpp:
     14        (WebCore::setDOMException):
     15        * bindings/v8/V8Proxy.cpp:
     16        (WebCore::V8Proxy::setDOMException):
     17        * dom/ExceptionCode.cpp:
     18        (WebCore::getExceptionCodeDescription):
     19        * dom/ExceptionCode.h:
     20        * storage/IDBDatabaseError.h:
     21        (WebCore::IDBDatabaseError::code):
     22        * storage/IDBDatabaseException.h:
     23        (WebCore::IDBDatabaseException::create):
     24        (WebCore::IDBDatabaseException::ErrorCodeToExceptionCode):
     25        (WebCore::IDBDatabaseException::IDBDatabaseException):
     26        * storage/IDBDatabaseException.idl:
     27
    1282010-12-09  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
    229
  • trunk/WebCore/bindings/js/JSDOMBinding.cpp

    r73532 r73605  
    8585#include "FileException.h"
    8686#include "JSFileException.h"
     87#endif
     88
     89#if ENABLE(INDEXED_DATABASE)
     90#include "IDBDatabaseException.h"
     91#include "JSIDBDatabaseException.h"
    8792#endif
    8893
     
    651656            break;
    652657#endif
     658#if ENABLE(INDEXED_DATABASE)
     659        case IDBDatabaseExceptionType:
     660            errorObject = toJS(exec, globalObject, IDBDatabaseException::create(description));
     661            break;
     662#endif
    653663    }
    654664
  • trunk/WebCore/bindings/v8/V8Proxy.cpp

    r72387 r73605  
    3838#include "Frame.h"
    3939#include "FrameLoaderClient.h"
     40#include "IDBDatabaseException.h"
    4041#include "IDBFactoryBackendInterface.h"
    4142#include "IDBPendingTransactionMonitor.h"
     
    6566#include "WorkerContextExecutionProxy.h"
    6667
     68#if ENABLE(INDEXED_DATABASE)
     69#include "V8IDBDatabaseException.h"
     70#endif
     71
    6772#if ENABLE(SVG)
    6873#include "V8SVGException.h"
     
    674679        break;
    675680#endif
     681#if ENABLE(INDEXED_DATABASE)
     682    case IDBDatabaseExceptionType:
     683        exception = toV8(IDBDatabaseException::create(description));
     684        break;
     685#endif
    676686    default:
    677687        ASSERT_NOT_REACHED();
  • trunk/WebCore/dom/ExceptionCode.cpp

    r72500 r73605  
    2828
    2929#include "EventException.h"
     30#include "IDBDatabaseException.h"
    3031#include "RangeException.h"
    3132#include "XMLHttpRequestException.h"
     
    207208    "The path supplied exists, but was not an entry of requested type.",
    208209    "An attempt was made to create a file or directory where an element already exists."
     210};
     211#endif
     212
     213#if ENABLE(INDEXED_DATABASE)
     214static const char* const idbDatabaseExceptionNames[] = {
     215    "UNKNOWN_ERR",
     216    "NON_TRANSIENT_ERR",
     217    "NOT_FOUND_ERR",
     218    "CONSTRAINT_ERR",
     219    "DATA_ERR",
     220    "NOT_ALLOWED_ERR",
     221    "SERIAL_ERR",
     222    "RECOVERABLE_ERR",
     223    "TRANSIENT_ERR",
     224    "TIMEOUT_ERR",
     225    "DEADLOCK_ERR"
     226};
     227
     228static const char* const idbDatabaseExceptionDescriptions[] = {
     229    "An unknown error occurred within Indexed Database.",
     230    "NON_TRANSIENT_ERR", // FIXME: Write a better message if it's ever possible this is thrown.
     231    "The name supplied does not match any existing item.",
     232    "The request cannot be completed due to a failed constraint.",
     233    "The data provided does not meet the requirements of the function.",
     234    "This function is not allowed to be called in such a context.",
     235    "The data supplied cannot be serialized according to the structured cloning algorithm.",
     236    "RECOVERABLE_ERR", // FIXME: This isn't even used.
     237    "TRANSIENT_ERR", // FIXME: This isn't even used.
     238    "TIMEOUT_ERR", // This can't be thrown.
     239    "DEADLOCK_ERR" // This can't be thrown.
    209240};
    210241#endif
     
    288319        nameTableOffset = FileException::NOT_FOUND_ERR;
    289320#endif
     321#if ENABLE(INDEXED_DATABASE)
     322    } else if (code >= IDBDatabaseException::IDBDatabaseExceptionOffset && code <= IDBDatabaseException::IDBDatabaseExceptionMax) {
     323        type = IDBDatabaseExceptionType;
     324        typeName = "DOM IDBDatabase";
     325        code -= IDBDatabaseException::IDBDatabaseExceptionOffset;
     326        nameTable = idbDatabaseExceptionNames;
     327        descriptionTable = idbDatabaseExceptionDescriptions;
     328        nameTableSize = WTF_ARRAY_LENGTH(idbDatabaseExceptionNames);
     329        nameTableOffset = IDBDatabaseException::UNKNOWN_ERR;
     330#endif
    290331    } else {
    291332        type = DOMExceptionType;
  • trunk/WebCore/dom/ExceptionCode.h

    r70438 r73605  
    8585        , FileExceptionType
    8686#endif
     87#if ENABLE(INDEXED_DATABASE)
     88        , IDBDatabaseExceptionType
     89#endif
    8790    };
    8891
  • trunk/WebCore/storage/IDBDatabaseError.h

    r60357 r73605  
    2727#define IDBDatabaseError_h
    2828
     29#include "IDBDatabaseException.h"
    2930#include "PlatformString.h"
    3031#include <wtf/PassRefPtr.h>
     
    4344    ~IDBDatabaseError() { }
    4445
    45     unsigned short code() const { return m_code; }
     46    unsigned short code() const { return m_code - IDBDatabaseException::IDBDatabaseExceptionOffset; }
    4647    void setCode(unsigned short value) { m_code = value; }
    4748    const String& message() const { return m_message; }
  • trunk/WebCore/storage/IDBDatabaseException.h

    r70531 r73605  
    2727#define IDBDatabaseException_h
    2828
    29 #include "PlatformString.h"
    30 #include <wtf/PassRefPtr.h>
    31 #include <wtf/RefCounted.h>
     29#if ENABLE(INDEXED_DATABASE)
    3230
    33 #if ENABLE(INDEXED_DATABASE)
     31#include "ExceptionBase.h"
    3432
    3533namespace WebCore {
    3634
    37 class IDBDatabaseException : public RefCounted<IDBDatabaseException> {
     35class IDBDatabaseException : public ExceptionBase {
    3836public:
    39     static PassRefPtr<IDBDatabaseException> create()
     37    static PassRefPtr<IDBDatabaseException> create(const ExceptionCodeDescription& description)
    4038    {
    41         return adoptRef(new IDBDatabaseException());
     39        return adoptRef(new IDBDatabaseException(description));
    4240    }
    43     ~IDBDatabaseException() { }
    4441
    45     enum ErrorCode {
    46         UNKNOWN_ERR = 1,
    47         NON_TRANSIENT_ERR = 1,
    48         NOT_FOUND_ERR = 2,
    49         CONSTRAINT_ERR = 3,
    50         DATA_ERR = 4,
    51         NOT_ALLOWED_ERR = 5,
    52         SERIAL_ERR = 11,
    53         RECOVERABLE_ERR = 21,
    54         TRANSIENT_ERR = 31,
    55         TIMEOUT_ERR = 32,
    56         DEADLOCK_ERR = 33
     42    static const int IDBDatabaseExceptionOffset = 1200;
     43    static const int IDBDatabaseExceptionMax = 1299;
     44
     45    enum IDBDatabaseExceptionCode {
     46        UNKNOWN_ERR = IDBDatabaseExceptionOffset + 1,
     47        NON_TRANSIENT_ERR = IDBDatabaseExceptionOffset + 2,
     48        NOT_FOUND_ERR = IDBDatabaseExceptionOffset + 3,
     49        CONSTRAINT_ERR = IDBDatabaseExceptionOffset + 4,
     50        DATA_ERR = IDBDatabaseExceptionOffset + 5,
     51        NOT_ALLOWED_ERR = IDBDatabaseExceptionOffset + 6,
     52        SERIAL_ERR = IDBDatabaseExceptionOffset + 7,
     53        RECOVERABLE_ERR = IDBDatabaseExceptionOffset + 8,
     54        TRANSIENT_ERR = IDBDatabaseExceptionOffset + 9,
     55        TIMEOUT_ERR = IDBDatabaseExceptionOffset + 10,
     56        DEADLOCK_ERR = IDBDatabaseExceptionOffset + 11
    5757    };
    58    
    59     unsigned short code() const { return m_code; }
    60     void setCode(unsigned short value) { m_code = value; }
    61     String message() const { return m_message; }
    62     void setMessage(const String& value) { m_message = value; }
     58
     59    static int ErrorCodeToExceptionCode(int errorCode)
     60    {
     61        if (!errorCode)
     62            return 0;
     63        return errorCode + IDBDatabaseExceptionOffset;
     64    }
    6365
    6466private:
    65     IDBDatabaseException() { }
    66 
    67     unsigned short m_code;
    68     String m_message;
     67    IDBDatabaseException(const ExceptionCodeDescription& description)
     68        : ExceptionBase(description)
     69    {
     70    }
    6971};
    7072
  • trunk/WebCore/storage/IDBDatabaseException.idl

    r70531 r73605  
    2727
    2828    interface [
    29         Conditional=INDEXED_DATABASE
     29        Conditional=INDEXED_DATABASE,
     30        DontCheckEnums
    3031    ] IDBDatabaseException {
    31         // FIXME: These error codes conflict with others.
     32
     33        readonly attribute unsigned short   code;
     34        readonly attribute DOMString        name;
     35        readonly attribute DOMString        message;
     36
     37#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
     38        // Override in a Mozilla compatible format
     39        [DontEnum] DOMString toString();
     40#endif
     41
    3242        const unsigned short UNKNOWN_ERR = 1;
    33         const unsigned short NON_TRANSIENT_ERR = 1;
    34         const unsigned short NOT_FOUND_ERR = 2;
    35         const unsigned short CONSTRAINT_ERR = 3;
    36         const unsigned short DATA_ERR = 4;
    37         const unsigned short NOT_ALLOWED_ERR = 5;
    38         const unsigned short SERIAL_ERR = 11;
    39         const unsigned short RECOVERABLE_ERR = 21;
    40         const unsigned short TRANSIENT_ERR = 31;
    41         const unsigned short TIMEOUT_ERR = 32;
    42         const unsigned short DEADLOCK_ERR = 33;
    43 
    44         attribute unsigned short code;
    45         attribute DOMString message;
     43        const unsigned short NON_TRANSIENT_ERR = 2;
     44        const unsigned short NOT_FOUND_ERR = 3;
     45        const unsigned short CONSTRAINT_ERR = 4;
     46        const unsigned short DATA_ERR = 5;
     47        const unsigned short NOT_ALLOWED_ERR = 6;
     48        const unsigned short SERIAL_ERR = 7;
     49        const unsigned short RECOVERABLE_ERR = 8;
     50        const unsigned short TRANSIENT_ERR = 9;
     51        const unsigned short TIMEOUT_ERR = 10;
     52        const unsigned short DEADLOCK_ERR = 11;
    4653    };
    4754
Note: See TracChangeset for help on using the changeset viewer.