2015-01-16 01:39:02 +03:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Test for Bug 1107592</title>
|
2019-04-16 06:53:28 +03:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
2015-01-16 01:39:02 +03:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
<script type="application/javascript">
|
2019-03-29 19:47:06 +03:00
|
|
|
/* global TestInterfaceJS, thereIsNoSuchContentFunction1, thereIsNoSuchContentFunction2, thereIsNoSuchContentFunction3 */
|
2015-01-16 01:39:02 +03:00
|
|
|
/** Test for Bug 1107592 **/
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2015-01-16 01:39:02 +03:00
|
|
|
function checkExn(lineNumber, name, message, code, filename, testNumber, stack, exn) {
|
2015-05-13 02:52:01 +03:00
|
|
|
is(exn.lineNumber, lineNumber,
|
|
|
|
"Should have the right line number in test " + testNumber);
|
|
|
|
is(exn.name, name,
|
|
|
|
"Should have the right exception name in test " + testNumber);
|
|
|
|
is("filename" in exn ? exn.filename : exn.fileName, filename,
|
|
|
|
"Should have the right file name in test " + testNumber);
|
|
|
|
is(exn.message, message,
|
|
|
|
"Should have the right message in test " + testNumber);
|
|
|
|
is(exn.code, code, "Should have the right .code in test " + testNumber);
|
2015-01-16 01:39:02 +03:00
|
|
|
if (message === "") {
|
2016-07-21 01:44:16 +03:00
|
|
|
is(exn.name, "InternalError",
|
2015-05-13 02:52:01 +03:00
|
|
|
"Should have one of our synthetic exceptions in test " + testNumber);
|
2015-01-16 01:39:02 +03:00
|
|
|
}
|
2015-05-13 02:52:01 +03:00
|
|
|
is(exn.stack, stack, "Should have the right stack in test " + testNumber);
|
2015-01-16 01:39:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function ensurePromiseFail(testNumber, value) {
|
|
|
|
ok(false, "Test " + testNumber + " should not have a fulfilled promise");
|
|
|
|
}
|
|
|
|
|
|
|
|
function doTest() {
|
|
|
|
var t = new TestInterfaceJS();
|
2019-06-24 23:47:53 +03:00
|
|
|
|
|
|
|
|
2015-06-09 12:17:09 +03:00
|
|
|
var asyncStack = SpecialPowers.getBoolPref("javascript.options.asyncstack");
|
2015-07-24 14:01:00 +03:00
|
|
|
var ourFile = location.href;
|
2016-07-21 01:44:16 +03:00
|
|
|
var unwrapError = "Promise rejection value is a non-unwrappable cross-compartment wrapper.";
|
2019-06-24 23:47:53 +03:00
|
|
|
var parentFrame = asyncStack ? `Async*@${ourFile}:130:17
|
2015-07-24 14:01:00 +03:00
|
|
|
` : "";
|
2015-01-16 01:39:02 +03:00
|
|
|
|
|
|
|
Promise.all([
|
|
|
|
t.testPromiseWithThrowingChromePromiseInit().then(
|
|
|
|
ensurePromiseFail.bind(null, 1),
|
2016-07-21 01:44:16 +03:00
|
|
|
checkExn.bind(null, 49, "InternalError", unwrapError,
|
|
|
|
undefined, ourFile, 1,
|
2019-02-13 05:55:21 +03:00
|
|
|
`doTest@${ourFile}:49:9
|
2015-07-24 14:01:00 +03:00
|
|
|
` +
|
|
|
|
parentFrame)),
|
2015-01-16 01:39:02 +03:00
|
|
|
t.testPromiseWithThrowingContentPromiseInit(function() {
|
|
|
|
thereIsNoSuchContentFunction1();
|
|
|
|
}).then(
|
|
|
|
ensurePromiseFail.bind(null, 2),
|
2016-07-21 01:44:16 +03:00
|
|
|
checkExn.bind(null, 57, "ReferenceError",
|
2015-01-16 01:39:02 +03:00
|
|
|
"thereIsNoSuchContentFunction1 is not defined",
|
2015-01-16 01:39:02 +03:00
|
|
|
undefined, ourFile, 2,
|
2016-07-21 01:44:16 +03:00
|
|
|
`doTest/<@${ourFile}:57:11
|
2019-02-13 05:55:21 +03:00
|
|
|
doTest@${ourFile}:56:9
|
2015-07-24 14:01:00 +03:00
|
|
|
` +
|
|
|
|
parentFrame)),
|
2015-01-16 01:39:02 +03:00
|
|
|
t.testPromiseWithThrowingChromeThenFunction().then(
|
|
|
|
ensurePromiseFail.bind(null, 3),
|
2019-02-13 05:55:21 +03:00
|
|
|
checkExn.bind(null, 0, "InternalError", unwrapError, undefined, "", 3, asyncStack ? (`Async*doTest@${ourFile}:67:9
|
2016-07-21 01:44:16 +03:00
|
|
|
` +
|
|
|
|
parentFrame) : "")),
|
2015-01-16 01:39:02 +03:00
|
|
|
t.testPromiseWithThrowingContentThenFunction(function() {
|
|
|
|
thereIsNoSuchContentFunction2();
|
|
|
|
}).then(
|
|
|
|
ensurePromiseFail.bind(null, 4),
|
2016-07-21 01:44:16 +03:00
|
|
|
checkExn.bind(null, 73, "ReferenceError",
|
2015-01-16 01:39:02 +03:00
|
|
|
"thereIsNoSuchContentFunction2 is not defined",
|
2015-01-16 01:39:02 +03:00
|
|
|
undefined, ourFile, 4,
|
2016-07-21 01:44:16 +03:00
|
|
|
`doTest/<@${ourFile}:73:11
|
2015-07-24 14:01:00 +03:00
|
|
|
` +
|
2019-02-13 05:55:21 +03:00
|
|
|
(asyncStack ? `Async*doTest@${ourFile}:72:9
|
2015-07-24 14:01:00 +03:00
|
|
|
` : "") +
|
|
|
|
parentFrame)),
|
2015-01-16 01:39:02 +03:00
|
|
|
t.testPromiseWithThrowingChromeThenable().then(
|
|
|
|
ensurePromiseFail.bind(null, 5),
|
2019-02-13 05:55:21 +03:00
|
|
|
checkExn.bind(null, 0, "InternalError", unwrapError, undefined, "", 5, asyncStack ? (`Async*doTest@${ourFile}:84:9
|
2016-07-21 01:44:16 +03:00
|
|
|
` +
|
|
|
|
parentFrame) : "")),
|
2015-01-16 01:39:02 +03:00
|
|
|
t.testPromiseWithThrowingContentThenable({
|
2019-03-28 12:11:04 +03:00
|
|
|
then() { thereIsNoSuchContentFunction3(); },
|
2015-01-16 01:39:02 +03:00
|
|
|
}).then(
|
|
|
|
ensurePromiseFail.bind(null, 6),
|
2016-07-21 01:44:16 +03:00
|
|
|
checkExn.bind(null, 90, "ReferenceError",
|
2015-01-16 01:39:02 +03:00
|
|
|
"thereIsNoSuchContentFunction3 is not defined",
|
2015-01-16 01:39:02 +03:00
|
|
|
undefined, ourFile, 6,
|
2019-03-29 19:47:06 +03:00
|
|
|
`then@${ourFile}:90:22
|
2019-02-13 05:55:21 +03:00
|
|
|
` + (asyncStack ? `Async*doTest@${ourFile}:89:9\n` + parentFrame : ""))),
|
2015-01-16 01:39:02 +03:00
|
|
|
t.testPromiseWithDOMExceptionThrowingPromiseInit().then(
|
|
|
|
ensurePromiseFail.bind(null, 7),
|
2016-07-21 01:44:16 +03:00
|
|
|
checkExn.bind(null, 98, "NotFoundError",
|
2015-01-16 01:39:02 +03:00
|
|
|
"We are a second DOMException",
|
|
|
|
DOMException.NOT_FOUND_ERR, ourFile, 7,
|
2019-02-13 05:55:21 +03:00
|
|
|
`doTest@${ourFile}:98:9
|
2015-07-24 14:01:00 +03:00
|
|
|
` +
|
|
|
|
parentFrame)),
|
2015-01-16 01:39:02 +03:00
|
|
|
t.testPromiseWithDOMExceptionThrowingThenFunction().then(
|
|
|
|
ensurePromiseFail.bind(null, 8),
|
2016-07-21 01:44:16 +03:00
|
|
|
checkExn.bind(null, asyncStack ? 106 : 0, "NetworkError",
|
2015-06-09 12:17:09 +03:00
|
|
|
"We are a third DOMException",
|
|
|
|
DOMException.NETWORK_ERR, asyncStack ? ourFile : "", 8,
|
2019-02-13 05:55:21 +03:00
|
|
|
(asyncStack ? `Async*doTest@${ourFile}:106:9
|
2015-07-24 14:01:00 +03:00
|
|
|
` +
|
|
|
|
parentFrame : ""))),
|
2015-01-16 01:39:02 +03:00
|
|
|
t.testPromiseWithDOMExceptionThrowingThenable().then(
|
|
|
|
ensurePromiseFail.bind(null, 9),
|
2016-07-21 01:44:16 +03:00
|
|
|
checkExn.bind(null, asyncStack ? 114 : 0, "TypeMismatchError",
|
2015-01-16 01:39:02 +03:00
|
|
|
"We are a fourth DOMException",
|
2016-07-21 01:44:16 +03:00
|
|
|
DOMException.TYPE_MISMATCH_ERR,
|
|
|
|
asyncStack ? ourFile : "", 9,
|
2019-02-13 05:55:21 +03:00
|
|
|
(asyncStack ? `Async*doTest@${ourFile}:114:9
|
2016-07-21 01:44:16 +03:00
|
|
|
` +
|
|
|
|
parentFrame : ""))),
|
2015-01-16 01:39:02 +03:00
|
|
|
]).then(SimpleTest.finish,
|
2016-07-21 01:44:16 +03:00
|
|
|
function(err) {
|
2019-03-28 12:11:04 +03:00
|
|
|
ok(false, "One of our catch statements totally failed with err" + err + ", stack: " + (err ? err.stack : ""));
|
2015-01-16 01:39:02 +03:00
|
|
|
SimpleTest.finish();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-03-28 12:11:04 +03:00
|
|
|
SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]},
|
2015-01-16 01:39:02 +03:00
|
|
|
doTest);
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107592">Mozilla Bug 1107592</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|