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 editing variables or properties values works properly. 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 gVars; michael@0: michael@0: function test() { 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: gVars = gDebugger.DebuggerView.Variables; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 24) michael@0: .then(() => initialChecks()) michael@0: .then(() => testModification("a", "1")) michael@0: .then(() => testModification("{ a: 1 }", "Object")) michael@0: .then(() => testModification("[a]", "Array[1]")) michael@0: .then(() => testModification("b", "Object")) michael@0: .then(() => testModification("b.a", "1")) michael@0: .then(() => testModification("c.a", "1")) michael@0: .then(() => testModification("Infinity", "Infinity")) michael@0: .then(() => testModification("NaN", "NaN")) michael@0: .then(() => testModification("new Function", "anonymous()")) michael@0: .then(() => testModification("+0", "0")) michael@0: .then(() => testModification("-0", "-0")) michael@0: .then(() => testModification("Object.keys({})", "Array[0]")) michael@0: .then(() => testModification("document.title", '"Debugger test page"')) 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 initialChecks() { michael@0: let localScope = gVars.getScopeAtIndex(0); michael@0: let aVar = localScope.get("a"); michael@0: michael@0: is(aVar.target.querySelector(".name").getAttribute("value"), "a", michael@0: "Should have the right name for 'a'."); michael@0: is(aVar.target.querySelector(".value").getAttribute("value"), "1", michael@0: "Should have the right initial value for 'a'."); michael@0: } michael@0: michael@0: function testModification(aNewValue, aNewResult) { michael@0: let localScope = gVars.getScopeAtIndex(0); michael@0: let aVar = localScope.get("a"); 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 varValue = aVar.target.querySelector(".title > .value"); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, varValue, gDebugger); michael@0: michael@0: let varInput = aVar.target.querySelector(".title > .element-value-input"); michael@0: setText(varInput, aNewValue); michael@0: EventUtils.sendKey("RETURN", gDebugger); michael@0: }); michael@0: michael@0: return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { michael@0: let localScope = gVars.getScopeAtIndex(0); michael@0: let aVar = localScope.get("a"); michael@0: michael@0: is(aVar.target.querySelector(".name").getAttribute("value"), "a", michael@0: "Should have the right name for 'a'."); michael@0: is(aVar.target.querySelector(".value").getAttribute("value"), aNewResult, michael@0: "Should have the right new value for 'a'."); michael@0: }); 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: gVars = null; michael@0: });