browser_dbg_optimized-out-vars.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // Test that optimized out variables aren't present in the variables view.
  5. function test() {
  6. Task.spawn(function* () {
  7. const TAB_URL = EXAMPLE_URL + "doc_closure-optimized-out.html";
  8. let gDebugger, sources;
  9. let options = {
  10. source: TAB_URL,
  11. line: 1
  12. };
  13. let [tab,, panel] = yield initDebugger(TAB_URL, options);
  14. gDebugger = panel.panelWin;
  15. sources = gDebugger.DebuggerView.Sources;
  16. yield panel.addBreakpoint({ actor: sources.values[0],
  17. line: 18 });
  18. yield ensureThreadClientState(panel, "resumed");
  19. // Spin the event loop before causing the debuggee to pause, to allow
  20. // this function to return first.
  21. generateMouseClickInTab(tab, "content.document.querySelector('button')");
  22. yield waitForDebuggerEvents(panel, gDebugger.EVENTS.FETCHED_SCOPES);
  23. let gVars = gDebugger.DebuggerView.Variables;
  24. let outerScope = gVars.getScopeAtIndex(1);
  25. outerScope.expand();
  26. let upvarVar = outerScope.get("upvar");
  27. ok(upvarVar, "The variable `upvar` is shown.");
  28. is(upvarVar.target.querySelector(".value").getAttribute("value"),
  29. gDebugger.L10N.getStr("variablesViewOptimizedOut"),
  30. "Should show the optimized out message for upvar.");
  31. let argVar = outerScope.get("arg");
  32. is(argVar.target.querySelector(".name").getAttribute("value"), "arg",
  33. "Should have the right property name for |arg|.");
  34. is(argVar.target.querySelector(".value").getAttribute("value"), 42,
  35. "Should have the right property value for |arg|.");
  36. yield resumeDebuggerThenCloseAndFinish(panel);
  37. }).then(null, aError => {
  38. ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
  39. });
  40. }