|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Check that the editing state of a Variable is correctly tracked. Clicking on |
|
6 * the textbox while editing should not cancel editing. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html"; |
|
10 |
|
11 function test() { |
|
12 Task.spawn(function*() { |
|
13 let [tab, debuggee, panel] = yield initDebugger(TAB_URL); |
|
14 let win = panel.panelWin; |
|
15 let vars = win.DebuggerView.Variables; |
|
16 |
|
17 win.DebuggerView.WatchExpressions.addExpression("this"); |
|
18 |
|
19 // Allow this generator function to yield first. |
|
20 executeSoon(() => debuggee.ermahgerd()); |
|
21 yield waitForDebuggerEvents(panel, win.EVENTS.FETCHED_WATCH_EXPRESSIONS); |
|
22 |
|
23 let exprScope = vars.getScopeAtIndex(0); |
|
24 let exprVar = exprScope.get("this"); |
|
25 let name = exprVar.target.querySelector(".title > .name"); |
|
26 |
|
27 is(exprVar.editing, false, |
|
28 "The expression should indicate it is not being edited."); |
|
29 |
|
30 EventUtils.sendMouseEvent({ type: "dblclick" }, name, win); |
|
31 let input = exprVar.target.querySelector(".title > .element-name-input"); |
|
32 is(exprVar.editing, true, |
|
33 "The expression should indicate it is being edited."); |
|
34 is(input.selectionStart !== input.selectionEnd, true, |
|
35 "The expression text should be selected."); |
|
36 |
|
37 EventUtils.synthesizeMouse(input, 2, 2, {}, win); |
|
38 is(exprVar.editing, true, |
|
39 "The expression should indicate it is still being edited after a click."); |
|
40 is(input.selectionStart === input.selectionEnd, true, |
|
41 "The expression text should not be selected."); |
|
42 |
|
43 EventUtils.sendKey("ESCAPE", win); |
|
44 is(exprVar.editing, false, |
|
45 "The expression should indicate it is not being edited after cancelling."); |
|
46 |
|
47 // Why is this needed? |
|
48 EventUtils.synthesizeMouse(vars.parentNode, 2, 2, {}, win); |
|
49 |
|
50 yield resumeDebuggerThenCloseAndFinish(panel); |
|
51 }); |
|
52 } |