1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-value.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 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 + * Make sure that the editing variables or properties values works properly. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; 1.12 + 1.13 +let gTab, gDebuggee, gPanel, gDebugger; 1.14 +let gVars; 1.15 + 1.16 +function test() { 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + gVars = gDebugger.DebuggerView.Variables; 1.23 + 1.24 + waitForSourceAndCaretAndScopes(gPanel, ".html", 24) 1.25 + .then(() => initialChecks()) 1.26 + .then(() => testModification("a", "1")) 1.27 + .then(() => testModification("{ a: 1 }", "Object")) 1.28 + .then(() => testModification("[a]", "Array[1]")) 1.29 + .then(() => testModification("b", "Object")) 1.30 + .then(() => testModification("b.a", "1")) 1.31 + .then(() => testModification("c.a", "1")) 1.32 + .then(() => testModification("Infinity", "Infinity")) 1.33 + .then(() => testModification("NaN", "NaN")) 1.34 + .then(() => testModification("new Function", "anonymous()")) 1.35 + .then(() => testModification("+0", "0")) 1.36 + .then(() => testModification("-0", "-0")) 1.37 + .then(() => testModification("Object.keys({})", "Array[0]")) 1.38 + .then(() => testModification("document.title", '"Debugger test page"')) 1.39 + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) 1.40 + .then(null, aError => { 1.41 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.42 + }); 1.43 + 1.44 + EventUtils.sendMouseEvent({ type: "click" }, 1.45 + gDebuggee.document.querySelector("button"), 1.46 + gDebuggee); 1.47 + }); 1.48 +} 1.49 + 1.50 +function initialChecks() { 1.51 + let localScope = gVars.getScopeAtIndex(0); 1.52 + let aVar = localScope.get("a"); 1.53 + 1.54 + is(aVar.target.querySelector(".name").getAttribute("value"), "a", 1.55 + "Should have the right name for 'a'."); 1.56 + is(aVar.target.querySelector(".value").getAttribute("value"), "1", 1.57 + "Should have the right initial value for 'a'."); 1.58 +} 1.59 + 1.60 +function testModification(aNewValue, aNewResult) { 1.61 + let localScope = gVars.getScopeAtIndex(0); 1.62 + let aVar = localScope.get("a"); 1.63 + 1.64 + // Allow the target variable to get painted, so that clicking on 1.65 + // its value would scroll the new textbox node into view. 1.66 + executeSoon(() => { 1.67 + let varValue = aVar.target.querySelector(".title > .value"); 1.68 + EventUtils.sendMouseEvent({ type: "mousedown" }, varValue, gDebugger); 1.69 + 1.70 + let varInput = aVar.target.querySelector(".title > .element-value-input"); 1.71 + setText(varInput, aNewValue); 1.72 + EventUtils.sendKey("RETURN", gDebugger); 1.73 + }); 1.74 + 1.75 + return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { 1.76 + let localScope = gVars.getScopeAtIndex(0); 1.77 + let aVar = localScope.get("a"); 1.78 + 1.79 + is(aVar.target.querySelector(".name").getAttribute("value"), "a", 1.80 + "Should have the right name for 'a'."); 1.81 + is(aVar.target.querySelector(".value").getAttribute("value"), aNewResult, 1.82 + "Should have the right new value for 'a'."); 1.83 + }); 1.84 +} 1.85 + 1.86 +registerCleanupFunction(function() { 1.87 + gTab = null; 1.88 + gDebuggee = null; 1.89 + gPanel = null; 1.90 + gDebugger = null; 1.91 + gVars = null; 1.92 +});