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