dom/promise/tests/test_resolve.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/promise/tests/test_resolve.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +<!--
     1.5 +  Any copyright is dedicated to the Public Domain.
     1.6 +  http://creativecommons.org/publicdomain/zero/1.0/
     1.7 +-->
     1.8 +<html>
     1.9 +<head>
    1.10 +  <title>Promise.resolve(anything) Test</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +</head>
    1.14 +<body>
    1.15 +<p id="display"></p>
    1.16 +<div id="content" style="display: none">
    1.17 +
    1.18 +</div>
    1.19 +<pre id="test">
    1.20 +<script type="application/javascript"><!--
    1.21 +
    1.22 +var tests = [
    1.23 +  null,
    1.24 +  42,
    1.25 +  "hello world",
    1.26 +  true,
    1.27 +  false,
    1.28 +  {},
    1.29 +  { a: 42 },
    1.30 +  [ 1, 2, 3, 4, null, true, "hello world" ],
    1.31 +  function() {},
    1.32 +  window,
    1.33 +  undefined,
    1.34 +  document.createElement('input'),
    1.35 +  new Date(),
    1.36 +];
    1.37 +
    1.38 +function cbError() {
    1.39 +  ok(false, "Nothing should arrive here!");
    1.40 +}
    1.41 +
    1.42 +function runTest() {
    1.43 +  if (!tests.length) {
    1.44 +    SimpleTest.finish();
    1.45 +    return;
    1.46 +  }
    1.47 +
    1.48 +  var test = tests.pop();
    1.49 +
    1.50 +  new Promise(function(resolve, reject) {
    1.51 +    resolve(test);
    1.52 +  }).then(function(what) {
    1.53 +    ok(test === what, "What is: " + what);
    1.54 +  }, cbError).then(function() {
    1.55 +    new Promise(function(resolve, reject) {
    1.56 +      reject(test)
    1.57 +    }).then(cbError, function(what) {
    1.58 +      ok(test === what, "What is: " + what);
    1.59 +    }).then(runTest, cbError);
    1.60 +  });
    1.61 +}
    1.62 +
    1.63 +SimpleTest.waitForExplicitFinish();
    1.64 +runTest();
    1.65 +// -->
    1.66 +</script>
    1.67 +</pre>
    1.68 +</body>
    1.69 +</html>
    1.70 +

mercurial