test_bug_442086.js 947 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. // Bug 442086 - XPConnect creates doubles without checking for
  5. // the INT_FITS_IN_JSVAL case
  6. var types = [
  7. 'PRUint8',
  8. 'PRUint16',
  9. 'PRUint32',
  10. 'PRUint64',
  11. 'PRInt16',
  12. 'PRInt32',
  13. 'PRInt64',
  14. 'float',
  15. 'double'
  16. ];
  17. function run_test()
  18. {
  19. var i;
  20. for (i = 0; i < types.length; i++) {
  21. var name = types[i];
  22. var cls = Components.classes["@mozilla.org/supports-" + name + ";1"];
  23. var ifname = ("nsISupports" + name.charAt(0).toUpperCase() +
  24. name.substring(1));
  25. var f = cls.createInstance(Components.interfaces[ifname]);
  26. f.data = 0;
  27. switch (f.data) {
  28. case 0: /*ok*/ break;
  29. default: do_throw("FAILED - bug 442086 (type=" + name + ")");
  30. }
  31. }
  32. }