Bug 1174954 part 1. Stop throwing DOMErrors from JS-implemented webidl, since we can now throw content-side Errors instead. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 16 Jun 2015 16:44:10 -0400
changeset 249240 66f5705f110dde310906ffcc5ff111c5eee1f7a5
parent 249239 25e99bc12482eb4a72abc512bbbe1aecc61afcfd
child 249241 b6f23bd165db2d864a5cceebc1aab2f9b98021d2
push id28923
push userryanvm@gmail.com
push dateWed, 17 Jun 2015 18:57:11 +0000
treeherdermozilla-central@099d6cd6725e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1174954
milestone41.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 1174954 part 1. Stop throwing DOMErrors from JS-implemented webidl, since we can now throw content-side Errors instead. r=bholley
dom/bindings/test/TestInterfaceJS.js
dom/bindings/test/test_exception_options_from_jsimplemented.html
dom/contacts/ContactManager.js
dom/inputmethod/MozKeyboard.js
dom/nfc/nsNfc.js
dom/webidl/TestInterfaceJS.webidl
toolkit/mozapps/extensions/amInstallTrigger.js
--- a/dom/bindings/test/TestInterfaceJS.js
+++ b/dom/bindings/test/TestInterfaceJS.js
@@ -59,18 +59,18 @@ TestInterfaceJS.prototype = {
 
   get cachedAttr() { return this._cachedAttr; },
   setCachedAttr: function(n) { this._cachedAttr = n; },
   clearCachedAttrCache: function () { this.__DOM_IMPL__._clearCachedCachedAttrValue(); },
 
   testSequenceOverload: function(arg) {},
   testSequenceUnion: function(arg) {},
 
-  testThrowDOMError: function() {
-    throw new this._win.DOMError("NotSupportedError", "We are a DOMError");
+  testThrowError: function() {
+    throw new this._win.Error("We are an Error");
   },
 
   testThrowDOMException: function() {
     throw new this._win.DOMException("We are a DOMException",
                                      "NotSupportedError");
   },
 
   testThrowTypeError: function() {
--- a/dom/bindings/test/test_exception_options_from_jsimplemented.html
+++ b/dom/bindings/test/test_exception_options_from_jsimplemented.html
@@ -12,23 +12,23 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   /** Test for Bug 1107592 **/
 
   SimpleTest.waitForExplicitFinish();
 
   function doTest() {
     var t = new TestInterfaceJS();
     try {
-      t.testThrowDOMError();
+      t.testThrowError();
     } catch (e) {
       ok(e instanceof Error, "Should have an Error here");
       ok(!(e instanceof DOMException), "Should not have DOMException here");
       ok(!("code" in e), "Should not have a 'code' property");
       is(e.name, "Error", "Should not have an interesting name here");
-      is(e.message, "We are a DOMError", "Should have the right message");
+      is(e.message, "We are an Error", "Should have the right message");
       is(e.stack,
          "doTest@http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html:20:7\n",
          "Exception stack should still only show our code");
       is(e.fileName,
          "http://mochi.test:8888/tests/dom/bindings/test/test_exception_options_from_jsimplemented.html",
          "Should have the right file name");
       is(e.lineNumber, 20, "Should have the right line number");
       is(e.columnNumber, 7, "Should have the right column number");
--- a/dom/contacts/ContactManager.js
+++ b/dom/contacts/ContactManager.js
@@ -307,17 +307,17 @@ ContactManager.prototype = {
     try {
       for (let field of PROPERTIES) {
         // This hack makes sure modifications to the sequence attributes get validated.
         aContact[field] = aContact[field];
         newContact.properties[field] = aContact[field];
       }
     } catch (e) {
       // And then make sure we throw a proper error message (no internal file and line #)
-      throw new this._window.DOMError(e.name, e.message);
+      throw new this._window.Error(e.message);
     }
 
     let request = this.createRequest();
     let requestID = this.getRequestId({request: request});
 
     let reason;
     if (aContact.id == "undefined") {
       // for example {25c00f01-90e5-c545-b4d4-21E2ddbab9e0} becomes
--- a/dom/inputmethod/MozKeyboard.js
+++ b/dom/inputmethod/MozKeyboard.js
@@ -397,18 +397,17 @@ MozInputMethod.prototype = {
 
   removeFocus: function() {
     this._ensureIsSystem();
     cpmm.sendAsyncMessage('System:RemoveFocus', {});
   },
 
   _ensureIsSystem: function() {
     if (!this._isSystem) {
-      throw new this._window.DOMError("Security",
-                                      "Should have 'input-manage' permssion.");
+      throw new this._window.Error("Should have 'input-manage' permssion.");
     }
   },
 
   _sendPromise: function(callback) {
     let self = this;
     return this.createPromise(function(resolve, reject) {
       let resolverId = self.getPromiseResolverId({ resolve: resolve, reject: reject });
       callback(resolverId);
--- a/dom/nfc/nsNfc.js
+++ b/dom/nfc/nsNfc.js
@@ -159,98 +159,95 @@ MozNFCTagImpl.prototype = {
   isLost: false,
 
   createTech: { "ISO-DEP": (win, tag) => { return new win.MozIsoDepTech(tag); }
               },
 
   // NFCTag interface:
   readNDEF: function readNDEF() {
     if (this.isLost) {
-      throw new this._window.DOMError("InvalidStateError", "NFCTag object is invalid");
+      throw new this._window.Error("NFCTag object is invalid");
     }
 
     let callback = new NfcCallback(this._window);
     this._nfcContentHelper.readNDEF(this.session, callback);
     return callback.promise;
   },
 
   writeNDEF: function writeNDEF(records) {
     if (this.isLost) {
-      throw new this._window.DOMError("InvalidStateError", "NFCTag object is invalid");
+      throw new this._window.Error("NFCTag object is invalid");
     }
 
     if (this.isReadOnly) {
-      throw new this._window.DOMError("InvalidAccessError", "NFCTag object is read-only");
+      throw new this._window.Error("NFCTag object is read-only");
     }
 
     let ndefLen = 0;
     for (let record of records) {
       ndefLen += record.size;
     }
 
     if (ndefLen > this.maxNDEFSize) {
-      throw new this._window.DOMError("NotSupportedError", "Exceed max NDEF size");
+      throw new this._window.Error("Exceed max NDEF size");
     }
 
     let callback = new NfcCallback(this._window);
     this._nfcContentHelper.writeNDEF(records, false, this.session, callback);
     return callback.promise;
   },
 
   makeReadOnly: function makeReadOnly() {
     if (this.isLost) {
-      throw new this._window.DOMError("InvalidStateError", "NFCTag object is invalid");
+      throw new this._window.Error("NFCTag object is invalid");
     }
 
     if (!this.canBeMadeReadOnly) {
-      throw new this._window.DOMError("InvalidAccessError",
-                                      "NFCTag object cannot be made read-only");
+      throw new this._window.Error("NFCTag object cannot be made read-only");
     }
 
     let callback = new NfcCallback(this._window);
     this._nfcContentHelper.makeReadOnly(this.session, callback);
     return callback.promise;
   },
 
   format: function format() {
     if (this.isLost) {
-      throw new this._window.DOMError("InvalidStateError", "NFCTag object is invalid");
+      throw new this._window.Error("NFCTag object is invalid");
     }
 
     if (!this.isFormatable) {
-      throw new this._window.DOMError("InvalidAccessError",
-                                      "NFCTag object is not formatable");
+      throw new this._window.Error("NFCTag object is not formatable");
     }
 
     let callback = new NfcCallback(this._window);
     this._nfcContentHelper.format(this.session, callback);
     return callback.promise;
   },
 
   selectTech: function selectTech(tech) {
     if (this.isLost) {
-      throw new this._window.DOMError("InvalidStateError", "NFCTag object is invalid");
+      throw new this._window.Error("NFCTag object is invalid");
     }
 
     if (this.techList.indexOf(tech) == -1) {
-      throw new this._window.DOMError("InvalidAccessError",
+      throw new this._window.Error(
         "NFCTag does not contain selected tag technology");
     }
 
     if (this.createTech[tech] === undefined) {
-      throw new this._window.DOMError("InvalidAccessError",
-        "Technology is not supported now");
+      throw new this._window.Error("Technology is not supported now");
     }
 
     return this.createTech[tech](this._window, this._contentObj);
   },
 
   transceive: function transceive(tech, cmd) {
     if (this.isLost) {
-      throw new this._window.DOMError("InvalidStateError", "NFCTag object is invalid");
+      throw new this._window.Error("NFCTag object is invalid");
     }
 
     let callback = new NfcCallback(this._window);
     this._nfcContentHelper.transceive(this.session, tech, cmd, callback);
     return callback.promise;
   },
 
   notifyLost: function notifyLost() {
@@ -280,28 +277,28 @@ function MozNFCPeerImpl(aWindow, aSessio
 MozNFCPeerImpl.prototype = {
   _nfcContentHelper: null,
   _window: null,
   isLost: false,
 
   // NFCPeer interface:
   sendNDEF: function sendNDEF(records) {
     if (this.isLost) {
-      throw new this._window.DOMError("InvalidStateError", "NFCPeer object is invalid");
+      throw new this._window.Error("NFCPeer object is invalid");
     }
 
     // Just forward sendNDEF to writeNDEF
     let callback = new NfcCallback(this._window);
     this._nfcContentHelper.writeNDEF(records, true, this.session, callback);
     return callback.promise;
   },
 
   sendFile: function sendFile(blob) {
     if (this.isLost) {
-      throw new this._window.DOMError("InvalidStateError", "NFCPeer object is invalid");
+      throw new this._window.Error("NFCPeer object is invalid");
     }
 
     let data = {
       "blob": blob
     };
 
     let callback = new NfcCallback(this._window);
     this._nfcContentHelper.sendFile(Cu.cloneInto(data, this._window),
--- a/dom/webidl/TestInterfaceJS.webidl
+++ b/dom/webidl/TestInterfaceJS.webidl
@@ -46,17 +46,17 @@ interface TestInterfaceJS {
   // Test for sequence overloading and union behavior
   void testSequenceOverload(sequence<DOMString> arg);
   void testSequenceOverload(DOMString arg);
 
   void testSequenceUnion((sequence<DOMString> or DOMString) arg);
 
   // Tests for exception-throwing behavior
   [Throws]
-  void testThrowDOMError();
+  void testThrowError();
 
   [Throws]
   void testThrowDOMException();
 
   [Throws]
   void testThrowTypeError();
 
   [Throws]
--- a/toolkit/mozapps/extensions/amInstallTrigger.js
+++ b/toolkit/mozapps/extensions/amInstallTrigger.js
@@ -140,22 +140,22 @@ InstallTrigger.prototype = {
     };
 
     for (let name of Object.keys(installs)) {
       let item = installs[name];
       if (typeof item === "string") {
         item = { URL: item };
       }
       if (!item.URL) {
-        throw new this._window.DOMError("Error", "Missing URL property for '" + name + "'");
+        throw new this._window.Error("Missing URL property for '" + name + "'");
       }
 
       let url = this._resolveURL(item.URL);
       if (!this._checkLoadURIFromScript(url)) {
-        throw new this._window.DOMError("SecurityError", "Insufficient permissions to install: " + url.spec);
+        throw new this._window.Error("Insufficient permissions to install: " + url.spec);
       }
 
       let iconUrl = null;
       if (item.IconURL) {
         iconUrl = this._resolveURL(item.IconURL);
         if (!this._checkLoadURIFromScript(iconUrl)) {
           iconUrl = null; // If page can't load the icon, just ignore it
         }