Bug 856410 - Implement futures - Part 6: Additional tests. r=mounir
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 11 Jun 2013 21:41:22 -0400
changeset 146294 fcc490282828806ecda651533c8f0fc531027a1c
parent 146293 6954d8ae226de069125119f47f931460d2c72fc6
child 146295 a3d315019c47df5a0824f74a5eae5760202daa86
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs856410
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 856410 - Implement futures - Part 6: Additional tests. r=mounir
dom/future/tests/Makefile.in
dom/future/tests/test_resolve.html
--- a/dom/future/tests/Makefile.in
+++ b/dom/future/tests/Makefile.in
@@ -8,11 +8,12 @@ srcdir           = @srcdir@
 VPATH            = @srcdir@
 
 relativesrcdir   = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_FILES = \
   test_future.html \
+  test_resolve.html \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/future/tests/test_resolve.html
@@ -0,0 +1,67 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+  <title>Future.resolve(anything) Test</title>
+  <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();
+
+  new Future(function(resolver) {
+    resolver.resolve(test);
+  }).then(function(what) {
+    ok(test === what, "What is: " + what);
+  }, cbError).done(function() {
+    new Future(function(resolver) {
+      resolver.reject(test)
+    }).then(cbError, function(what) {
+      ok(test === what, "What is: " + what);
+    }).done(runTest, cbError);
+  });
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["dom.future.enabled", true]]}, runTest);
+// -->
+</script>
+</pre>
+</body>
+</html>
+