1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-click.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 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 + * Check that the editing state of a Variable is correctly tracked. Clicking on 1.9 + * the textbox while editing should not cancel editing. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html"; 1.13 + 1.14 +function test() { 1.15 + Task.spawn(function*() { 1.16 + let [tab, debuggee, panel] = yield initDebugger(TAB_URL); 1.17 + let win = panel.panelWin; 1.18 + let vars = win.DebuggerView.Variables; 1.19 + 1.20 + win.DebuggerView.WatchExpressions.addExpression("this"); 1.21 + 1.22 + // Allow this generator function to yield first. 1.23 + executeSoon(() => debuggee.ermahgerd()); 1.24 + yield waitForDebuggerEvents(panel, win.EVENTS.FETCHED_WATCH_EXPRESSIONS); 1.25 + 1.26 + let exprScope = vars.getScopeAtIndex(0); 1.27 + let exprVar = exprScope.get("this"); 1.28 + let name = exprVar.target.querySelector(".title > .name"); 1.29 + 1.30 + is(exprVar.editing, false, 1.31 + "The expression should indicate it is not being edited."); 1.32 + 1.33 + EventUtils.sendMouseEvent({ type: "dblclick" }, name, win); 1.34 + let input = exprVar.target.querySelector(".title > .element-name-input"); 1.35 + is(exprVar.editing, true, 1.36 + "The expression should indicate it is being edited."); 1.37 + is(input.selectionStart !== input.selectionEnd, true, 1.38 + "The expression text should be selected."); 1.39 + 1.40 + EventUtils.synthesizeMouse(input, 2, 2, {}, win); 1.41 + is(exprVar.editing, true, 1.42 + "The expression should indicate it is still being edited after a click."); 1.43 + is(input.selectionStart === input.selectionEnd, true, 1.44 + "The expression text should not be selected."); 1.45 + 1.46 + EventUtils.sendKey("ESCAPE", win); 1.47 + is(exprVar.editing, false, 1.48 + "The expression should indicate it is not being edited after cancelling."); 1.49 + 1.50 + // Why is this needed? 1.51 + EventUtils.synthesizeMouse(vars.parentNode, 2, 2, {}, win); 1.52 + 1.53 + yield resumeDebuggerThenCloseAndFinish(panel); 1.54 + }); 1.55 +}