|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Make sure that the variables view is able to override getter properties |
|
6 * to plain value properties. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; |
|
10 |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 let gL10N, gEditor, gVars, gWatch; |
|
13 |
|
14 function test() { |
|
15 // Debug test slaves are a bit slow at this test. |
|
16 requestLongerTimeout(2); |
|
17 |
|
18 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
19 gTab = aTab; |
|
20 gDebuggee = aDebuggee; |
|
21 gPanel = aPanel; |
|
22 gDebugger = gPanel.panelWin; |
|
23 gL10N = gDebugger.L10N; |
|
24 gEditor = gDebugger.DebuggerView.editor; |
|
25 gVars = gDebugger.DebuggerView.Variables; |
|
26 gWatch = gDebugger.DebuggerView.WatchExpressions; |
|
27 |
|
28 gVars.switch = function() {}; |
|
29 gVars.delete = function() {}; |
|
30 |
|
31 waitForSourceAndCaretAndScopes(gPanel, ".html", 24) |
|
32 .then(() => addWatchExpression()) |
|
33 .then(() => testEdit("\"xlerb\"", "xlerb")) |
|
34 .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
|
35 .then(null, aError => { |
|
36 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
37 }); |
|
38 |
|
39 EventUtils.sendMouseEvent({ type: "click" }, |
|
40 gDebuggee.document.querySelector("button"), |
|
41 gDebuggee); |
|
42 }); |
|
43 } |
|
44 |
|
45 function addWatchExpression() { |
|
46 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS); |
|
47 |
|
48 gWatch.addExpression("myVar.prop"); |
|
49 gEditor.focus(); |
|
50 |
|
51 return finished; |
|
52 } |
|
53 |
|
54 function testEdit(aString, aExpected) { |
|
55 let localScope = gVars.getScopeAtIndex(1); |
|
56 let myVar = localScope.get("myVar"); |
|
57 |
|
58 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES).then(() => { |
|
59 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS).then(() => { |
|
60 let exprScope = gVars.getScopeAtIndex(0); |
|
61 |
|
62 ok(exprScope, |
|
63 "There should be a wach expressions scope in the variables view."); |
|
64 is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"), |
|
65 "The scope's name should be marked as 'Watch Expressions'."); |
|
66 is(exprScope._store.size, 1, |
|
67 "There should be one evaluation available."); |
|
68 |
|
69 is(exprScope.get("myVar.prop").value, aExpected, |
|
70 "The expression value is correct after the edit."); |
|
71 }); |
|
72 |
|
73 let editTarget = myVar.get("prop").target; |
|
74 |
|
75 // Allow the target variable to get painted, so that clicking on |
|
76 // its value would scroll the new textbox node into view. |
|
77 executeSoon(() => { |
|
78 let varEdit = editTarget.querySelector(".title > .variables-view-edit"); |
|
79 EventUtils.sendMouseEvent({ type: "mousedown" }, varEdit, gDebugger); |
|
80 |
|
81 let varInput = editTarget.querySelector(".title > .element-value-input"); |
|
82 setText(varInput, aString); |
|
83 EventUtils.sendKey("RETURN", gDebugger); |
|
84 }); |
|
85 |
|
86 return finished; |
|
87 }); |
|
88 |
|
89 myVar.expand(); |
|
90 gVars.clearHierarchy(); |
|
91 |
|
92 return finished; |
|
93 } |
|
94 |
|
95 registerCleanupFunction(function() { |
|
96 gTab = null; |
|
97 gDebuggee = null; |
|
98 gPanel = null; |
|
99 gDebugger = null; |
|
100 gL10N = null; |
|
101 gEditor = null; |
|
102 gVars = null; |
|
103 gWatch = null; |
|
104 }); |
|
105 |