4 https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
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, thereIsNoSuchContentFunction1, thereIsNoSuchContentFunction2, thereIsNoSuchContentFunction3 */
13 /** Test for Bug
1107592 **/
15 SimpleTest.waitForExplicitFinish();
17 function checkExn(lineNumber, name, message, code, filename, testNumber, stack, exn) {
18 is(exn.lineNumber, lineNumber,
19 "Should have the right line number in test " + testNumber);
21 "Should have the right exception name in test " + testNumber);
22 is(
"filename" in exn ? exn.filename : exn.fileName, filename,
23 "Should have the right file name in test " + testNumber);
24 is(exn.message, message,
25 "Should have the right message in test " + testNumber);
26 is(exn.code, code,
"Should have the right .code in test " + testNumber);
28 is(exn.name,
"InternalError",
29 "Should have one of our synthetic exceptions in test " + testNumber);
31 is(exn.stack, stack,
"Should have the right stack in test " + testNumber);
34 function ensurePromiseFail(testNumber) {
35 ok(false,
"Test " + testNumber +
" should not have a fulfilled promise");
39 var t = new TestInterfaceJS();
42 var asyncStack = !SpecialPowers.getBoolPref(
"javascript.options.asyncstack_capture_debuggee_only");
43 var ourFile = location.href;
44 var unwrapError =
"Promise rejection value is a non-unwrappable cross-compartment wrapper.";
45 var parentFrame = asyncStack ? `Async*@${ourFile}:
130:
17
49 t.testPromiseWithThrowingChromePromiseInit().then(
50 ensurePromiseFail.bind(null,
1),
51 checkExn.bind(null,
49,
"InternalError", unwrapError,
52 undefined, ourFile,
1,
53 `doTest@${ourFile}:
49:
9
56 t.testPromiseWithThrowingContentPromiseInit(function() {
57 thereIsNoSuchContentFunction1();
59 ensurePromiseFail.bind(null,
2),
60 checkExn.bind(null,
57,
"ReferenceError",
61 "thereIsNoSuchContentFunction1 is not defined",
62 undefined, ourFile,
2,
63 `doTest/<@${ourFile}:
57:
11
64 doTest@${ourFile}:
56:
9
67 t.testPromiseWithThrowingChromeThenFunction().then(
68 ensurePromiseFail.bind(null,
3),
69 checkExn.bind(null,
0,
"InternalError", unwrapError, undefined,
"",
3, asyncStack ? (`Async*doTest@${ourFile}:
67:
9
72 t.testPromiseWithThrowingContentThenFunction(function() {
73 thereIsNoSuchContentFunction2();
75 ensurePromiseFail.bind(null,
4),
76 checkExn.bind(null,
73,
"ReferenceError",
77 "thereIsNoSuchContentFunction2 is not defined",
78 undefined, ourFile,
4,
79 `doTest/<@${ourFile}:
73:
11
81 (asyncStack ? `Async*doTest@${ourFile}:
72:
9
84 t.testPromiseWithThrowingChromeThenable().then(
85 ensurePromiseFail.bind(null,
5),
86 checkExn.bind(null,
0,
"InternalError", unwrapError, undefined,
"",
5, asyncStack ? (`Async*doTest@${ourFile}:
84:
9
89 t.testPromiseWithThrowingContentThenable({
90 then() { thereIsNoSuchContentFunction3(); },
92 ensurePromiseFail.bind(null,
6),
93 checkExn.bind(null,
90,
"ReferenceError",
94 "thereIsNoSuchContentFunction3 is not defined",
95 undefined, ourFile,
6,
96 `then@${ourFile}:
90:
22
97 ` + (asyncStack ? `Async*doTest@${ourFile}:
89:
9\n` + parentFrame :
""))),
98 t.testPromiseWithDOMExceptionThrowingPromiseInit().then(
99 ensurePromiseFail.bind(null,
7),
100 checkExn.bind(null,
98,
"NotFoundError",
101 "We are a second DOMException",
102 DOMException.NOT_FOUND_ERR, ourFile,
7,
103 `doTest@${ourFile}:
98:
9
106 t.testPromiseWithDOMExceptionThrowingThenFunction().then(
107 ensurePromiseFail.bind(null,
8),
108 checkExn.bind(null, asyncStack ?
106 :
0,
"NetworkError",
109 "We are a third DOMException",
110 DOMException.NETWORK_ERR, asyncStack ? ourFile :
"",
8,
111 (asyncStack ? `Async*doTest@${ourFile}:
106:
9
114 t.testPromiseWithDOMExceptionThrowingThenable().then(
115 ensurePromiseFail.bind(null,
9),
116 checkExn.bind(null, asyncStack ?
114 :
0,
"TypeMismatchError",
117 "We are a fourth DOMException",
118 DOMException.TYPE_MISMATCH_ERR,
119 asyncStack ? ourFile :
"",
9,
120 (asyncStack ? `Async*doTest@${ourFile}:
114:
9
123 ]).then(SimpleTest.finish,
125 ok(false,
"One of our catch statements totally failed with err" + err +
", stack: " + (err ? err.stack :
""));
130 SpecialPowers.pushPrefEnv({set: [[
"dom.expose_test_interfaces", true]]},
135 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1107592">Mozilla Bug
1107592</a>
137 <div id=
"content" style=
"display: none">