browser/devtools/debugger/test/browser_dbg_variables-view-edit-value.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Make sure that the editing variables or properties values works properly.
michael@0 6 */
michael@0 7
michael@0 8 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
michael@0 9
michael@0 10 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 11 let gVars;
michael@0 12
michael@0 13 function test() {
michael@0 14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 15 gTab = aTab;
michael@0 16 gDebuggee = aDebuggee;
michael@0 17 gPanel = aPanel;
michael@0 18 gDebugger = gPanel.panelWin;
michael@0 19 gVars = gDebugger.DebuggerView.Variables;
michael@0 20
michael@0 21 waitForSourceAndCaretAndScopes(gPanel, ".html", 24)
michael@0 22 .then(() => initialChecks())
michael@0 23 .then(() => testModification("a", "1"))
michael@0 24 .then(() => testModification("{ a: 1 }", "Object"))
michael@0 25 .then(() => testModification("[a]", "Array[1]"))
michael@0 26 .then(() => testModification("b", "Object"))
michael@0 27 .then(() => testModification("b.a", "1"))
michael@0 28 .then(() => testModification("c.a", "1"))
michael@0 29 .then(() => testModification("Infinity", "Infinity"))
michael@0 30 .then(() => testModification("NaN", "NaN"))
michael@0 31 .then(() => testModification("new Function", "anonymous()"))
michael@0 32 .then(() => testModification("+0", "0"))
michael@0 33 .then(() => testModification("-0", "-0"))
michael@0 34 .then(() => testModification("Object.keys({})", "Array[0]"))
michael@0 35 .then(() => testModification("document.title", '"Debugger test page"'))
michael@0 36 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
michael@0 37 .then(null, aError => {
michael@0 38 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 39 });
michael@0 40
michael@0 41 EventUtils.sendMouseEvent({ type: "click" },
michael@0 42 gDebuggee.document.querySelector("button"),
michael@0 43 gDebuggee);
michael@0 44 });
michael@0 45 }
michael@0 46
michael@0 47 function initialChecks() {
michael@0 48 let localScope = gVars.getScopeAtIndex(0);
michael@0 49 let aVar = localScope.get("a");
michael@0 50
michael@0 51 is(aVar.target.querySelector(".name").getAttribute("value"), "a",
michael@0 52 "Should have the right name for 'a'.");
michael@0 53 is(aVar.target.querySelector(".value").getAttribute("value"), "1",
michael@0 54 "Should have the right initial value for 'a'.");
michael@0 55 }
michael@0 56
michael@0 57 function testModification(aNewValue, aNewResult) {
michael@0 58 let localScope = gVars.getScopeAtIndex(0);
michael@0 59 let aVar = localScope.get("a");
michael@0 60
michael@0 61 // Allow the target variable to get painted, so that clicking on
michael@0 62 // its value would scroll the new textbox node into view.
michael@0 63 executeSoon(() => {
michael@0 64 let varValue = aVar.target.querySelector(".title > .value");
michael@0 65 EventUtils.sendMouseEvent({ type: "mousedown" }, varValue, gDebugger);
michael@0 66
michael@0 67 let varInput = aVar.target.querySelector(".title > .element-value-input");
michael@0 68 setText(varInput, aNewValue);
michael@0 69 EventUtils.sendKey("RETURN", gDebugger);
michael@0 70 });
michael@0 71
michael@0 72 return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
michael@0 73 let localScope = gVars.getScopeAtIndex(0);
michael@0 74 let aVar = localScope.get("a");
michael@0 75
michael@0 76 is(aVar.target.querySelector(".name").getAttribute("value"), "a",
michael@0 77 "Should have the right name for 'a'.");
michael@0 78 is(aVar.target.querySelector(".value").getAttribute("value"), aNewResult,
michael@0 79 "Should have the right new value for 'a'.");
michael@0 80 });
michael@0 81 }
michael@0 82
michael@0 83 registerCleanupFunction(function() {
michael@0 84 gTab = null;
michael@0 85 gDebuggee = null;
michael@0 86 gPanel = null;
michael@0 87 gDebugger = null;
michael@0 88 gVars = null;
michael@0 89 });

mercurial