Advertisement
Guest User

Untitled

a guest
Oct 27th, 2011
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.33 KB | None | 0 0
  1. diff --git a/tests/resources/testharness.js b/tests/resources/testharness.js
  2. --- a/tests/resources/testharness.js
  3. +++ b/tests/resources/testharness.js
  4. @@ -728,54 +728,64 @@ policies and contribution forms [3].
  5.                         "assert_throws", description,
  6.                         "${func} threw ${actual} (${actual_name}) expected ${expected} (${expected_name})",
  7.                                      {func:func, actual:e, actual_name:e.name,
  8.                                       expected:code,
  9.                                       expected_name:code.name});
  10.                  return;
  11.              }
  12.              var required_props = {};
  13. -            var expected_type;
  14. -            if (code in DOMException)
  15. +            required_props.code = {
  16. +                INDEX_SIZE_ERR: 1,
  17. +                HIERARCHY_REQUEST_ERR: 3,
  18. +                WRONG_DOCUMENT_ERR: 4,
  19. +                INVALID_CHARACTER_ERR: 5,
  20. +                NO_MODIFICATION_ALLOWED_ERR: 7,
  21. +                NOT_FOUND_ERR: 8,
  22. +                NOT_SUPPOTED_ERR: 9,
  23. +                INVALID_STATE_ERR: 11,
  24. +                SYNTAX_ERR: 12,
  25. +                INVALID_MODIFICATION_ERR: 13,
  26. +                NAMESPACE_ERR: 14,
  27. +                INVALID_ACCESS_ERR: 15,
  28. +                TYPE_MISMATCH_ERR: 17,
  29. +                SECURITY_ERR: 18,
  30. +                NETWORK_ERR: 19,
  31. +                ABORT_ERR: 20,
  32. +                URL_MISMATCH_ERR: 21,
  33. +                QUOTA_EXCEEDED_ERR: 22,
  34. +                TIMEOUT_ERR: 23,
  35. +                INVALID_NODE_TYPE_ERR: 24,
  36. +                DATA_CLONE_ERR: 25,
  37. +            }[code];
  38. +            if (required_props.code === undefined)
  39.              {
  40. -                expected_type = "DOMException";
  41. -                required_props[code] = DOMException[code];
  42. -                required_props.code = DOMException[code];
  43. -                //Uncomment this when the latest version of every browser
  44. -                //actually implements the spec; otherwise it just creates
  45. -                //zillions of failures
  46. -                //required_props.name = code;
  47. +                throw new AssertionError('Test bug: unrecognized DOMException code "' + code + '" passed to assert_throws()');
  48.              }
  49. -            else if (code in RangeException)
  50. -            {
  51. -                expected_type = "RangeException";
  52. -                required_props[code] = RangeException[code];
  53. -                required_props.code = RangeException[code];
  54. -                //As above
  55. -                //required_props.name = code;
  56. -            }
  57. -            else
  58. -            {
  59. -                throw new AssertionError('Test bug: unrecognized code "' + code + '" passed to assert_throws()');
  60. -            }
  61. +            required_props[code] = required_props.code;
  62. +            //Uncomment this when the latest version of every browser
  63. +            //actually implements the spec; otherwise it just creates
  64. +            //zillions of failures.  Also do required_props.type.
  65. +            //required_props.name = code;
  66. +            //
  67.              //We'd like to test that e instanceof the appropriate interface,
  68.              //but we can't, because we don't know what window it was created
  69.              //in.  It might be an instanceof the appropriate interface on some
  70.              //unknown other window.  TODO: Work around this somehow?
  71.  
  72.              assert(typeof e == "object",
  73.                     "assert_throws", description,
  74.                     "${func} threw ${e} with type ${type}, not an object",
  75.                     {func:func, e:e, type:typeof e});
  76.  
  77.              for (var prop in required_props)
  78.              {
  79.                  assert(typeof e == "object" && prop in e && e[prop] == required_props[prop],
  80.                         "assert_throws", description,
  81. -                       "${func} threw ${e} that is not a " + expected_type + " " + code + ": property ${prop} is equal to ${actual}, expected ${expected}",
  82. +                       "${func} threw ${e} that is not a DOMException " + code + ": property ${prop} is equal to ${actual}, expected ${expected}",
  83.                         {func:func, e:e, prop:prop, actual:e[prop], expected:required_props[prop]});
  84.              }
  85.          }
  86.      }
  87.      expose(assert_throws, "assert_throws");
  88.  
  89.      function assert_unreached(description) {
  90.           assert(false, "assert_unreached", description,
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement