michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Check that the editing state of a Variable is correctly tracked. Clicking on michael@0: * the textbox while editing should not cancel editing. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html"; michael@0: michael@0: function test() { michael@0: Task.spawn(function*() { michael@0: let [tab, debuggee, panel] = yield initDebugger(TAB_URL); michael@0: let win = panel.panelWin; michael@0: let vars = win.DebuggerView.Variables; michael@0: michael@0: win.DebuggerView.WatchExpressions.addExpression("this"); michael@0: michael@0: // Allow this generator function to yield first. michael@0: executeSoon(() => debuggee.ermahgerd()); michael@0: yield waitForDebuggerEvents(panel, win.EVENTS.FETCHED_WATCH_EXPRESSIONS); michael@0: michael@0: let exprScope = vars.getScopeAtIndex(0); michael@0: let exprVar = exprScope.get("this"); michael@0: let name = exprVar.target.querySelector(".title > .name"); michael@0: michael@0: is(exprVar.editing, false, michael@0: "The expression should indicate it is not being edited."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "dblclick" }, name, win); michael@0: let input = exprVar.target.querySelector(".title > .element-name-input"); michael@0: is(exprVar.editing, true, michael@0: "The expression should indicate it is being edited."); michael@0: is(input.selectionStart !== input.selectionEnd, true, michael@0: "The expression text should be selected."); michael@0: michael@0: EventUtils.synthesizeMouse(input, 2, 2, {}, win); michael@0: is(exprVar.editing, true, michael@0: "The expression should indicate it is still being edited after a click."); michael@0: is(input.selectionStart === input.selectionEnd, true, michael@0: "The expression text should not be selected."); michael@0: michael@0: EventUtils.sendKey("ESCAPE", win); michael@0: is(exprVar.editing, false, michael@0: "The expression should indicate it is not being edited after cancelling."); michael@0: michael@0: // Why is this needed? michael@0: EventUtils.synthesizeMouse(vars.parentNode, 2, 2, {}, win); michael@0: michael@0: yield resumeDebuggerThenCloseAndFinish(panel); michael@0: }); michael@0: }