js/xpconnect/tests/unit/test_bug_442086.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/unit/test_bug_442086.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,36 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +// Bug 442086 - XPConnect creates doubles without checking for
     1.9 +//              the INT_FITS_IN_JSVAL case
    1.10 +
    1.11 +var types = [
    1.12 +    'PRUint8',
    1.13 +    'PRUint16',
    1.14 +    'PRUint32',
    1.15 +    'PRUint64',
    1.16 +    'PRInt16',
    1.17 +    'PRInt32',
    1.18 +    'PRInt64',
    1.19 +    'float',
    1.20 +    'double'
    1.21 +];
    1.22 +
    1.23 +function run_test()
    1.24 +{
    1.25 +  var i;
    1.26 +  for (i = 0; i < types.length; i++) {
    1.27 +    var name = types[i];
    1.28 +    var cls = Components.classes["@mozilla.org/supports-" + name + ";1"];
    1.29 +    var ifname = ("nsISupports" + name.charAt(0).toUpperCase() +
    1.30 +                  name.substring(1));
    1.31 +    var f = cls.createInstance(Components.interfaces[ifname]);
    1.32 +
    1.33 +    f.data = 0;
    1.34 +    switch (f.data) {
    1.35 +      case 0: /*ok*/ break;
    1.36 +      default: do_throw("FAILED - bug 442086 (type=" + name + ")");
    1.37 +    }
    1.38 +  }
    1.39 +}

mercurial