browser_scratchpad_falsy.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /* Bug 679467 */
  4. function test()
  5. {
  6. waitForExplicitFinish();
  7. gBrowser.selectedTab = gBrowser.addTab();
  8. gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
  9. gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
  10. openScratchpad(testFalsy);
  11. }, true);
  12. content.location = "data:text/html,<p>test falsy display() values in Scratchpad";
  13. }
  14. function testFalsy()
  15. {
  16. let scratchpad = gScratchpadWindow.Scratchpad;
  17. verifyFalsies(scratchpad).then(function () {
  18. scratchpad.setBrowserContext();
  19. verifyFalsies(scratchpad).then(finish);
  20. });
  21. }
  22. function verifyFalsies(scratchpad)
  23. {
  24. let tests = [{
  25. method: "display",
  26. code: "undefined",
  27. result: "undefined\n/*\nundefined\n*/",
  28. label: "undefined is displayed"
  29. },
  30. {
  31. method: "display",
  32. code: "false",
  33. result: "false\n/*\nfalse\n*/",
  34. label: "false is displayed"
  35. },
  36. {
  37. method: "display",
  38. code: "0",
  39. result: "0\n/*\n0\n*/",
  40. label: "0 is displayed"
  41. },
  42. {
  43. method: "display",
  44. code: "null",
  45. result: "null\n/*\nnull\n*/",
  46. label: "null is displayed"
  47. },
  48. {
  49. method: "display",
  50. code: "NaN",
  51. result: "NaN\n/*\nNaN\n*/",
  52. label: "NaN is displayed"
  53. },
  54. {
  55. method: "display",
  56. code: "''",
  57. result: "''\n/*\n\n*/",
  58. label: "the empty string is displayed"
  59. }];
  60. return runAsyncTests(scratchpad, tests);
  61. }