4 <title>DOMException constructor
</title>
5 <script src=
"../../../resources/testharness.js"></script>
6 <script src=
"../../../resources/testharnessreport.js"></script>
7 <link rel=
"stylesheet" href=
"../../../resources/testharness.css">
12 var ex
= new DOMException();
13 assert_equals(ex
.name
, 'Error', 'Default name should be "Error"');
14 assert_equals(ex
.message
, '', 'Default message should be ""');
15 assert_equals(ex
.code
, 0, 'Default code should be 0');
16 }, 'new DOMException()');
19 var ex
= new DOMException(null);
20 assert_equals(ex
.name
, 'Error', 'Default name should be "Error"');
21 assert_equals(ex
.message
, 'null', 'Passing null as message should be stringified to "null"');
22 assert_equals(ex
.code
, 0, 'Default code should be 0');
23 }, 'new DOMException(null)');
26 var ex
= new DOMException(undefined);
27 assert_equals(ex
.name
, 'Error', 'Default name should be "Error"');
28 assert_equals(ex
.message
, '', 'Passing undefined as message should give default ""');
29 assert_equals(ex
.code
, 0, 'Default code should be 0');
30 }, 'new DOMException(undefined)');
33 var ex
= new DOMException('example');
34 assert_equals(ex
.name
, 'Error', 'Default name should be "Error"');
35 assert_equals(ex
.message
, 'example', 'Passed string as message should be used');
36 assert_equals(ex
.code
, 0, 'Default code should be 0');
37 }, 'new DOMException(string)');
40 var ex
= new DOMException('example', undefined);
41 assert_equals(ex
.name
, 'Error', 'Passing undefined as name should give default "Error"');
42 assert_equals(ex
.message
, 'example', 'Passed string as message should be used');
43 assert_equals(ex
.code
, 0, 'Default code should be 0');
44 }, 'new DOMException(string, undefined)');
47 var ex
= new DOMException('example', null);
48 assert_equals(ex
.name
, 'null', 'Passing null as name should be stringified to "null"');
49 assert_equals(ex
.message
, 'example', 'Passed string as message should be used');
50 assert_equals(ex
.code
, 0, 'Default code should be 0');
51 }, 'new DOMException(string, null)');
54 var ex
= new DOMException('example', 'bar');
55 assert_equals(ex
.name
, 'bar', 'Passed string as name should be used');
56 assert_equals(ex
.message
, 'example', 'Passed string as message should be used');
57 assert_equals(ex
.code
, 0, 'Default code should be 0');
58 }, 'new DOMException(string, string)');
61 {name
: "IndexSizeError", code
: 1},
62 {name
: "HierarchyRequestError", code
: 3},
63 {name
: "WrongDocumentError", code
: 4},
64 {name
: "InvalidCharacterError", code
: 5},
65 {name
: "NoModificationAllowedError", code
: 7},
66 {name
: "NotFoundError", code
: 8},
67 {name
: "NotSupportedError", code
: 9},
68 {name
: "InUseAttributeError", code
: 10},
69 {name
: "InvalidStateError", code
: 11},
70 {name
: "SyntaxError", code
: 12},
71 {name
: "InvalidModificationError", code
: 13},
72 {name
: "NamespaceError", code
: 14},
73 {name
: "InvalidAccessError", code
: 15},
74 {name
: "SecurityError", code
: 18},
75 {name
: "NetworkError", code
: 19},
76 {name
: "AbortError", code
: 20},
77 {name
: "URLMismatchError", code
: 21},
78 {name
: "QuotaExceededError", code
: 22},
79 {name
: "TimeoutError", code
: 23},
80 {name
: "InvalidNodeTypeError", code
: 24},
81 {name
: "DataCloneError", code
: 25}
82 ].forEach(function(test_case
) {
84 var ex
= new DOMException('example', test_case
.name
);
85 assert_equals(ex
.name
, test_case
.name
, 'Passed string as name should be used');
86 assert_equals(ex
.message
, 'example', 'Passed string as message should be used');
87 assert_equals(ex
.code
, test_case
.code
, 'Legacy code should be used for matching name');
88 }, 'Legacy code matching: new DOMException(string, "' + test_case
.name
+ '")');