Bug 730161 - Replace IDBDatabaseException and FileException with DOMException. r=sicking
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Wed, 11 Apr 2012 17:55:21 -0400
changeset 94778 3b27921b99ebc4e6d374856aee3fcfcabfcc5864
parent 94777 37e9c8655cfd13883b22ac54490f6f9a0b5a636e
child 94779 56262a68406b6e8d9eb41736f6dcbedc8708124d
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs730161
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 730161 - Replace IDBDatabaseException and FileException with DOMException. r=sicking
content/base/public/Makefile.in
content/base/public/nsIDOMFileException.idl
content/base/src/nsGenericDOMDataNode.cpp
dom/base/domerr.msg
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/base/nsDOMError.h
dom/base/nsDOMException.cpp
dom/base/nsDOMException.h
dom/base/nsDOMScriptObjectFactory.cpp
dom/base/nsIBaseDOMException.h
dom/contacts/fallback/ContactDB.jsm
dom/indexedDB/IDBCursor.cpp
dom/indexedDB/IDBDatabase.cpp
dom/indexedDB/IDBEvents.cpp
dom/indexedDB/IDBFactory.cpp
dom/indexedDB/Makefile.in
dom/indexedDB/nsIIDBDatabaseException.idl
js/xpconnect/src/dom_quickstubs.qsconf
--- a/content/base/public/Makefile.in
+++ b/content/base/public/Makefile.in
@@ -93,17 +93,16 @@ SDK_XPIDLSRCS   = \
 		$(NULL)
 
 XPIDLSRCS	= \
 		nsIContentPolicy.idl        \
 		nsIDocumentEncoder.idl      \
 		nsIDOMFile.idl \
 		nsIDOMFileReader.idl \
 		nsIDOMFileList.idl \
-		nsIDOMFileException.idl \
 		nsIDOMFormData.idl \
 		nsIDOMParser.idl \
 		nsIDOMSerializer.idl \
 		nsISelectionController.idl  \
 		nsISelectionDisplay.idl  \
 		nsISelectionListener.idl  \
 		nsISelectionPrivate.idl  \
 		nsIScriptLoaderObserver.idl  \
deleted file mode 100644
--- a/content/base/public/nsIDOMFileException.idl
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Corporation
- * Portions created by the Initial Developer are Copyright (C) 2007
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "domstubs.idl"
-
-[scriptable, uuid(b52356e1-45c5-4d61-b61a-fb9bd91690e1)]
-interface nsIDOMFileException : nsISupports
-{
-  const unsigned short NOT_FOUND_ERR = 1;
-  const unsigned short SECURITY_ERR = 2;
-  const unsigned short ABORT_ERR = 3;
-  const unsigned short NOT_READABLE_ERR = 4;
-  const unsigned short ENCODING_ERR = 5;
- 
-  readonly attribute unsigned short code;
-};
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -302,20 +302,17 @@ nsGenericDOMDataNode::SetTextInternal(PR
   if (aCount > textLength - aOffset) {
     aCount = textLength - aOffset;
   }
 
   PRUint32 endOffset = aOffset + aCount;
 
   // Make sure the text fragment can hold the new data.
   if (aLength > aCount && !mText.CanGrowBy(aLength - aCount)) {
-    // This exception isn't per spec, but the spec doesn't actually
-    // say what to do here.
-
-    return NS_ERROR_DOM_DOMSTRING_SIZE_ERR;
+    return NS_ERROR_OUT_OF_MEMORY;
   }
 
   nsIDocument *document = GetCurrentDoc();
   mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
 
   bool haveMutationListeners = aNotify &&
     nsContentUtils::HasMutationListeners(this,
       NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED,
--- a/dom/base/domerr.msg
+++ b/dom/base/domerr.msg
@@ -33,72 +33,73 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* Error Message definitions. */
 
 
-/* DOM error codes from http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#domexception */
+/* DOM4 errors from http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#domexception */
 
-DOM_MSG_DEF_(INDEX_SIZE_ERR, "IndexSizeError", "Index or size is negative or greater than the allowed amount")
-DOM_MSG_DEF_(DOMSTRING_SIZE_ERR, "DOMStringSizeError", "The specified range of text does not fit in a DOM string")
-DOM_MSG_DEF_(HIERARCHY_REQUEST_ERR, "HierarchyRequestError", "Node cannot be inserted at the specified point in the hierarchy")
-DOM_MSG_DEF_(WRONG_DOCUMENT_ERR, "WrongDocumentError", "Node cannot be used in a document other than the one in which it was created")
-DOM_MSG_DEF_(INVALID_CHARACTER_ERR, "InvalidCharacterError", "String contains an invalid character")
-DOM_MSG_DEF_(NO_DATA_ALLOWED_ERR, "NoDataAllowedError", "Node does not contain data")
-DOM_MSG_DEF_(NO_MODIFICATION_ALLOWED_ERR, "NoModificationAllowedError", "Modifications are not allowed for this document")
-DOM_MSG_DEF_(NOT_FOUND_ERR, "NotFoundError", "Node was not found")
-DOM_MSG_DEF_(NOT_SUPPORTED_ERR, "NotSupportedError", "Operation is not supported")
-DOM_MSG_DEF_(INUSE_ATTRIBUTE_ERR, "InUseAttributeError", "Attribute already in use")
-DOM_MSG_DEF_(INVALID_STATE_ERR, "InvalidStateError", "An attempt was made to use an object that is not, or is no longer, usable")
-DOM_MSG_DEF_(SYNTAX_ERR, "SyntaxError", "An invalid or illegal string was specified")
-DOM_MSG_DEF_(INVALID_MODIFICATION_ERR, "InvalidModificationError", "An attempt was made to modify the type of the underlying objec")
-DOM_MSG_DEF_(NAMESPACE_ERR, "NamespaceError", "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces")
-DOM_MSG_DEF_(INVALID_ACCESS_ERR, "InvalidAccessError", "A parameter or an operation is not supported by the underlying object")
-DOM_MSG_DEF_(VALIDATION_ERR, "ValidationError", "A call to a method would make the Node invalid with respect to \"partial validity\", so the operation was not done")
-DOM_MSG_DEF_(TYPE_MISMATCH_ERR, "TypeMismatchError", "The type of an object is incompatible with the expected type of the parameter associated to the object")
-DOM_MSG_DEF_(SECURITY_ERR, "SecurityError", "The operation is insecure.")
-DOM_MSG_DEF_(NETWORK_ERR, "NetworkError", "A network error occurred.")
-DOM_MSG_DEF_(ABORT_ERR, "AbortError", "The operation was aborted. ")
-DOM_MSG_DEF_(URL_MISMATCH_ERR, "URLMismatchError", "The given URL does not match another URL.")
-DOM_MSG_DEF_(QUOTA_EXCEEDED_ERR, "QuotaExceededError", "The quota has been exceeded.")
-DOM_MSG_DEF_(TIMEOUT_ERR, "TimeoutError", "The operation timed out.")
-DOM_MSG_DEF_(INVALID_NODE_TYPE_ERR, "InvalidNodeTypeError", "The supplied node is incorrect or has an incorrect ancestor for this operation.")
-DOM_MSG_DEF_(DATA_CLONE_ERR, "DataCloneError", "The object could not be cloned.")
+DOM4_MSG_DEF(IndexSizeError, "Index or size is negative or greater than the allowed amount", NS_ERROR_DOM_INDEX_SIZE_ERR)
+DOM4_MSG_DEF(HierarchyRequestError, "Node cannot be inserted at the specified point in the hierarchy", NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)
+DOM4_MSG_DEF(WrongDocumentError, "Node cannot be used in a document other than the one in which it was created", NS_ERROR_DOM_WRONG_DOCUMENT_ERR)
+DOM4_MSG_DEF(InvalidCharacterError, "String contains an invalid character", NS_ERROR_DOM_INVALID_CHARACTER_ERR)
+DOM4_MSG_DEF(NoModificationAllowedError, "Modifications are not allowed for this document", NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR)
+DOM4_MSG_DEF(NotFoundError, "Node was not found", NS_ERROR_DOM_NOT_FOUND_ERR)
+DOM4_MSG_DEF(NotSupportedError, "Operation is not supported", NS_ERROR_DOM_NOT_SUPPORTED_ERR)
+DOM4_MSG_DEF(InUseAttributeError, "Attribute already in use", NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR)
+DOM4_MSG_DEF(InvalidStateError, "An attempt was made to use an object that is not, or is no longer, usable", NS_ERROR_DOM_INVALID_STATE_ERR)
+DOM4_MSG_DEF(SyntaxError, "An invalid or illegal string was specified", NS_ERROR_DOM_SYNTAX_ERR)
+DOM4_MSG_DEF(InvalidModificationError, "An attempt was made to modify the type of the underlying objec", NS_ERROR_DOM_INVALID_MODIFICATION_ERR)
+DOM4_MSG_DEF(NamespaceError, "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces", NS_ERROR_DOM_NAMESPACE_ERR)
+DOM4_MSG_DEF(InvalidAccessError, "A parameter or an operation is not supported by the underlying object", NS_ERROR_DOM_INVALID_ACCESS_ERR)
+DOM4_MSG_DEF(TypeMismatchError, "The type of an object is incompatible with the expected type of the parameter associated to the object", NS_ERROR_DOM_TYPE_MISMATCH_ERR)
+DOM4_MSG_DEF(SecurityError, "The operation is insecure.", NS_ERROR_DOM_SECURITY_ERR)
+DOM4_MSG_DEF(NetworkError, "A network error occurred.", NS_ERROR_DOM_NETWORK_ERR)
+DOM4_MSG_DEF(AbortError, "The operation was aborted. ", NS_ERROR_DOM_ABORT_ERR)
+DOM4_MSG_DEF(URLMismatchError, "The given URL does not match another URL.", NS_ERROR_DOM_URL_MISMATCH_ERR)
+DOM4_MSG_DEF(QuotaExceededError, "The quota has been exceeded.", NS_ERROR_DOM_QUOTA_EXCEEDED_ERR)
+DOM4_MSG_DEF(TimeoutError, "The operation timed out.", NS_ERROR_DOM_TIMEOUT_ERR)
+DOM4_MSG_DEF(InvalidNodeTypeError, "The supplied node is incorrect or has an incorrect ancestor for this operation.", NS_ERROR_DOM_INVALID_NODE_TYPE_ERR)
+DOM4_MSG_DEF(DataCloneError, "The object could not be cloned.", NS_ERROR_DOM_DATA_CLONE_ERR)
+
+/* XXX Should be JavaScript native TypeError */
+DOM4_MSG_DEF(TypeError, "The method parameter is missing or invalid.", NS_ERROR_TYPE_ERR)
 
 /* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */
 
 DOM_MSG_DEF(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR, "Unknown or invalid type")
 DOM_MSG_DEF(NS_ERROR_DOM_SVG_INVALID_VALUE_ERR, "One of the parameters has an invalid value")
 DOM_MSG_DEF(NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE, "The matrix could not be computed")
 
 /* DOM error codes from http://www.w3.org/TR/DOM-Level-3-XPath/ */
 
 DOM_MSG_DEF(NS_ERROR_DOM_INVALID_EXPRESSION_ERR, "The expression is not a legal expression.")
 DOM_MSG_DEF(NS_ERROR_DOM_TYPE_ERR, "The expression cannot be converted to return the specified type.")
 
-/* IndexedDB error codes http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html */
+/* IndexedDB errors http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#exceptions */
 
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR, "The operation failed for reasons unrelated to the database itself and not covered by any other error code.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR, "This error occurred because an operation was not allowed on an object. A retry of the same operation would fail unless the cause of the error is corrected.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR, "The operation failed because the requested database object could not be found. For example, an object store did not exist but was being opened.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR, "A mutation operation in the transaction failed because a constraint was not satisfied. For example, an object such as an object store or index already exists and a new one was being attempted to be created.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_DATA_ERR, "Data provided to an operation does not meet requirements.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR, "A mutation operation was attempted on a database that did not allow mutations.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR, "A request was placed against a transaction which is currently not active, or which is finished.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR, "A request was aborted, for example through a call to IDBTransaction.abort.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR, "A mutation operation was attempted in a READ_ONLY transaction.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_TIMEOUT_ERR, "A lock for the transaction could not be obtained in a reasonable time.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR, "The current transaction exceeded its quota limitations.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_VERSION_ERR, "The operation failed because the stored database is a higher version than the version requested.")
+DOM4_MSG_DEF(UnknownError, "The operation failed for reasons unrelated to the database itself and not covered by any other error code.", NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR)
+DOM4_MSG_DEF(ConstraintError, "A mutation operation in the transaction failed because a constraint was not satisfied. For example, an object such as an object store or index already exists and a new one was being attempted to be created.", NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR)
+DOM4_MSG_DEF(DataError, "Data provided to an operation does not meet requirements.", NS_ERROR_DOM_INDEXEDDB_DATA_ERR)
+DOM4_MSG_DEF(TransactionInactiveError, "A request was placed against a transaction which is currently not active, or which is finished.", NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR)
+DOM4_MSG_DEF(ReadOnlyError, "A mutation operation was attempted in a READ_ONLY transaction.", NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR)
+DOM4_MSG_DEF(VersionError, "The operation failed because the stored database is a higher version than the version requested.", NS_ERROR_DOM_INDEXEDDB_VERSION_ERR)
+
+DOM4_MSG_DEF(NotFoundError, "The operation failed because the requested database object could not be found. For example, an object store did not exist but was being opened.", NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR)
+DOM4_MSG_DEF(InvalidStateError, "A mutation operation was attempted on a database that did not allow mutations.", NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR)
+DOM4_MSG_DEF(AbortError, "A request was aborted, for example through a call to IDBTransaction.abort.", NS_ERROR_DOM_INDEXEDDB_ABORT_ERR)
+DOM4_MSG_DEF(TimeoutError, "A lock for the transaction could not be obtained in a reasonable time.", NS_ERROR_DOM_INDEXEDDB_TIMEOUT_ERR)
+DOM4_MSG_DEF(QuotaExceededError, "The current transaction exceeded its quota limitations.", NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR)
+
+/* A Non-standard IndexedDB error */
 
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR, "The operation failed because the database was prevented from taking an action. The operation might be able to succeed if the application performs some recovery steps and retries the entire transaction. For example, there was not enough remaining storage space, or the storage quota was reached and the user declined to give more space to the database.")
-DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_DEADLOCK_ERR, "The current transaction was automatically rolled back by the database because of deadlock or other transaction serialization failures.")
 
 /* DOM error codes defined by us */
 
 /* XXX string should be specified by norris */
 DOM_MSG_DEF(NS_ERROR_DOM_SECMAN_ERR, "Unable to obtain security manager")
 DOM_MSG_DEF(NS_ERROR_DOM_WRONG_TYPE_ERR, "Object is of wrong type")
 DOM_MSG_DEF(NS_ERROR_DOM_NOT_OBJECT_ERR, "Parameter is not an object")
 DOM_MSG_DEF(NS_ERROR_DOM_NOT_XPC_OBJECT_ERR, "Parameter is not a XPConnect object")
@@ -108,18 +109,18 @@ DOM_MSG_DEF(NS_ERROR_DOM_NOT_FUNCTION_ER
 DOM_MSG_DEF(NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR, "Too few parameters to method")
 DOM_MSG_DEF(NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN, "Illegal document.domain value")
 DOM_MSG_DEF(NS_ERROR_DOM_PROP_ACCESS_DENIED, "Access to property denied")
 DOM_MSG_DEF(NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED, "Access to XPConnect service denied")
 DOM_MSG_DEF(NS_ERROR_DOM_BAD_URI, "Access to restricted URI denied")
 DOM_MSG_DEF(NS_ERROR_DOM_RETVAL_UNDEFINED, "Return value is undefined")
 DOM_MSG_DEF(NS_ERROR_DOM_QUOTA_REACHED, "Persistent storage maximum size reached")
 
-DOM_MSG_DEF(NS_ERROR_DOM_FILE_NOT_FOUND_ERR, "File was not found")
-DOM_MSG_DEF(NS_ERROR_DOM_FILE_NOT_READABLE_ERR, "File could not be read")
+DOM4_MSG_DEF(NotFoundError, "File was not found", NS_ERROR_DOM_FILE_NOT_FOUND_ERR)
+DOM4_MSG_DEF(NotReadableError, "File could not be read", NS_ERROR_DOM_FILE_NOT_READABLE_ERR)
 
 /* common global codes (from nsError.h) */
 
 DOM_MSG_DEF(NS_OK                                  , "Success")
 DOM_MSG_DEF(NS_ERROR_NOT_INITIALIZED               , "Component not initialized")
 DOM_MSG_DEF(NS_ERROR_ALREADY_INITIALIZED           , "Component already initialized")
 DOM_MSG_DEF(NS_ERROR_NOT_IMPLEMENTED               , "Method not implemented")
 DOM_MSG_DEF(NS_NOINTERFACE                         , "Component does not have requested interface")
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -450,17 +450,16 @@
 #include "nsIDOMGeoPositionCoords.h"
 #include "nsIDOMGeoPositionError.h"
 
 // Workers
 #include "mozilla/dom/workers/Workers.h"
 
 #include "nsDOMFile.h"
 #include "nsDOMFileReader.h"
-#include "nsIDOMFileException.h"
 #include "nsIDOMFormData.h"
 
 #include "nsIDOMDOMStringMap.h"
 
 #include "nsIDOMDesktopNotification.h"
 #include "nsIDOMNavigatorDesktopNotification.h"
 #include "nsIDOMNavigatorGeolocation.h"
 #include "Navigator.h"
@@ -490,17 +489,16 @@
 #include "mozilla/dom/indexedDB/IDBRequest.h"
 #include "mozilla/dom/indexedDB/IDBDatabase.h"
 #include "mozilla/dom/indexedDB/IDBEvents.h"
 #include "mozilla/dom/indexedDB/IDBObjectStore.h"
 #include "mozilla/dom/indexedDB/IDBTransaction.h"
 #include "mozilla/dom/indexedDB/IDBCursor.h"
 #include "mozilla/dom/indexedDB/IDBKeyRange.h"
 #include "mozilla/dom/indexedDB/IDBIndex.h"
-#include "nsIIDBDatabaseException.h"
 
 using mozilla::dom::indexedDB::IDBWrapperCache;
 
 #include "nsIDOMMediaQueryList.h"
 
 #include "nsDOMTouchEvent.h"
 #include "nsIDOMCustomEvent.h"
 #include "nsDOMMutationObserver.h"
@@ -1393,18 +1391,16 @@ static nsDOMClassInfoData sClassInfoData
                            ARRAY_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(FileList, nsFileListSH,
                            ARRAY_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(Blob, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(File, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
-  NS_DEFINE_CLASSINFO_DATA(FileException, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(FileReader, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozURLProperty, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozBlobBuilder, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(DOMStringMap, nsDOMStringMapSH,
@@ -1592,18 +1588,16 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBIndex, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBVersionChangeEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH,
                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
-  NS_DEFINE_CLASSINFO_DATA(IDBDatabaseException, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(Touch, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(TouchList, nsDOMTouchListSH,
                            ARRAY_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(TouchEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
@@ -3992,21 +3986,16 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(File, nsIDOMFile)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFile)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(FileException, nsIDOMFileException)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileException)
-    DOM_CLASSINFO_MAP_ENTRY(nsIException)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(FileReader, nsIDOMFileReader)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileReader)
     DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozURLProperty, nsIDOMMozURLProperty)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozURLProperty)
   DOM_CLASSINFO_MAP_END
@@ -4332,21 +4321,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(IDBOpenDBRequest, nsIIDBOpenDBRequest)
     DOM_CLASSINFO_MAP_ENTRY(nsIIDBOpenDBRequest)
     DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(IDBDatabaseException, nsIIDBDatabaseException)
-    DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabaseException)
-    DOM_CLASSINFO_MAP_ENTRY(nsIException)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(Touch, nsIDOMTouch,
                                         !nsDOMTouchEvent::PrefEnabled())
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTouch)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(TouchList, nsIDOMTouchList,
                                         !nsDOMTouchEvent::PrefEnabled())
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTouchList)
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -396,17 +396,16 @@ DOMCI_CLASS(SVGForeignObjectElement)
 
 DOMCI_CLASS(XULCommandEvent)
 DOMCI_CLASS(CommandEvent)
 DOMCI_CLASS(OfflineResourceList)
 
 DOMCI_CLASS(FileList)
 DOMCI_CLASS(Blob)
 DOMCI_CLASS(File)
-DOMCI_CLASS(FileException)
 DOMCI_CLASS(FileReader)
 DOMCI_CLASS(MozURLProperty)
 DOMCI_CLASS(MozBlobBuilder)
 
 DOMCI_CLASS(DOMStringMap)
 
 // DOM modal content window class, almost identical to Window
 DOMCI_CLASS(ModalContentWindow)
@@ -515,17 +514,16 @@ DOMCI_CLASS(IDBDatabase)
 DOMCI_CLASS(IDBObjectStore)
 DOMCI_CLASS(IDBTransaction)
 DOMCI_CLASS(IDBCursor)
 DOMCI_CLASS(IDBCursorWithValue)
 DOMCI_CLASS(IDBKeyRange)
 DOMCI_CLASS(IDBIndex)
 DOMCI_CLASS(IDBVersionChangeEvent)
 DOMCI_CLASS(IDBOpenDBRequest)
-DOMCI_CLASS(IDBDatabaseException)
 
 DOMCI_CLASS(Touch)
 DOMCI_CLASS(TouchList)
 DOMCI_CLASS(TouchEvent)
 
 DOMCI_CLASS(MozCSSKeyframeRule)
 DOMCI_CLASS(MozCSSKeyframesRule)
 
--- a/dom/base/nsDOMError.h
+++ b/dom/base/nsDOMError.h
@@ -41,70 +41,69 @@
 #include "nsError.h"
 
 // XXX If you add a new error code, also add an error string to
 // dom/src/base/domerr.msg
 
 /* Standard DOM error codes: http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html */
 
 #define NS_ERROR_DOM_INDEX_SIZE_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1)
-#define NS_ERROR_DOM_DOMSTRING_SIZE_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,2)
 #define NS_ERROR_DOM_HIERARCHY_REQUEST_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,3)
 #define NS_ERROR_DOM_WRONG_DOCUMENT_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,4)
 #define NS_ERROR_DOM_INVALID_CHARACTER_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,5)
-#define NS_ERROR_DOM_NO_DATA_ALLOWED_ERR         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,6)
 #define NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,7)
 #define NS_ERROR_DOM_NOT_FOUND_ERR               NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,8)
 #define NS_ERROR_DOM_NOT_SUPPORTED_ERR           NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,9)
 #define NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,10)
 #define NS_ERROR_DOM_INVALID_STATE_ERR           NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,11)
 #define NS_ERROR_DOM_SYNTAX_ERR                  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,12)
 #define NS_ERROR_DOM_INVALID_MODIFICATION_ERR    NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,13)
 #define NS_ERROR_DOM_NAMESPACE_ERR               NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,14)
 #define NS_ERROR_DOM_INVALID_ACCESS_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,15)
-#define NS_ERROR_DOM_VALIDATION_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,16)
 #define NS_ERROR_DOM_TYPE_MISMATCH_ERR           NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,17)
 #define NS_ERROR_DOM_SECURITY_ERR                NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,18)
 #define NS_ERROR_DOM_NETWORK_ERR                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,19)
 #define NS_ERROR_DOM_ABORT_ERR                   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,20)
 #define NS_ERROR_DOM_URL_MISMATCH_ERR            NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,21)
 #define NS_ERROR_DOM_QUOTA_EXCEEDED_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,22)
 #define NS_ERROR_DOM_TIMEOUT_ERR                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,23)
 #define NS_ERROR_DOM_INVALID_NODE_TYPE_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,24)
 #define NS_ERROR_DOM_DATA_CLONE_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,25)
 
+/* XXX Should be JavaScript native TypeError */
+
+#define NS_ERROR_TYPE_ERR                        NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,26)
+
 /* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */
 
 #define NS_ERROR_DOM_SVG_WRONG_TYPE_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SVG,0)
 #define NS_ERROR_DOM_SVG_INVALID_VALUE_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SVG,1)
 #define NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SVG,2)
 
 /* DOM error codes from http://www.w3.org/TR/DOM-Level-3-XPath/ */
 
 #define NS_ERROR_DOM_INVALID_EXPRESSION_ERR      NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_XPATH, 51)
 #define NS_ERROR_DOM_TYPE_ERR                    NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_XPATH, 52)
 
 /* IndexedDB error codes http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html */
 
 #define NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,1)
-#define NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,2)
 #define NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR     NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,3)
 #define NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR    NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,4)
 #define NS_ERROR_DOM_INDEXEDDB_DATA_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,5)
 #define NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,6)
 #define NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR \
                                                  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,7)
 #define NS_ERROR_DOM_INDEXEDDB_ABORT_ERR         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,8)
 #define NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR     NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,9)
 #define NS_ERROR_DOM_INDEXEDDB_TIMEOUT_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,10)
 #define NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,11)
 #define NS_ERROR_DOM_INDEXEDDB_VERSION_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,12)
 
 #define NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,1001)
-#define NS_ERROR_DOM_INDEXEDDB_DEADLOCK_ERR   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,1002)
 
 /* DOM error codes defined by us */
 
 #define NS_ERROR_DOM_SECMAN_ERR                  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1001)
 #define NS_ERROR_DOM_WRONG_TYPE_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1002)
 #define NS_ERROR_DOM_NOT_OBJECT_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1003)
 #define NS_ERROR_DOM_NOT_XPC_OBJECT_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1004)
 #define NS_ERROR_DOM_NOT_NUMBER_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1005)
--- a/dom/base/nsDOMException.cpp
+++ b/dom/base/nsDOMException.cpp
@@ -37,97 +37,136 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCOMPtr.h"
 #include "nsCRTGlue.h"
 #include "nsDOMClassInfoID.h"
 #include "nsDOMError.h"
 #include "nsDOMException.h"
 #include "nsIDOMDOMException.h"
-#include "nsIDOMFileException.h"
 #include "nsIDOMSVGException.h"
 #include "nsIDOMXPathException.h"
-#include "nsIIDBDatabaseException.h"
 #include "nsString.h"
 #include "prprf.h"
 
-#define DOM_MSG_DEF(val, message) {(val), #val, message},
-#define DOM_MSG_DEF_(val, name, message) {(NS_ERROR_DOM_##val), name, message},
-
-#define IMPL_INTERNAL_DOM_EXCEPTION_HEAD(classname, ifname)                  \
-class classname : public nsBaseDOMException,                                 \
-                  public ifname                                              \
+#define IMPL_INTERNAL_DOM_EXCEPTION_HEAD(domname)                            \
+class ns##domname : public nsBaseDOMException,                               \
+                    public nsIDOM##domname                                   \
 {                                                                            \
 public:                                                                      \
-  classname();                                                               \
-  virtual ~classname();                                                      \
+  ns##domname();                                                             \
+  virtual ~ns##domname();                                                    \
                                                                              \
   NS_DECL_ISUPPORTS_INHERITED
 
-#define IMPL_INTERNAL_DOM_EXCEPTION_TAIL(classname, ifname, domname, module, \
-                                         mapping_function)                   \
+#define IMPL_INTERNAL_DOM_EXCEPTION_TAIL(domname)                            \
 };                                                                           \
                                                                              \
-classname::classname() {}                                                    \
-classname::~classname() {}                                                   \
+ns##domname::ns##domname() {}                                                \
+ns##domname::~ns##domname() {}                                               \
                                                                              \
-DOMCI_DATA(domname, classname)                                               \
+DOMCI_DATA(domname, ns##domname)                                             \
                                                                              \
-NS_IMPL_ADDREF_INHERITED(classname, nsBaseDOMException)                      \
-NS_IMPL_RELEASE_INHERITED(classname, nsBaseDOMException)                     \
-NS_INTERFACE_MAP_BEGIN(classname)                                            \
-  NS_INTERFACE_MAP_ENTRY(ifname)                                             \
+NS_IMPL_ADDREF_INHERITED(ns##domname, nsBaseDOMException)                    \
+NS_IMPL_RELEASE_INHERITED(ns##domname, nsBaseDOMException)                   \
+NS_INTERFACE_MAP_BEGIN(ns##domname)                                          \
+  NS_INTERFACE_MAP_ENTRY(nsIDOM##domname)                                    \
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(domname)                              \
 NS_INTERFACE_MAP_END_INHERITING(nsBaseDOMException)                          \
                                                                              \
 nsresult                                                                     \
 NS_New##domname(nsresult aNSResult, nsIException* aDefaultException,         \
-                nsIException** aException)                                   \
+                  nsIException** aException)                                 \
 {                                                                            \
-  if (!(NS_ERROR_GET_MODULE(aNSResult) == module)) {                         \
-    NS_WARNING("Trying to create an exception for the wrong error module."); \
-    return NS_ERROR_FAILURE;                                                 \
-  }                                                                          \
   const char* name;                                                          \
   const char* message;                                                       \
-  mapping_function(aNSResult, &name, &message);                              \
-  classname* inst = new classname();                                         \
+  PRUint16 code;                                                             \
+  NSResultToNameAndMessage(aNSResult, &name, &message, &code);               \
+  ns##domname* inst = new ns##domname();                                     \
   NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);                              \
-  inst->Init(aNSResult, name, message, aDefaultException);                   \
+  inst->Init(aNSResult, name, message, code, aDefaultException);             \
   *aException = inst;                                                        \
   NS_ADDREF(*aException);                                                    \
   return NS_OK;                                                              \
 }
 
+enum DOM4ErrorTypeCodeMap {
+  /* DOM4 errors from http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#domexception */
+  IndexSizeError             = nsIDOMDOMException::INDEX_SIZE_ERR,
+  HierarchyRequestError      = nsIDOMDOMException::HIERARCHY_REQUEST_ERR,
+  WrongDocumentError         = nsIDOMDOMException::WRONG_DOCUMENT_ERR,
+  InvalidCharacterError      = nsIDOMDOMException::INVALID_CHARACTER_ERR,
+  NoModificationAllowedError = nsIDOMDOMException::NO_MODIFICATION_ALLOWED_ERR,
+  NotFoundError              = nsIDOMDOMException::NOT_FOUND_ERR,
+  NotSupportedError          = nsIDOMDOMException::NOT_SUPPORTED_ERR,
+  // Can't remove until setNamedItem is removed
+  InUseAttributeError        = nsIDOMDOMException::INUSE_ATTRIBUTE_ERR,
+  InvalidStateError          = nsIDOMDOMException::INVALID_STATE_ERR,
+  SyntaxError                = nsIDOMDOMException::SYNTAX_ERR,
+  InvalidModificationError   = nsIDOMDOMException::INVALID_MODIFICATION_ERR,
+  NamespaceError             = nsIDOMDOMException::NAMESPACE_ERR,
+  InvalidAccessError         = nsIDOMDOMException::INVALID_ACCESS_ERR,
+  TypeMismatchError          = nsIDOMDOMException::TYPE_MISMATCH_ERR,
+  SecurityError              = nsIDOMDOMException::SECURITY_ERR,
+  NetworkError               = nsIDOMDOMException::NETWORK_ERR,
+  AbortError                 = nsIDOMDOMException::ABORT_ERR,
+  URLMismatchError           = nsIDOMDOMException::URL_MISMATCH_ERR,
+  QuotaExceededError         = nsIDOMDOMException::QUOTA_EXCEEDED_ERR,
+  TimeoutError               = nsIDOMDOMException::TIMEOUT_ERR,
+  InvalidNodeTypeError       = nsIDOMDOMException::INVALID_NODE_TYPE_ERR,
+  DataCloneError             = nsIDOMDOMException::DATA_CLONE_ERR,
+
+  /* XXX Should be JavaScript native TypeError */
+  TypeError                  = 0,
+
+  /* IndexedDB errors http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#exceptions */
+  UnknownError             = 0,
+  ConstraintError          = 0,
+  DataError                = 0,
+  TransactionInactiveError = 0,
+  ReadOnlyError            = 0,
+  VersionError             = 0,
+
+  /* File API errors http://dev.w3.org/2006/webapi/FileAPI/#ErrorAndException */
+  NotReadableError         = 0,
+};
+
+#define DOM4_MSG_DEF(name, message, nsresult) {(nsresult), name, #name, message},
+#define DOM_MSG_DEF(val, message) {(val), NS_ERROR_GET_CODE(val), #val, message},
+
 static struct ResultStruct
 {
   nsresult mNSResult;
+  PRUint16 mCode;
   const char* mName;
   const char* mMessage;
 } gDOMErrorMsgMap[] = {
 #include "domerr.msg"
-  {0, nsnull, nsnull}   // sentinel to mark end of array
+  {0, 0, nsnull, nsnull}   // sentinel to mark end of array
 };
 
+#undef DOM4_MSG_DEF
 #undef DOM_MSG_DEF
-#undef DOM_MSG_DEF_
 
 static void
 NSResultToNameAndMessage(nsresult aNSResult,
                          const char** aName,
-                         const char** aMessage)
+                         const char** aMessage,
+                         PRUint16* aCode)
 {
   *aName = nsnull;
   *aMessage = nsnull;
+  *aCode = 0;
   ResultStruct* result_struct = gDOMErrorMsgMap;
 
   while (result_struct->mName) {
     if (aNSResult == result_struct->mNSResult) {
       *aName = result_struct->mName;
       *aMessage = result_struct->mMessage;
+      *aCode = result_struct->mCode;
       return;
     }
 
     ++result_struct;
   }
 
   NS_WARNING("Huh, someone is throwing non-DOM errors using the DOM module!");
 
@@ -135,111 +174,64 @@ NSResultToNameAndMessage(nsresult aNSRes
 }
 
 nsresult
 NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
                                    const char** aMessage)
 {
   const char* name = nsnull;
   const char* message = nsnull;
-  NSResultToNameAndMessage(aNSResult, &name, &message);
+  PRUint16 code = 0;
+  NSResultToNameAndMessage(aNSResult, &name, &message, &code);
 
   if (name && message) {
     *aName = name;
     *aMessage = message;
     return NS_OK;
   }
 
   return NS_ERROR_NOT_AVAILABLE;
 }
 
-IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsDOMException, nsIDOMDOMException)
+IMPL_INTERNAL_DOM_EXCEPTION_HEAD(DOMException)
   NS_DECL_NSIDOMDOMEXCEPTION
-IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsDOMException, nsIDOMDOMException,
-                                 DOMException, NS_ERROR_MODULE_DOM,
-                                 NSResultToNameAndMessage)
+IMPL_INTERNAL_DOM_EXCEPTION_TAIL(DOMException)
 
 NS_IMETHODIMP
 nsDOMException::GetCode(PRUint16* aCode)
 {
   NS_ENSURE_ARG_POINTER(aCode);
-  nsresult result;
-  GetResult(&result);
-  *aCode = NS_ERROR_GET_CODE(result);
+  *aCode = mCode;
 
   return NS_OK;
 }
 
-IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsSVGException, nsIDOMSVGException)
+IMPL_INTERNAL_DOM_EXCEPTION_HEAD(SVGException)
   NS_DECL_NSIDOMSVGEXCEPTION
-IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsSVGException, nsIDOMSVGException,
-                                 SVGException, NS_ERROR_MODULE_SVG,
-                                 NSResultToNameAndMessage)
+IMPL_INTERNAL_DOM_EXCEPTION_TAIL(SVGException)
 
 NS_IMETHODIMP
 nsSVGException::GetCode(PRUint16* aCode)
 {
   NS_ENSURE_ARG_POINTER(aCode);
-  nsresult result;
-  GetResult(&result);
-  *aCode = NS_ERROR_GET_CODE(result);
+  *aCode = mCode;
 
   return NS_OK;
 }
 
-IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsXPathException, nsIDOMXPathException)
+IMPL_INTERNAL_DOM_EXCEPTION_HEAD(XPathException)
   NS_DECL_NSIDOMXPATHEXCEPTION
-IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsXPathException, nsIDOMXPathException,
-                                 XPathException, NS_ERROR_MODULE_DOM_XPATH,
-                                 NSResultToNameAndMessage)
+IMPL_INTERNAL_DOM_EXCEPTION_TAIL(XPathException)
 
 NS_IMETHODIMP
 nsXPathException::GetCode(PRUint16* aCode)
 {
   NS_ENSURE_ARG_POINTER(aCode);
-  nsresult result;
-  GetResult(&result);
-  *aCode = NS_ERROR_GET_CODE(result);
-
-  return NS_OK;
-}
-
-IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsDOMFileException, nsIDOMFileException)
-  NS_DECL_NSIDOMFILEEXCEPTION
-IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsDOMFileException, nsIDOMFileException,
-                                 FileException, NS_ERROR_MODULE_DOM_FILE,
-                                 NSResultToNameAndMessage)
+  *aCode = mCode;
 
-NS_IMETHODIMP
-nsDOMFileException::GetCode(PRUint16* aCode)
-{
-  NS_ENSURE_ARG_POINTER(aCode);
-  nsresult result;
-  GetResult(&result);
-  *aCode = NS_ERROR_GET_CODE(result);
-
-  return NS_OK;
-}
-
-IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsIDBDatabaseException,
-                                 nsIIDBDatabaseException)
-  NS_DECL_NSIIDBDATABASEEXCEPTION
-IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsIDBDatabaseException,
-                                 nsIIDBDatabaseException,
-                                 IDBDatabaseException,
-                                 NS_ERROR_MODULE_DOM_INDEXEDDB,
-                                 NSResultToNameAndMessage)
-
-NS_IMETHODIMP
-nsIDBDatabaseException::GetCode(PRUint16* aCode)
-{
-  NS_ASSERTION(aCode, "Null pointer!");
-  nsresult result;
-  GetResult(&result);
-  *aCode = NS_ERROR_GET_CODE(result);
   return NS_OK;
 }
 
 nsBaseDOMException::nsBaseDOMException()
 {
 }
 
 nsBaseDOMException::~nsBaseDOMException()
@@ -396,27 +388,27 @@ nsBaseDOMException::ToString(char **aRet
   }
 
   if (location.IsEmpty()) {
     location = defaultLocation;
   }
 
   const char* msg = mMessage ? mMessage : defaultMsg;
   const char* resultName = mName ? mName : defaultName;
-  PRUint32 code = NS_ERROR_GET_CODE(mResult);
 
-  *aReturn = PR_smprintf(format, msg, code, mResult, resultName,
+  *aReturn = PR_smprintf(format, msg, mCode, mResult, resultName,
                          location.get());
 
   return *aReturn ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 NS_IMETHODIMP
 nsBaseDOMException::Init(nsresult aNSResult, const char* aName,
-                         const char* aMessage,
+                         const char* aMessage, PRUint16 aCode,
                          nsIException* aDefaultException)
 {
   mResult = aNSResult;
   mName = aName;
   mMessage = aMessage;
+  mCode = aCode;
   mInner = aDefaultException;
   return NS_OK;
 }
--- a/dom/base/nsDOMException.h
+++ b/dom/base/nsDOMException.h
@@ -46,33 +46,32 @@ class nsBaseDOMException : public nsIExc
 {
 public:
   nsBaseDOMException();
   virtual ~nsBaseDOMException();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIEXCEPTION
   NS_IMETHOD Init(nsresult aNSResult, const char* aName,
-                  const char* aMessage,
+                  const char* aMessage, PRUint16 aCode,
                   nsIException* aDefaultException);
 
 protected:
   nsresult mResult;
   const char* mName;
   const char* mMessage;
+  PRUint16 mCode;                                                            \
   nsCOMPtr<nsIException> mInner;
 };
 
 nsresult
 NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
                                    const char** aMessage);
 
 #define DECL_INTERNAL_DOM_EXCEPTION(domname)                                 \
 nsresult                                                                     \
 NS_New##domname(nsresult aNSResult, nsIException* aDefaultException,         \
                 nsIException** aException);
 
 
 DECL_INTERNAL_DOM_EXCEPTION(DOMException)
 DECL_INTERNAL_DOM_EXCEPTION(SVGException)
 DECL_INTERNAL_DOM_EXCEPTION(XPathException)
-DECL_INTERNAL_DOM_EXCEPTION(FileException)
-DECL_INTERNAL_DOM_EXCEPTION(IDBDatabaseException)
--- a/dom/base/nsDOMScriptObjectFactory.cpp
+++ b/dom/base/nsDOMScriptObjectFactory.cpp
@@ -383,18 +383,18 @@ nsDOMExceptionProvider::GetException(nsr
   switch (NS_ERROR_GET_MODULE(result))
   {
     case NS_ERROR_MODULE_SVG:
       return NS_NewSVGException(result, aDefaultException, _retval);
     case NS_ERROR_MODULE_DOM_XPATH:
       return NS_NewXPathException(result, aDefaultException, _retval);
     case NS_ERROR_MODULE_XPCONNECT:
       return CreateXPConnectException(result, aDefaultException, _retval);
-    case NS_ERROR_MODULE_DOM_FILE:
-      return NS_NewFileException(result, aDefaultException, _retval);
-    case NS_ERROR_MODULE_DOM_INDEXEDDB:
-      return NS_NewIDBDatabaseException(result, aDefaultException, _retval);
     default:
+      MOZ_ASSERT(NS_ERROR_GET_MODULE(result) == NS_ERROR_MODULE_DOM ||
+          NS_ERROR_GET_MODULE(result) == NS_ERROR_MODULE_DOM_FILE ||
+          NS_ERROR_GET_MODULE(result) == NS_ERROR_MODULE_DOM_INDEXEDDB,
+          "Trying to create an exception for the wrong error module.");
       return NS_NewDOMException(result, aDefaultException, _retval);
   }
   NS_NOTREACHED("Not reached");
   return NS_ERROR_UNEXPECTED;
 }
--- a/dom/base/nsIBaseDOMException.h
+++ b/dom/base/nsIBaseDOMException.h
@@ -44,25 +44,25 @@
 
 // {1f13b201-39fa-11d6-a7f2-df501ff820dc}
 #define NS_BASE_DOM_EXCEPTION_CID  \
 { 0x1f13b201, 0x39fa, 0x11d6, \
 { 0xa7, 0xf2, 0xdf, 0x50, 0x1f, 0xf8, 0x20, 0xdc } }
 
 // {731d9701-39f8-11d6-a7f2-b39073384c9c}
 #define NS_IBASEDOMEXCEPTION_IID  \
-{ 0x731d9701, 0x39f8, 0x11d6, \
-{ 0xa7, 0xf2, 0xb3, 0x90, 0x73, 0x38, 0x4c, 0x9c } }
+{ 0xb33afd76, 0x5531, 0x423b, \
+{ 0x99, 0x42, 0x90, 0x69, 0xf0, 0x9a, 0x3f, 0x5c } }
 
 class nsIBaseDOMException : public nsISupports {
 public:  
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IBASEDOMEXCEPTION_IID)
 
   NS_IMETHOD Init(nsresult aNSResult, const char* aName,
-                  const char* aMessage,
+                  const char* aMessage, PRUint16 aCode,
                   nsIException* aDefaultException) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIBaseDOMException, NS_IBASEDOMEXCEPTION_IID)
 
 #define IMPL_DOM_EXCEPTION_HEAD(classname, ifname)                           \
 class classname : public nsIException,                                       \
                   public ifname                                              \
--- a/dom/contacts/fallback/ContactDB.jsm
+++ b/dom/contacts/fallback/ContactDB.jsm
@@ -148,34 +148,34 @@ ContactDB.prototype = {
       let store = txn.objectStore(STORE_NAME);
 
       txn.oncomplete = function (event) {
         debug("Transaction complete. Returning to callback.");
         successCb(txn.result);
       };
 
       txn.onabort = function (event) {
-        debug("Caught error on transaction" + event.target.errorCode);
-        switch(event.target.errorCode) {
-          case Ci.nsIIDBDatabaseException.ABORT_ERR:
-          case Ci.nsIIDBDatabaseException.CONSTRAINT_ERR:
-          case Ci.nsIIDBDatabaseException.DATA_ERR:
-          case Ci.nsIIDBDatabaseException.TRANSIENT_ERR:
-          case Ci.nsIIDBDatabaseException.NOT_ALLOWED_ERR:
-          case Ci.nsIIDBDatabaseException.NOT_FOUND_ERR:
-          case Ci.nsIIDBDatabaseException.QUOTA_ERR:
-          case Ci.nsIIDBDatabaseException.READ_ONLY_ERR:
-          case Ci.nsIIDBDatabaseException.TIMEOUT_ERR:
-          case Ci.nsIIDBDatabaseException.TRANSACTION_INACTIVE_ERR:
-          case Ci.nsIIDBDatabaseException.VERSION_ERR:
-          case Ci.nsIIDBDatabaseException.UNKNOWN_ERR:
+        debug("Caught error on transaction" + event.target.error.name);
+        switch(event.target.error.name) {
+          case "AbortError":
+          case "ConstraintError":
+          case "DataError":
+          case "SyntaxError":
+          case "InvalidStateError":
+          case "NotFoundError":
+          case "QuotaExceededError":
+          case "ReadOnlyError":
+          case "TimeoutError":
+          case "TransactionInactiveError":
+          case "VersionError":
+          case "UnknownError":
             failureCb("UnknownError");
             break;
           default:
-            debug("Unknown errorCode", event.target.errorCode);
+            debug("Unknown error", event.target.error.name);
             failureCb("UnknownError");
             break;
         }
       };
       callback(txn, store);
     }, failureCb);
   },
 
--- a/dom/indexedDB/IDBCursor.cpp
+++ b/dom/indexedDB/IDBCursor.cpp
@@ -254,17 +254,17 @@ IDBCursor::ParseDirection(const nsAStrin
   }
   else if (aDirection.EqualsLiteral("prev")) {
     *aResult = PREV;
   }
   else if (aDirection.EqualsLiteral("prevunique")) {
     *aResult = PREV_UNIQUE;
   }
   else {
-    return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
+    return NS_ERROR_TYPE_ERR;
   }
   
   return NS_OK;
 }
 
 // static
 already_AddRefed<IDBCursor>
 IDBCursor::CreateCommon(IDBRequest* aRequest,
@@ -715,17 +715,17 @@ IDBCursor::Delete(JSContext* aCx,
 }
 
 NS_IMETHODIMP
 IDBCursor::Advance(PRInt32 aCount)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (aCount < 1) {
-    return NS_ERROR_DOM_TYPE_ERR;
+    return NS_ERROR_TYPE_ERR;
   }
 
   Key key;
   return ContinueInternal(key, aCount);
 }
 
 nsresult
 ContinueHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -548,17 +548,17 @@ IDBDatabase::Transaction(const jsval& aS
   }
 
   IDBTransaction::Mode transactionMode = IDBTransaction::READ_ONLY;
   if (aOptionalArgCount) {
     if (aMode.EqualsLiteral("readwrite")) {
       transactionMode = IDBTransaction::READ_WRITE;
     }
     else if (!aMode.EqualsLiteral("readonly")) {
-      return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
+      return NS_ERROR_TYPE_ERR;
     }
   }
 
   nsresult rv;
   nsTArray<nsString> storesToOpen;
 
   if (!JSVAL_IS_PRIMITIVE(aStoreNames)) {
     JSObject* obj = JSVAL_TO_OBJECT(aStoreNames);
--- a/dom/indexedDB/IDBEvents.cpp
+++ b/dom/indexedDB/IDBEvents.cpp
@@ -34,17 +34,16 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "IDBEvents.h"
 
-#include "nsIIDBDatabaseException.h"
 #include "nsIPrivateDOMEvent.h"
 
 #include "nsContentUtils.h"
 #include "nsDOMClassInfoID.h"
 #include "nsDOMException.h"
 #include "nsJSON.h"
 #include "nsThreadUtils.h"
 
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -507,17 +507,17 @@ IDBFactory::OpenCommon(const nsAString& 
 
 NS_IMETHODIMP
 IDBFactory::Open(const nsAString& aName,
                  PRInt64 aVersion,
                  PRUint8 aArgc,
                  nsIIDBOpenDBRequest** _retval)
 {
   if (aVersion < 1 && aArgc) {
-    return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
+    return NS_ERROR_TYPE_ERR;
   }
 
   return OpenCommon(aName, aVersion, false, _retval);
 }
 
 NS_IMETHODIMP
 IDBFactory::DeleteDatabase(const nsAString& aName,
                            nsIIDBOpenDBRequest** _retval)
--- a/dom/indexedDB/Makefile.in
+++ b/dom/indexedDB/Makefile.in
@@ -104,17 +104,16 @@ LOCAL_INCLUDES = \
 DEFINES += -D_IMPL_NS_LAYOUT
 
 # Make sure to quickstub as much as possible here! See
 # js/xpconnect/src/dom_quickstubs.qsconf.
 XPIDLSRCS = \
   nsIIDBCursor.idl \
   nsIIDBCursorWithValue.idl \
   nsIIDBDatabase.idl \
-  nsIIDBDatabaseException.idl \
   nsIIDBFactory.idl \
   nsIIDBIndex.idl \
   nsIIDBKeyRange.idl \
   nsIIDBObjectStore.idl \
   nsIIDBRequest.idl \
   nsIIDBTransaction.idl \
   nsIIDBVersionChangeEvent.idl \
   nsIIDBOpenDBRequest.idl \
deleted file mode 100644
--- a/dom/indexedDB/nsIIDBDatabaseException.idl
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Indexed Database.
- *
- * The Initial Developer of the Original Code is
- * The Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Ben Turner <bent.mozilla@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-
-[scriptable, builtinclass, uuid(7aad2542-a5cb-4a57-b20c-c7d16b8582ab)]
-interface nsIIDBDatabaseException : nsISupports
-{
-  // const unsigned short NO_ERR = 0;
-  const unsigned short UNKNOWN_ERR = 1;
-  const unsigned short NON_TRANSIENT_ERR = 2;
-  const unsigned short NOT_FOUND_ERR = 3;
-  const unsigned short CONSTRAINT_ERR = 4;
-  const unsigned short DATA_ERR = 5;
-  const unsigned short NOT_ALLOWED_ERR = 6;
-  const unsigned short TRANSACTION_INACTIVE_ERR = 7;
-  const unsigned short ABORT_ERR = 8;
-  const unsigned short READ_ONLY_ERR = 9;
-  const unsigned short TIMEOUT_ERR = 10;
-  const unsigned short QUOTA_ERR = 11;
-  const unsigned short VERSION_ERR = 12;
-
-  readonly attribute unsigned short code;
-};
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -452,17 +452,16 @@ members = [
     'nsIDOMNotifyAudioAvailableEvent.frameBuffer',
     'nsIDOMNotifyAudioAvailableEvent.time',
     'nsIDOMHTMLAudioElement.mozWriteAudio',
 
     # dom/indexedDB
     'nsIIDBCursor.*',
     'nsIIDBCursorWithValue.*',
     'nsIIDBDatabase.*',
-    'nsIIDBDatabaseException.*',
     'nsIIDBIndex.*',
     'nsIIDBKeyRange.*',
     'nsIIDBObjectStore.*',
     'nsIIDBRequest.*',
     'nsIIDBTransaction.*',
     'nsIIDBFactory.*',
     'nsIIDBOpenDBRequest.*',
     'nsIIDBVersionChangeEvent.*',