Bug 1941128 - Turn off network.dns.native_https_query on Mac again
[gecko.git] / dom / bindings / test / test_exception_options_from_jsimplemented.html
blobd7d243b0d08ac6260c6d85ae3563297cd5e93688
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 1107592</title>
9 <script src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 <script type="application/javascript">
12 /* global TestInterfaceJS */
13 /** Test for Bug 1107592 **/
15 SimpleTest.waitForExplicitFinish();
17 function doTest() {
18 var file = location.href;
20 var asyncFrame;
21 /* Async parent frames from pushPrefEnv don't show up in e10s. */
22 if (!SpecialPowers.getBoolPref("javascript.options.asyncstack_capture_debuggee_only")) {
23 asyncFrame = `Async*@${file}:153:17
25 } else {
26 asyncFrame = "";
29 var t = new TestInterfaceJS();
30 try {
31 t.testThrowError();
32 } catch (e) {
33 ok(e instanceof Error, "Should have an Error here");
34 ok(!(e instanceof DOMException), "Should not have DOMException here");
35 ok(!("code" in e), "Should not have a 'code' property");
36 is(e.name, "Error", "Should not have an interesting name here");
37 is(e.message, "We are an Error", "Should have the right message");
38 is(e.stack,
39 `doTest@${file}:31:9
40 ${asyncFrame}`,
41 "Exception stack should still only show our code");
42 is(e.fileName,
43 file,
44 "Should have the right file name");
45 is(e.lineNumber, 31, "Should have the right line number");
46 is(e.columnNumber, 9, "Should have the right column number");
49 try {
50 t.testThrowDOMException();
51 } catch (e) {
52 ok(e instanceof Error, "Should also have an Error here");
53 ok(e instanceof DOMException, "Should have DOMException here");
54 is(e.name, "NotSupportedError", "Should have the right name here");
55 is(e.message, "We are a DOMException",
56 "Should also have the right message");
57 is(e.code, DOMException.NOT_SUPPORTED_ERR,
58 "Should have the right 'code'");
59 is(e.stack,
60 `doTest@${file}:50:9
61 ${asyncFrame}`,
62 "Exception stack should still only show our code");
63 is(e.filename,
64 file,
65 "Should still have the right file name");
66 is(e.lineNumber, 50, "Should still have the right line number");
67 todo_isnot(e.columnNumber, 0,
68 "No column number support for DOMException yet");
71 try {
72 t.testThrowTypeError();
73 } catch (e) {
74 ok(e instanceof TypeError, "Should have a TypeError here");
75 ok(!(e instanceof DOMException), "Should not have DOMException here (2)");
76 ok(!("code" in e), "Should not have a 'code' property (2)");
77 is(e.name, "TypeError", "Should be named TypeError");
78 is(e.message, "We are a TypeError",
79 "Should also have the right message (2)");
80 is(e.stack,
81 `doTest@${file}:72:9
82 ${asyncFrame}`,
83 "Exception stack for TypeError should only show our code");
84 is(e.fileName,
85 file,
86 "Should still have the right file name for TypeError");
87 is(e.lineNumber, 72, "Should still have the right line number for TypeError");
88 is(e.columnNumber, 9, "Should have the right column number for TypeError");
91 try {
92 t.testThrowCallbackError(function() { Array.prototype.forEach(); });
93 } catch (e) {
94 ok(e instanceof TypeError, "Should have a TypeError here (3)");
95 ok(!(e instanceof DOMException), "Should not have DOMException here (3)");
96 ok(!("code" in e), "Should not have a 'code' property (3)");
97 is(e.name, "TypeError", "Should be named TypeError (3)");
98 is(e.message, "missing argument 0 when calling function Array.prototype.forEach",
99 "Should also have the right message (3)");
100 is(e.stack,
101 `doTest/<@${file}:92:61
102 doTest@${file}:92:9
103 ${asyncFrame}`,
104 "Exception stack for TypeError should only show our code (3)");
105 is(e.fileName,
106 file,
107 "Should still have the right file name for TypeError (3)");
108 is(e.lineNumber, 92, "Should still have the right line number for TypeError (3)");
109 is(e.columnNumber, 61, "Should have the right column number for TypeError (3)");
112 try {
113 t.testThrowXraySelfHosted();
114 } catch (e) {
115 ok(!(e instanceof Error), "Should have an Exception here (4)");
116 ok(!(e instanceof DOMException), "Should not have DOMException here (4)");
117 ok(!("code" in e), "Should not have a 'code' property (4)");
118 is(e.name, "NS_ERROR_UNEXPECTED", "Name should be sanitized (4)");
119 is(e.message, "", "Message should be sanitized (5)");
120 is(e.stack,
121 `doTest@${file}:113:9
122 ${asyncFrame}`,
123 "Exception stack for sanitized exception should only show our code (4)");
124 is(e.filename,
125 file,
126 "Should still have the right file name for sanitized exception (4)");
127 is(e.lineNumber, 113, "Should still have the right line number for sanitized exception (4)");
128 todo_isnot(e.columnNumber, 0, "Should have the right column number for sanitized exception (4)");
131 try {
132 t.testThrowSelfHosted();
133 } catch (e) {
134 ok(!(e instanceof Error), "Should have an Exception here (5)");
135 ok(!(e instanceof DOMException), "Should not have DOMException here (5)");
136 ok(!("code" in e), "Should not have a 'code' property (5)");
137 is(e.name, "NS_ERROR_UNEXPECTED", "Name should be sanitized (5)");
138 is(e.message, "", "Message should be sanitized (5)");
139 is(e.stack,
140 `doTest@${file}:132:9
141 ${asyncFrame}`,
142 "Exception stack for sanitized exception should only show our code (5)");
143 is(e.filename,
144 file,
145 "Should still have the right file name for sanitized exception (5)");
146 is(e.lineNumber, 132, "Should still have the right line number for sanitized exception (5)");
147 todo_isnot(e.columnNumber, 0, "Should have the right column number for sanitized exception (5)");
150 SimpleTest.finish();
153 SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]},
154 doTest);
155 </script>
156 </head>
157 <body>
158 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107592">Mozilla Bug 1107592</a>
159 <p id="display"></p>
160 <div id="content" style="display: none">
162 </div>
163 <pre id="test">
164 </pre>
165 </body>
166 </html>