browser_jsterm_inspect.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. // Check that the inspect() jsterm helper function works.
  5. "use strict";
  6. const TEST_URI = "data:text/html;charset=utf8,<p>hello bug 869981";
  7. add_task(function* () {
  8. yield loadTab(TEST_URI);
  9. let hud = yield openConsole();
  10. let jsterm = hud.jsterm;
  11. /* Check that the window object is inspected */
  12. jsterm.execute("testProp = 'testValue'");
  13. let updated = jsterm.once("variablesview-updated");
  14. jsterm.execute("inspect(window)");
  15. let view = yield updated;
  16. ok(view, "variables view object");
  17. // The single variable view contains a scope with the variable name
  18. // and unnamed subitem that contains the properties
  19. let variable = view.getScopeAtIndex(0).get(undefined);
  20. ok(variable, "variable object");
  21. yield findVariableViewProperties(variable, [
  22. { name: "testProp", value: "testValue" },
  23. { name: "document", value: /HTMLDocument \u2192 data:/ },
  24. ], { webconsole: hud });
  25. /* Check that a primitive value can be inspected, too */
  26. let updated2 = jsterm.once("variablesview-updated");
  27. jsterm.execute("inspect(1)");
  28. let view2 = yield updated2;
  29. ok(view2, "variables view object");
  30. // Check the label of the scope - it should contain the value
  31. let scope = view.getScopeAtIndex(0);
  32. ok(scope, "variable object");
  33. is(scope.name, "1", "The value of the primitive var is correct");
  34. });