browser_scratchpad_inspect.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. function test()
  4. {
  5. waitForExplicitFinish();
  6. gBrowser.selectedTab = gBrowser.addTab();
  7. gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
  8. gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
  9. openScratchpad(runTests);
  10. }, true);
  11. content.location = "data:text/html;charset=utf8,<p>test inspect() in Scratchpad</p>";
  12. }
  13. function runTests()
  14. {
  15. let sp = gScratchpadWindow.Scratchpad;
  16. sp.setText("({ a: 'foobarBug636725' })");
  17. sp.inspect().then(function () {
  18. let sidebar = sp.sidebar;
  19. ok(sidebar.visible, "sidebar is open");
  20. let found = false;
  21. outer: for (let scope of sidebar.variablesView) {
  22. for (let [, obj] of scope) {
  23. for (let [, prop] of obj) {
  24. if (prop.name == "a" && prop.value == "foobarBug636725") {
  25. found = true;
  26. break outer;
  27. }
  28. }
  29. }
  30. }
  31. ok(found, "found the property");
  32. let tabbox = sidebar._sidebar._tabbox;
  33. is(tabbox.width, 300, "Scratchpad sidebar width is correct");
  34. ok(!tabbox.hasAttribute("hidden"), "Scratchpad sidebar visible");
  35. sidebar.hide();
  36. ok(tabbox.hasAttribute("hidden"), "Scratchpad sidebar hidden");
  37. sp.inspect().then(function () {
  38. is(tabbox.width, 300, "Scratchpad sidebar width is still correct");
  39. ok(!tabbox.hasAttribute("hidden"), "Scratchpad sidebar visible again");
  40. finish();
  41. });
  42. });
  43. }