Bug 672843 part D2 - Fix the xpconnect exception code and Components.results to prefer the name NS_ERROR_ILLEGAL_VALUE over the other synonyms. Fix a few tests that rely on exception names to use exception values instead. r=bholley
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 20 Nov 2013 11:46:18 -0500
changeset 172233 4ac67f3ed9860cb3f67ff629ff94736d63641e70
parent 172232 1b97a8e7061883c57f6b4bd2f6db21fdfb8f76cc
child 172234 3fd5efa062a5e8d3b0ca7947fb6b0a53d2812290
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs672843
milestone28.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 672843 part D2 - Fix the xpconnect exception code and Components.results to prefer the name NS_ERROR_ILLEGAL_VALUE over the other synonyms. Fix a few tests that rely on exception names to use exception values instead. r=bholley
js/xpconnect/src/xpc.msg
layout/inspector/tests/test_bug462787.html
netwerk/test/unit/test_psl.js
toolkit/components/places/tests/unit/test_null_interfaces.js
--- a/js/xpconnect/src/xpc.msg
+++ b/js/xpconnect/src/xpc.msg
@@ -68,23 +68,23 @@ XPC_MSG_DEF(NS_ERROR_XPC_CANT_PASS_CPOW_
 /* common global codes (from nsError.h) */
 
 XPC_MSG_DEF(NS_OK                                  , "Success")
 XPC_MSG_DEF(NS_ERROR_NOT_INITIALIZED               , "Component not initialized")
 XPC_MSG_DEF(NS_ERROR_ALREADY_INITIALIZED           , "Component already initialized")
 XPC_MSG_DEF(NS_ERROR_NOT_IMPLEMENTED               , "Method not implemented")
 XPC_MSG_DEF(NS_NOINTERFACE                         , "Component does not have requested interface")
 XPC_MSG_DEF(NS_ERROR_NO_INTERFACE                  , "Component does not have requested interface")
+XPC_MSG_DEF(NS_ERROR_ILLEGAL_VALUE                 , "Illegal value")
 XPC_MSG_DEF(NS_ERROR_INVALID_POINTER               , "Invalid pointer")
 XPC_MSG_DEF(NS_ERROR_NULL_POINTER                  , "Null pointer")
 XPC_MSG_DEF(NS_ERROR_ABORT                         , "Abort")
 XPC_MSG_DEF(NS_ERROR_FAILURE                       , "Failure")
 XPC_MSG_DEF(NS_ERROR_UNEXPECTED                    , "Unexpected error")
 XPC_MSG_DEF(NS_ERROR_OUT_OF_MEMORY                 , "Out of Memory")
-XPC_MSG_DEF(NS_ERROR_ILLEGAL_VALUE                 , "Illegal value")
 XPC_MSG_DEF(NS_ERROR_INVALID_ARG                   , "Invalid argument")
 XPC_MSG_DEF(NS_ERROR_NO_AGGREGATION                , "Component does not support aggregation")
 XPC_MSG_DEF(NS_ERROR_NOT_AVAILABLE                 , "Component is not available")
 XPC_MSG_DEF(NS_ERROR_FACTORY_NOT_REGISTERED        , "Factory not registered")
 XPC_MSG_DEF(NS_ERROR_FACTORY_REGISTER_AGAIN        , "Factory not registered (may be tried again)")
 XPC_MSG_DEF(NS_ERROR_FACTORY_NOT_LOADED            , "Factory not loaded")
 XPC_MSG_DEF(NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT  , "Factory does not support signatures")
 XPC_MSG_DEF(NS_ERROR_FACTORY_EXISTS                , "Factory already exists")
--- a/layout/inspector/tests/test_bug462787.html
+++ b/layout/inspector/tests/test_bug462787.html
@@ -15,17 +15,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 462787 **/
 
 function do_test() {
-  const INVALID_POINTER = 0x80004003;
+  const INVALID_POINTER = SpecialPowers.Cr.NS_ERROR_INVALID_POINTER;
 
   var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
                              .getService(SpecialPowers.Ci.inIDOMUtils);
   try {
     utils.getCSSStyleRules(null); 
     ok(false, "expected an exception"); 
   }
   catch(e) {
--- a/netwerk/test/unit/test_psl.js
+++ b/netwerk/test/unit/test_psl.js
@@ -1,14 +1,16 @@
 var etld = Cc["@mozilla.org/network/effective-tld-service;1"]
              .getService(Ci.nsIEffectiveTLDService);
 
 var idna = Cc["@mozilla.org/network/idn-service;1"]
            .getService(Ci.nsIIDNService);
 
+var Cr = Components.results;
+
 function run_test()
 {
   var file = do_get_file("data/test_psl.txt");
   var ios = Cc["@mozilla.org/network/io-service;1"]
               .getService(Ci.nsIIOService);
   var uri = ios.newFileURI(file);
   var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
                        .getService(Ci.mozIJSSubScriptLoader);
@@ -16,18 +18,18 @@ function run_test()
   scriptLoader.loadSubScript(uri.spec, srvScope, "utf-8");
 }
 
 function checkPublicSuffix(host, expectedSuffix)
 {
   var actualSuffix = null;
   try {
     actualSuffix = etld.getBaseDomainFromHost(host);
-  } catch (e if e.name == "NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS" ||
-                e.name == "NS_ERROR_ILLEGAL_VALUE") {
+  } catch (e if e.result == Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS ||
+                e.result == Cr.NS_ERROR_ILLEGAL_VALUE) {
   }
   // The EffectiveTLDService always gives back punycoded labels.
   // The test suite wants to get back what it put in.
   if (actualSuffix !== null && expectedSuffix !== null &&
       /(^|\.)xn--/.test(actualSuffix) && !/(^|\.)xn--/.test(expectedSuffix)) {
     actualSuffix = idna.convertACEtoUTF8(actualSuffix);
   }
   do_check_eq(actualSuffix, expectedSuffix);
--- a/toolkit/components/places/tests/unit/test_null_interfaces.js
+++ b/toolkit/components/places/tests/unit/test_null_interfaces.js
@@ -1,16 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Test bug 489872 to make sure passing nulls to nsNavHistory doesn't crash.
  */
 
+let Cr = Components.results;
+
 /**
  * Print some debug message to the console. All arguments will be printed,
  * separated by spaces.
  *
  * @param [arg0, arg1, arg2, ...]
  *        Any number of arguments to print out
  * @usage _("Hello World") -> prints "Hello World"
  * @usage _(1, 2, 3) -> prints "1 2 3"
@@ -76,28 +78,28 @@ function run_test()
           func.apply(s, args);
   
           _("The function didn't throw! Is it one of the nothrow?", nothrow);
           do_check_neq(nothrow.indexOf(n), -1);
 
           _("Must have been an expected nothrow, so no need to try again");
           tryAgain = false;
         }
-        catch(ex if ex.name.match(/NS_ERROR_ILLEGAL_VALUE/)) {
+        catch(ex if ex.result == Cr.NS_ERROR_ILLEGAL_VALUE) {
           _("Caught an expected exception:", ex.name);
 
           _("Moving on to the next test..");
           tryAgain = false;
         }
-        catch(ex if ex.name.match(/NS_ERROR_XPC_NEED_OUT_OBJECT/)) {
+        catch(ex if ex.result == Cr.NS_ERROR_XPC_NEED_OUT_OBJECT) {
           let pos = Number(ex.message.match(/object arg (\d+)/)[1]);
           _("Function call expects an out object at", pos);
           args[pos] = {};
         }
-        catch(ex if ex.name.match(/NS_ERROR_NOT_IMPLEMENTED/)) {
+        catch(ex if ex.result == Cr.NS_ERROR_NOT_IMPLEMENTED) {
           _("Method not implemented exception:", ex.name);
 
           _("Moving on to the next test..");
           tryAgain = false;
         }
         catch(ex) {
           _("Caught some unexpected exception.. dumping");
           _([[i, ex[i]] for (i in ex)].join("\n"));