summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-edit-cancel.js
blob: 6bddf24888973a874a8bfbc8777c74041292fd3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Make sure that canceling a name change correctly unhides the separator and
 * value elements.
 */

const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html";

function test() {
  Task.spawn(function* () {
    let options = {
      source: TAB_URL,
      line: 1
    };
    let [tab,, panel] = yield initDebugger(TAB_URL, options);
    let win = panel.panelWin;
    let vars = win.DebuggerView.Variables;

    win.DebuggerView.WatchExpressions.addExpression("this");

    callInTab(tab, "ermahgerd");
    yield waitForDebuggerEvents(panel, win.EVENTS.FETCHED_WATCH_EXPRESSIONS);

    let exprScope = vars.getScopeAtIndex(0);
    let {target} = exprScope.get("this");

    let name = target.querySelector(".title > .name");
    let separator = target.querySelector(".separator");
    let value = target.querySelector(".value");

    is(separator.hidden, false,
      "The separator element should not be hidden.");
    is(value.hidden, false,
      "The value element should not be hidden.");

    for (let key of ["ESCAPE", "RETURN"]) {
      EventUtils.sendMouseEvent({ type: "dblclick" }, name, win);

      is(separator.hidden, true,
        "The separator element should be hidden.");
      is(value.hidden, true,
        "The value element should be hidden.");

      EventUtils.sendKey(key, win);

      is(separator.hidden, false,
        "The separator element should not be hidden.");
      is(value.hidden, false,
        "The value element should not be hidden.");
    }

    yield resumeDebuggerThenCloseAndFinish(panel);
  });
}