2013-06-11 18:41:22 -07:00
|
|
|
<!--
|
|
|
|
Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
-->
|
|
|
|
<html>
|
|
|
|
<head>
|
2013-06-20 01:49:40 -07:00
|
|
|
<title>Promise.resolve(anything) Test</title>
|
2013-06-11 18:41:22 -07:00
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<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,
|
|
|
|
document.createElement('input'),
|
|
|
|
new Date(),
|
|
|
|
];
|
|
|
|
|
|
|
|
function cbError() {
|
|
|
|
ok(false, "Nothing should arrive here!");
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
if (!tests.length) {
|
|
|
|
SimpleTest.finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var test = tests.pop();
|
|
|
|
|
2013-06-20 01:49:40 -07:00
|
|
|
new Promise(function(resolver) {
|
2013-06-11 18:41:22 -07:00
|
|
|
resolver.resolve(test);
|
|
|
|
}).then(function(what) {
|
|
|
|
ok(test === what, "What is: " + what);
|
2013-06-20 03:20:01 -07:00
|
|
|
}, cbError).done(function() {
|
2013-06-20 01:49:40 -07:00
|
|
|
new Promise(function(resolver) {
|
2013-06-11 18:41:22 -07:00
|
|
|
resolver.reject(test)
|
|
|
|
}).then(cbError, function(what) {
|
|
|
|
ok(test === what, "What is: " + what);
|
2013-06-20 03:20:01 -07:00
|
|
|
}).done(runTest, cbError);
|
2013-06-11 18:41:22 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2013-06-20 01:49:40 -07:00
|
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.promise.enabled", true]]}, runTest);
|
2013-06-11 18:41:22 -07:00
|
|
|
// -->
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|