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: * Make sure that the variables view is able to override getter properties michael@0: * to plain value properties. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gL10N, gEditor, gVars, gWatch; michael@0: michael@0: function test() { michael@0: // Debug test slaves are a bit slow at this test. michael@0: requestLongerTimeout(2); michael@0: michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gL10N = gDebugger.L10N; michael@0: gEditor = gDebugger.DebuggerView.editor; michael@0: gVars = gDebugger.DebuggerView.Variables; michael@0: gWatch = gDebugger.DebuggerView.WatchExpressions; michael@0: michael@0: gVars.switch = function() {}; michael@0: gVars.delete = function() {}; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 24) michael@0: .then(() => addWatchExpression()) michael@0: .then(() => testEdit("\"xlerb\"", "xlerb")) michael@0: .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: gDebuggee.document.querySelector("button"), michael@0: gDebuggee); michael@0: }); michael@0: } michael@0: michael@0: function addWatchExpression() { michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS); michael@0: michael@0: gWatch.addExpression("myVar.prop"); michael@0: gEditor.focus(); michael@0: michael@0: return finished; michael@0: } michael@0: michael@0: function testEdit(aString, aExpected) { michael@0: let localScope = gVars.getScopeAtIndex(1); michael@0: let myVar = localScope.get("myVar"); michael@0: michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES).then(() => { michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS).then(() => { michael@0: let exprScope = gVars.getScopeAtIndex(0); michael@0: michael@0: ok(exprScope, michael@0: "There should be a wach expressions scope in the variables view."); michael@0: is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"), michael@0: "The scope's name should be marked as 'Watch Expressions'."); michael@0: is(exprScope._store.size, 1, michael@0: "There should be one evaluation available."); michael@0: michael@0: is(exprScope.get("myVar.prop").value, aExpected, michael@0: "The expression value is correct after the edit."); michael@0: }); michael@0: michael@0: let editTarget = myVar.get("prop").target; michael@0: michael@0: // Allow the target variable to get painted, so that clicking on michael@0: // its value would scroll the new textbox node into view. michael@0: executeSoon(() => { michael@0: let varEdit = editTarget.querySelector(".title > .variables-view-edit"); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, varEdit, gDebugger); michael@0: michael@0: let varInput = editTarget.querySelector(".title > .element-value-input"); michael@0: setText(varInput, aString); michael@0: EventUtils.sendKey("RETURN", gDebugger); michael@0: }); michael@0: michael@0: return finished; michael@0: }); michael@0: michael@0: myVar.expand(); michael@0: gVars.clearHierarchy(); michael@0: michael@0: return finished; michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gL10N = null; michael@0: gEditor = null; michael@0: gVars = null; michael@0: gWatch = null; michael@0: }); michael@0: