browser_dbg_variables-view-07.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. /**
  5. * Test that proxy objects get their internal state added as pseudo properties.
  6. */
  7. const TAB_URL = EXAMPLE_URL + "doc_proxy.html";
  8. var test = Task.async(function* () {
  9. let options = {
  10. source: TAB_URL,
  11. line: 1
  12. };
  13. var dbg = initDebugger(TAB_URL, options);
  14. const [tab,, panel] = yield dbg;
  15. const debuggerLineNumber = 34;
  16. const scopes = waitForCaretAndScopes(panel, debuggerLineNumber);
  17. callInTab(tab, "doPause");
  18. yield scopes;
  19. const variables = panel.panelWin.DebuggerView.Variables;
  20. ok(variables, "Should get the variables view.");
  21. const scope = [...variables][0];
  22. ok(scope, "Should get the current function's scope.");
  23. let proxy;
  24. for (let [name, value] of scope) {
  25. if (name === "proxy") {
  26. proxy = value;
  27. }
  28. }
  29. ok(proxy, "Should have found the proxy variable");
  30. info("Expanding variable 'proxy'");
  31. let expanded = once(variables, "fetched");
  32. proxy.expand();
  33. yield expanded;
  34. let foundTarget = false;
  35. let foundHandler = false;
  36. for (let [property, data] of proxy) {
  37. info("Expanding property '" + property + "'");
  38. let expanded = once(variables, "fetched");
  39. data.expand();
  40. yield expanded;
  41. if (property === "<target>") {
  42. for(let [subprop, subdata] of data) if(subprop === "name") {
  43. is(subdata.value, "target", "The value of '<target>' should be the [[ProxyTarget]]");
  44. foundTarget = true;
  45. }
  46. } else {
  47. is(property, "<handler>", "There shouldn't be properties other than <target> and <handler>");
  48. for (let [subprop, subdata] of data) {
  49. if(subprop === "name") {
  50. is(subdata.value, "handler", "The value of '<handler>' should be the [[ProxyHandler]]");
  51. foundHandler = true;
  52. }
  53. }
  54. }
  55. }
  56. ok(foundTarget, "Should have found the '<target>' property containing the [[ProxyTarget]]");
  57. ok(foundHandler, "Should have found the '<handler>' property containing the [[ProxyHandler]]");
  58. resumeDebuggerThenCloseAndFinish(panel);
  59. });