summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-edit-watch.js
blob: fe9d190b278f27c40ac4692d6f0fa217b40afcb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Make sure that the editing or removing watch expressions works properly.
 */

const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html";

var gTab, gPanel, gDebugger;
var gL10N, gEditor, gVars, gWatch;

function test() {
  let options = {
    source: TAB_URL,
    line: 1
  };
  initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
    gTab = aTab;
    gPanel = aPanel;
    gDebugger = gPanel.panelWin;
    gL10N = gDebugger.L10N;
    gEditor = gDebugger.DebuggerView.editor;
    gVars = gDebugger.DebuggerView.Variables;
    gWatch = gDebugger.DebuggerView.WatchExpressions;

    promise.all([
      waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS),
      waitForCaretAndScopes(gPanel, 18)])
      .then(() => testInitialVariablesInScope())
      .then(() => testInitialExpressionsInScope())
      .then(() => testModification("document.title = 42", "document.title = 43", "43", "undefined"))
      .then(() => testIntegrity1())
      .then(() => testModification("aArg", "aArg = 44", "44", "44"))
      .then(() => testIntegrity2())
      .then(() => testModification("aArg = 44", "\ \t\r\ndocument.title\ \t\r\n", "\"43\"", "44"))
      .then(() => testIntegrity3())
      .then(() => testModification("document.title = 43", "\ \t\r\ndocument.title\ \t\r\n", "\"43\"", "44"))
      .then(() => testIntegrity4())
      .then(() => testModification("document.title", "\ \t\r\n", "\"43\"", "44"))
      .then(() => testIntegrity5())
      .then(() => testExprDeletion("this", "44"))
      .then(() => testIntegrity6())
      .then(() => testExprFinalDeletion("ermahgerd", "44"))
      .then(() => testIntegrity7())
      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
      .then(null, aError => {
        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
      });

    addExpressions();
    callInTab(gTab, "ermahgerd");
  });
}

function addExpressions() {
  addExpression("this");
  addExpression("ermahgerd");
  addExpression("aArg");
  addExpression("document.title");
  addCmdExpression("document.title = 42");

  is(gWatch.itemCount, 5,
    "There should be 5 items availalble in the watch expressions view.");

  is(gWatch.getItemAtIndex(4).attachment.initialExpression, "this",
    "The first expression's initial value should be correct.");
  is(gWatch.getItemAtIndex(3).attachment.initialExpression, "ermahgerd",
    "The second expression's initial value should be correct.");
  is(gWatch.getItemAtIndex(2).attachment.initialExpression, "aArg",
    "The third expression's initial value should be correct.");
  is(gWatch.getItemAtIndex(1).attachment.initialExpression, "document.title",
    "The fourth expression's initial value should be correct.");
  is(gWatch.getItemAtIndex(0).attachment.initialExpression, "document.title = 42",
    "The fifth expression's initial value should be correct.");

  is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
    "The first expression's current value should be correct.");
  is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
    "The second expression's current value should be correct.");
  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg",
    "The third expression's current value should be correct.");
  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
    "The fourth expression's current value should be correct.");
  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 42",
    "The fifth expression's current value should be correct.");
}

function testInitialVariablesInScope() {
  let localScope = gVars.getScopeAtIndex(1);
  let argVar = localScope.get("aArg");

  is(argVar.visible, true,
    "Should have the right visibility state for 'aArg'.");
  is(argVar.name, "aArg",
    "Should have the right name for 'aArg'.");
  is(argVar.value.type, "undefined",
    "Should have the right initial value for 'aArg'.");
}

function testInitialExpressionsInScope() {
  let exprScope = gVars.getScopeAtIndex(0);
  let thisExpr = exprScope.get("this");
  let ermExpr = exprScope.get("ermahgerd");
  let argExpr = exprScope.get("aArg");
  let docExpr = exprScope.get("document.title");
  let docExpr2 = exprScope.get("document.title = 42");

  ok(exprScope,
    "There should be a wach expressions scope in the variables view.");
  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    "The scope's name should be marked as 'Watch Expressions'.");
  is(exprScope._store.size, 5,
    "There should be 5 evaluations available.");

  is(thisExpr.visible, true,
    "Should have the right visibility state for 'this'.");
  is(thisExpr.target.querySelectorAll(".variables-view-delete").length, 1,
    "Should have the one close button visible for 'this'.");
  is(thisExpr.name, "this",
    "Should have the right name for 'this'.");
  is(thisExpr.value.type, "object",
    "Should have the right value type for 'this'.");
  is(thisExpr.value.class, "Window",
    "Should have the right value type for 'this'.");

  is(ermExpr.visible, true,
    "Should have the right visibility state for 'ermahgerd'.");
  is(ermExpr.target.querySelectorAll(".variables-view-delete").length, 1,
    "Should have the one close button visible for 'ermahgerd'.");
  is(ermExpr.name, "ermahgerd",
    "Should have the right name for 'ermahgerd'.");
  is(ermExpr.value.type, "object",
    "Should have the right value type for 'ermahgerd'.");
  is(ermExpr.value.class, "Function",
    "Should have the right value type for 'ermahgerd'.");

  is(argExpr.visible, true,
    "Should have the right visibility state for 'aArg'.");
  is(argExpr.target.querySelectorAll(".variables-view-delete").length, 1,
    "Should have the one close button visible for 'aArg'.");
  is(argExpr.name, "aArg",
    "Should have the right name for 'aArg'.");
  is(argExpr.value.type, "undefined",
    "Should have the right value for 'aArg'.");

  is(docExpr.visible, true,
    "Should have the right visibility state for 'document.title'.");
  is(docExpr.target.querySelectorAll(".variables-view-delete").length, 1,
    "Should have the one close button visible for 'document.title'.");
  is(docExpr.name, "document.title",
    "Should have the right name for 'document.title'.");
  is(docExpr.value, "42",
    "Should have the right value for 'document.title'.");

  is(docExpr2.visible, true,
    "Should have the right visibility state for 'document.title = 42'.");
  is(docExpr2.target.querySelectorAll(".variables-view-delete").length, 1,
    "Should have the one close button visible for 'document.title = 42'.");
  is(docExpr2.name, "document.title = 42",
    "Should have the right name for 'document.title = 42'.");
  is(docExpr2.value, 42,
    "Should have the right value for 'document.title = 42'.");

  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
    "There should be 5 hidden nodes in the watch expressions container.");
  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
    "There should be 0 visible nodes in the watch expressions container.");
}

function testModification(aName, aNewValue, aNewResult, aArgResult) {
  let exprScope = gVars.getScopeAtIndex(0);
  let exprVar = exprScope.get(aName);

  let finished = promise.all([
    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS)
  ])
  .then(() => {
    let localScope = gVars.getScopeAtIndex(1);
    let argVar = localScope.get("aArg");

    is(argVar.visible, true,
      "Should have the right visibility state for 'aArg'.");
    is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
      "Should have the right name for 'aArg'.");
    is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
      "Should have the right new value for 'aArg'.");

    let exprScope = gVars.getScopeAtIndex(0);
    let exprOldVar = exprScope.get(aName);
    let exprNewVar = exprScope.get(aNewValue.trim());

    if (!aNewValue.trim()) {
      ok(!exprOldVar,
        "The old watch expression should have been removed.");
      ok(!exprNewVar,
        "No new watch expression should have been added.");
    } else {
      ok(!exprOldVar,
        "The old watch expression should have been removed.");
      ok(exprNewVar,
        "The new watch expression should have been added.");

      is(exprNewVar.visible, true,
        "Should have the right visibility state for the watch expression.");
      is(exprNewVar.target.querySelector(".name").getAttribute("value"), aNewValue.trim(),
        "Should have the right name for the watch expression.");
      is(exprNewVar.target.querySelector(".value").getAttribute("value"), aNewResult,
        "Should have the right new value for the watch expression.");
    }
  });

  let varValue = exprVar.target.querySelector(".title > .name");
  EventUtils.sendMouseEvent({ type: "dblclick" }, varValue, gDebugger);

  let varInput = exprVar.target.querySelector(".title > .element-name-input");
  setText(varInput, aNewValue);
  EventUtils.sendKey("RETURN", gDebugger);

  return finished;
}

function testExprDeletion(aName, aArgResult) {
  let exprScope = gVars.getScopeAtIndex(0);
  let exprVar = exprScope.get(aName);

  let finished = promise.all([
    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS)
  ])
  .then(() => {
    let localScope = gVars.getScopeAtIndex(1);
    let argVar = localScope.get("aArg");

    is(argVar.visible, true,
      "Should have the right visibility state for 'aArg'.");
    is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
      "Should have the right name for 'aArg'.");
    is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
      "Should have the right new value for 'aArg'.");

    let exprScope = gVars.getScopeAtIndex(0);
    let exprOldVar = exprScope.get(aName);

    ok(!exprOldVar,
      "The watch expression should have been deleted.");
  });

  let varDelete = exprVar.target.querySelector(".variables-view-delete");
  EventUtils.sendMouseEvent({ type: "click" }, varDelete, gDebugger);

  return finished;
}

function testExprFinalDeletion(aName, aArgResult) {
  let exprScope = gVars.getScopeAtIndex(0);
  let exprVar = exprScope.get(aName);

  let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
    let localScope = gVars.getScopeAtIndex(0);
    let argVar = localScope.get("aArg");

    is(argVar.visible, true,
      "Should have the right visibility state for 'aArg'.");
    is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
      "Should have the right name for 'aArg'.");
    is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
      "Should have the right new value for 'aArg'.");

    let exprScope = gVars.getScopeAtIndex(0);
    let exprOldVar = exprScope.get(aName);

    ok(!exprOldVar,
      "The watch expression should have been deleted.");
  });

  let varDelete = exprVar.target.querySelector(".variables-view-delete");
  EventUtils.sendMouseEvent({ type: "click" }, varDelete, gDebugger);

  return finished;
}

function testIntegrity1() {
  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
    "There should be 5 hidden nodes in the watch expressions container.");
  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
    "There should be 0 visible nodes in the watch expressions container.");

  let exprScope = gVars.getScopeAtIndex(0);
  ok(exprScope,
    "There should be a wach expressions scope in the variables view.");
  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    "The scope's name should be marked as 'Watch Expressions'.");
  is(exprScope._store.size, 5,
    "There should be 5 visible evaluations available.");

  is(gWatch.itemCount, 5,
    "There should be 5 hidden expression input available.");
  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "aArg",
    "The third textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg",
    "The third textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "ermahgerd",
    "The fourth textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
    "The fourth textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(4).attachment.view.inputNode.value, "this",
    "The fifth textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
    "The fifth textbox input value is not the correct one.");
}

function testIntegrity2() {
  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
    "There should be 5 hidden nodes in the watch expressions container.");
  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
    "There should be 0 visible nodes in the watch expressions container.");

  let exprScope = gVars.getScopeAtIndex(0);
  ok(exprScope,
    "There should be a wach expressions scope in the variables view.");
  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    "The scope's name should be marked as 'Watch Expressions'.");
  is(exprScope._store.size, 5,
    "There should be 5 visible evaluations available.");

  is(gWatch.itemCount, 5,
    "There should be 5 hidden expression input available.");
  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "aArg = 44",
    "The third textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg = 44",
    "The third textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "ermahgerd",
    "The fourth textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
    "The fourth textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(4).attachment.view.inputNode.value, "this",
    "The fifth textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
    "The fifth textbox input value is not the correct one.");
}

function testIntegrity3() {
  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 4,
    "There should be 4 hidden nodes in the watch expressions container.");
  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
    "There should be 0 visible nodes in the watch expressions container.");

  let exprScope = gVars.getScopeAtIndex(0);
  ok(exprScope,
    "There should be a wach expressions scope in the variables view.");
  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    "The scope's name should be marked as 'Watch Expressions'.");
  is(exprScope._store.size, 4,
    "There should be 4 visible evaluations available.");

  is(gWatch.itemCount, 4,
    "There should be 4 hidden expression input available.");
  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "ermahgerd",
    "The third textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "ermahgerd",
    "The third textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "this",
    "The fourth textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(3).attachment.currentExpression, "this",
    "The fourth textbox input value is not the correct one.");
}

function testIntegrity4() {
  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 3,
    "There should be 3 hidden nodes in the watch expressions container.");
  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
    "There should be 0 visible nodes in the watch expressions container.");

  let exprScope = gVars.getScopeAtIndex(0);
  ok(exprScope,
    "There should be a wach expressions scope in the variables view.");
  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    "The scope's name should be marked as 'Watch Expressions'.");
  is(exprScope._store.size, 3,
    "There should be 3 visible evaluations available.");

  is(gWatch.itemCount, 3,
    "There should be 3 hidden expression input available.");
  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "ermahgerd",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "ermahgerd",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "this",
    "The third textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "this",
    "The third textbox input value is not the correct one.");
}

function testIntegrity5() {
  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 2,
    "There should be 2 hidden nodes in the watch expressions container.");
  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
    "There should be 0 visible nodes in the watch expressions container.");

  let exprScope = gVars.getScopeAtIndex(0);
  ok(exprScope,
    "There should be a wach expressions scope in the variables view.");
  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    "The scope's name should be marked as 'Watch Expressions'.");
  is(exprScope._store.size, 2,
    "There should be 2 visible evaluations available.");

  is(gWatch.itemCount, 2,
    "There should be 2 hidden expression input available.");
  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "ermahgerd",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "ermahgerd",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "this",
    "The second textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "this",
    "The second textbox input value is not the correct one.");
}

function testIntegrity6() {
  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 1,
    "There should be 1 hidden nodes in the watch expressions container.");
  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
    "There should be 0 visible nodes in the watch expressions container.");

  let exprScope = gVars.getScopeAtIndex(0);
  ok(exprScope,
    "There should be a wach expressions scope in the variables view.");
  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    "The scope's name should be marked as 'Watch Expressions'.");
  is(exprScope._store.size, 1,
    "There should be 1 visible evaluation available.");

  is(gWatch.itemCount, 1,
    "There should be 1 hidden expression input available.");
  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "ermahgerd",
    "The first textbox input value is not the correct one.");
  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "ermahgerd",
    "The first textbox input value is not the correct one.");
}

function testIntegrity7() {
  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 0,
    "There should be 0 hidden nodes in the watch expressions container.");
  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
    "There should be 0 visible nodes in the watch expressions container.");

  let localScope = gVars.getScopeAtIndex(0);
  ok(localScope,
    "There should be a local scope in the variables view.");
  isnot(localScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    "The scope's name should not be marked as 'Watch Expressions'.");
  isnot(localScope._store.size, 0,
    "There should be some variables available.");

  is(gWatch.itemCount, 0,
    "The watch expressions container should be empty.");
}

function addExpression(aString) {
  gWatch.addExpression(aString);
  gEditor.focus();
}

function addCmdExpression(aString) {
  gWatch._onCmdAddExpression(aString);
  gEditor.focus();
}

registerCleanupFunction(function () {
  gTab = null;
  gPanel = null;
  gDebugger = null;
  gL10N = null;
  gEditor = null;
  gVars = null;
  gWatch = null;
});