browser/devtools/debugger/test/browser_dbg_breadcrumbs-access.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_breadcrumbs-access.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests if the stackframe breadcrumbs are keyboard accessible.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    1.12 +
    1.13 +function test() {
    1.14 +  let gTab, gDebuggee, gPanel, gDebugger;
    1.15 +  let gSources, gFrames;
    1.16 +
    1.17 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.18 +    gTab = aTab;
    1.19 +    gDebuggee = aDebuggee;
    1.20 +    gPanel = aPanel;
    1.21 +    gDebugger = gPanel.panelWin;
    1.22 +    gSources = gDebugger.DebuggerView.Sources;
    1.23 +    gFrames = gDebugger.DebuggerView.StackFrames;
    1.24 +
    1.25 +    waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1)
    1.26 +      .then(checkNavigationWhileNotFocused)
    1.27 +      .then(focusCurrentStackFrame)
    1.28 +      .then(checkNavigationWhileFocused)
    1.29 +      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    1.30 +      .then(null, aError => {
    1.31 +        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.32 +      });
    1.33 +
    1.34 +    gDebuggee.firstCall();
    1.35 +  });
    1.36 +
    1.37 +  function checkNavigationWhileNotFocused() {
    1.38 +    checkState({ frame: 3, source: 1, line: 1 });
    1.39 +
    1.40 +    EventUtils.sendKey("DOWN", gDebugger);
    1.41 +    checkState({ frame: 3, source: 1, line: 2 });
    1.42 +
    1.43 +    EventUtils.sendKey("UP", gDebugger);
    1.44 +    checkState({ frame: 3, source: 1, line: 1 });
    1.45 +  }
    1.46 +
    1.47 +  function focusCurrentStackFrame() {
    1.48 +    EventUtils.sendMouseEvent({ type: "mousedown" },
    1.49 +      gFrames.selectedItem.target,
    1.50 +      gDebugger);
    1.51 +  }
    1.52 +
    1.53 +  function checkNavigationWhileFocused() {
    1.54 +    return Task.spawn(function() {
    1.55 +      yield promise.all([
    1.56 +        waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
    1.57 +        EventUtils.sendKey("UP", gDebugger)
    1.58 +      ]);
    1.59 +      checkState({ frame: 2, source: 1, line: 1 });
    1.60 +
    1.61 +      yield promise.all([
    1.62 +        waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
    1.63 +        waitForSourceAndCaret(gPanel, "-01.js", 1),
    1.64 +        EventUtils.sendKey("UP", gDebugger)
    1.65 +      ]);
    1.66 +      checkState({ frame: 1, source: 0, line: 1 });
    1.67 +
    1.68 +      yield promise.all([
    1.69 +        waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
    1.70 +        EventUtils.sendKey("UP", gDebugger)
    1.71 +      ]);
    1.72 +      checkState({ frame: 0, source: 0, line: 5 });
    1.73 +
    1.74 +      yield promise.all([
    1.75 +        waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
    1.76 +        waitForSourceAndCaret(gPanel, "-02.js", 1),
    1.77 +        EventUtils.sendKey("END", gDebugger)
    1.78 +      ]);
    1.79 +      checkState({ frame: 3, source: 1, line: 1 });
    1.80 +
    1.81 +      yield promise.all([
    1.82 +        waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
    1.83 +        waitForSourceAndCaret(gPanel, "-01.js", 1),
    1.84 +        EventUtils.sendKey("HOME", gDebugger)
    1.85 +      ]);
    1.86 +      checkState({ frame: 0, source: 0, line: 5 });
    1.87 +    });
    1.88 +  }
    1.89 +
    1.90 +  function checkState({ frame, source, line }) {
    1.91 +    is(gFrames.selectedIndex, frame,
    1.92 +      "The currently selected stackframe is incorrect.");
    1.93 +    is(gSources.selectedIndex, source,
    1.94 +      "The currently selected source is incorrect.");
    1.95 +    ok(isCaretPos(gPanel, line),
    1.96 +      "The source editor caret position was incorrect.");
    1.97 +  }
    1.98 +}

mercurial