test_sanityAddTask.xul 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?xml version="1.0"?>
  2. <!-- This Source Code Form is subject to the terms of the Mozilla Public
  3. - License, v. 2.0. If a copy of the MPL was not distributed with this
  4. - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
  5. <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
  6. type="text/css"?>
  7. <window title="Test spawnTawk function"
  8. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  9. <script type="application/javascript"
  10. src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  11. <script type="application/javascript"
  12. src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"/>
  13. <script type="application/javascript">
  14. <![CDATA[
  15. // Check that we can 'add_task' a few times and all tasks run asynchronously before test finishes.
  16. add_task(function* () {
  17. var x = yield Promise.resolve(1);
  18. is(x, 1, "task yields Promise value as expected");
  19. });
  20. add_task(function* () {
  21. var x = yield [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)];
  22. is(x.join(""), "123", "task yields Promise value as expected");
  23. });
  24. add_task(function* () {
  25. var x = yield (function* () {
  26. return 3;
  27. }());
  28. is(x, 3, "task yields generator function return value as expected");
  29. });
  30. ]]>
  31. </script>
  32. <body xmlns="http://www.w3.org/1999/xhtml" >
  33. </body>
  34. </window>