2013-06-12 01:41:22 +00:00
|
|
|
<!--
|
|
|
|
Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
-->
|
|
|
|
<html>
|
|
|
|
<head>
|
2013-07-11 20:40:36 +00:00
|
|
|
<title>Promise.resolve(anything) Test</title>
|
2019-04-16 03:53:28 +00:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
2013-06-12 01:41:22 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript"><!--
|
|
|
|
|
|
|
|
var tests = [
|
|
|
|
null,
|
|
|
|
42,
|
|
|
|
"hello world",
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
{},
|
|
|
|
{ a: 42 },
|
|
|
|
[ 1, 2, 3, 4, null, true, "hello world" ],
|
|
|
|
function() {},
|
|
|
|
window,
|
|
|
|
undefined,
|
2019-06-25 20:11:52 +00:00
|
|
|
document.createElement("input"),
|
2013-06-12 01:41:22 +00:00
|
|
|
new Date(),
|
|
|
|
];
|
|
|
|
|
|
|
|
function cbError() {
|
|
|
|
ok(false, "Nothing should arrive here!");
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
if (!tests.length) {
|
|
|
|
SimpleTest.finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var test = tests.pop();
|
|
|
|
|
2013-09-11 16:03:04 +00:00
|
|
|
new Promise(function(resolve, reject) {
|
|
|
|
resolve(test);
|
2013-06-12 01:41:22 +00:00
|
|
|
}).then(function(what) {
|
|
|
|
ok(test === what, "What is: " + what);
|
2013-07-16 13:56:24 +00:00
|
|
|
}, cbError).then(function() {
|
2013-09-11 16:03:04 +00:00
|
|
|
new Promise(function(resolve, reject) {
|
2019-06-25 20:11:52 +00:00
|
|
|
reject(test);
|
2013-06-12 01:41:22 +00:00
|
|
|
}).then(cbError, function(what) {
|
|
|
|
ok(test === what, "What is: " + what);
|
2013-07-16 13:56:24 +00:00
|
|
|
}).then(runTest, cbError);
|
2013-06-12 01:41:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2014-01-30 21:14:00 +00:00
|
|
|
runTest();
|
2013-06-12 01:41:22 +00:00
|
|
|
// -->
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|