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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-edit-watch.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,504 @@
     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 or removing watch expressions works properly.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html";
    1.12 +
    1.13 +let gTab, gDebuggee, gPanel, gDebugger;
    1.14 +let gL10N, gEditor, gVars, gWatch;
    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 +    gL10N = gDebugger.L10N;
    1.23 +    gEditor = gDebugger.DebuggerView.editor;
    1.24 +    gVars = gDebugger.DebuggerView.Variables;
    1.25 +    gWatch = gDebugger.DebuggerView.WatchExpressions;
    1.26 +
    1.27 +    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS)
    1.28 +      .then(() => testInitialVariablesInScope())
    1.29 +      .then(() => testInitialExpressionsInScope())
    1.30 +      .then(() => testModification("document.title = 42", "document.title = 43", "43", "undefined"))
    1.31 +      .then(() => testIntegrity1())
    1.32 +      .then(() => testModification("aArg", "aArg = 44", "44", "44"))
    1.33 +      .then(() => testIntegrity2())
    1.34 +      .then(() => testModification("aArg = 44", "\ \t\r\ndocument.title\ \t\r\n", "\"43\"", "44"))
    1.35 +      .then(() => testIntegrity3())
    1.36 +      .then(() => testModification("document.title = 43", "\ \t\r\ndocument.title\ \t\r\n", "\"43\"", "44"))
    1.37 +      .then(() => testIntegrity4())
    1.38 +      .then(() => testModification("document.title", "\ \t\r\n", "\"43\"", "44"))
    1.39 +      .then(() => testIntegrity5())
    1.40 +      .then(() => testExprDeletion("this", "44"))
    1.41 +      .then(() => testIntegrity6())
    1.42 +      .then(() => testExprFinalDeletion("ermahgerd", "44"))
    1.43 +      .then(() => testIntegrity7())
    1.44 +      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    1.45 +      .then(null, aError => {
    1.46 +        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.47 +      });
    1.48 +
    1.49 +    addExpressions();
    1.50 +    gDebuggee.ermahgerd();
    1.51 +  });
    1.52 +}
    1.53 +
    1.54 +function addExpressions() {
    1.55 +  addExpression("this");
    1.56 +  addExpression("ermahgerd");
    1.57 +  addExpression("aArg");
    1.58 +  addExpression("document.title");
    1.59 +  addCmdExpression("document.title = 42");
    1.60 +
    1.61 +  is(gWatch.itemCount, 5,
    1.62 +    "There should be 5 items availalble in the watch expressions view.");
    1.63 +
    1.64 +  is(gWatch.getItemAtIndex(4).attachment.initialExpression, "this",
    1.65 +    "The first expression's initial value should be correct.");
    1.66 +  is(gWatch.getItemAtIndex(3).attachment.initialExpression, "ermahgerd",
    1.67 +    "The second expression's initial value should be correct.");
    1.68 +  is(gWatch.getItemAtIndex(2).attachment.initialExpression, "aArg",
    1.69 +    "The third expression's initial value should be correct.");
    1.70 +  is(gWatch.getItemAtIndex(1).attachment.initialExpression, "document.title",
    1.71 +    "The fourth expression's initial value should be correct.");
    1.72 +  is(gWatch.getItemAtIndex(0).attachment.initialExpression, "document.title = 42",
    1.73 +    "The fifth expression's initial value should be correct.");
    1.74 +
    1.75 +  is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
    1.76 +    "The first expression's current value should be correct.");
    1.77 +  is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
    1.78 +    "The second expression's current value should be correct.");
    1.79 +  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg",
    1.80 +    "The third expression's current value should be correct.");
    1.81 +  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
    1.82 +    "The fourth expression's current value should be correct.");
    1.83 +  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 42",
    1.84 +    "The fifth expression's current value should be correct.");
    1.85 +}
    1.86 +
    1.87 +function testInitialVariablesInScope() {
    1.88 +  let localScope = gVars.getScopeAtIndex(1);
    1.89 +  let argVar = localScope.get("aArg");
    1.90 +
    1.91 +  is(argVar.visible, true,
    1.92 +    "Should have the right visibility state for 'aArg'.");
    1.93 +  is(argVar.name, "aArg",
    1.94 +    "Should have the right name for 'aArg'.");
    1.95 +  is(argVar.value.type, "undefined",
    1.96 +    "Should have the right initial value for 'aArg'.");
    1.97 +}
    1.98 +
    1.99 +function testInitialExpressionsInScope() {
   1.100 +  let exprScope = gVars.getScopeAtIndex(0);
   1.101 +  let thisExpr = exprScope.get("this");
   1.102 +  let ermExpr = exprScope.get("ermahgerd");
   1.103 +  let argExpr = exprScope.get("aArg");
   1.104 +  let docExpr = exprScope.get("document.title");
   1.105 +  let docExpr2 = exprScope.get("document.title = 42");
   1.106 +
   1.107 +  ok(exprScope,
   1.108 +    "There should be a wach expressions scope in the variables view.");
   1.109 +  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
   1.110 +    "The scope's name should be marked as 'Watch Expressions'.");
   1.111 +  is(exprScope._store.size, 5,
   1.112 +    "There should be 5 evaluations available.");
   1.113 +
   1.114 +  is(thisExpr.visible, true,
   1.115 +    "Should have the right visibility state for 'this'.");
   1.116 +  is(thisExpr.target.querySelectorAll(".variables-view-delete").length, 1,
   1.117 +    "Should have the one close button visible for 'this'.");
   1.118 +  is(thisExpr.name, "this",
   1.119 +    "Should have the right name for 'this'.");
   1.120 +  is(thisExpr.value.type, "object",
   1.121 +    "Should have the right value type for 'this'.");
   1.122 +  is(thisExpr.value.class, "Window",
   1.123 +    "Should have the right value type for 'this'.");
   1.124 +
   1.125 +  is(ermExpr.visible, true,
   1.126 +    "Should have the right visibility state for 'ermahgerd'.");
   1.127 +  is(ermExpr.target.querySelectorAll(".variables-view-delete").length, 1,
   1.128 +    "Should have the one close button visible for 'ermahgerd'.");
   1.129 +  is(ermExpr.name, "ermahgerd",
   1.130 +    "Should have the right name for 'ermahgerd'.");
   1.131 +  is(ermExpr.value.type, "object",
   1.132 +    "Should have the right value type for 'ermahgerd'.");
   1.133 +  is(ermExpr.value.class, "Function",
   1.134 +    "Should have the right value type for 'ermahgerd'.");
   1.135 +
   1.136 +  is(argExpr.visible, true,
   1.137 +    "Should have the right visibility state for 'aArg'.");
   1.138 +  is(argExpr.target.querySelectorAll(".variables-view-delete").length, 1,
   1.139 +    "Should have the one close button visible for 'aArg'.");
   1.140 +  is(argExpr.name, "aArg",
   1.141 +    "Should have the right name for 'aArg'.");
   1.142 +  is(argExpr.value.type, "undefined",
   1.143 +    "Should have the right value for 'aArg'.");
   1.144 +
   1.145 +  is(docExpr.visible, true,
   1.146 +    "Should have the right visibility state for 'document.title'.");
   1.147 +  is(docExpr.target.querySelectorAll(".variables-view-delete").length, 1,
   1.148 +    "Should have the one close button visible for 'document.title'.");
   1.149 +  is(docExpr.name, "document.title",
   1.150 +    "Should have the right name for 'document.title'.");
   1.151 +  is(docExpr.value, "42",
   1.152 +    "Should have the right value for 'document.title'.");
   1.153 +
   1.154 +  is(docExpr2.visible, true,
   1.155 +    "Should have the right visibility state for 'document.title = 42'.");
   1.156 +  is(docExpr2.target.querySelectorAll(".variables-view-delete").length, 1,
   1.157 +    "Should have the one close button visible for 'document.title = 42'.");
   1.158 +  is(docExpr2.name, "document.title = 42",
   1.159 +    "Should have the right name for 'document.title = 42'.");
   1.160 +  is(docExpr2.value, 42,
   1.161 +    "Should have the right value for 'document.title = 42'.");
   1.162 +
   1.163 +  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
   1.164 +    "There should be 5 hidden nodes in the watch expressions container.");
   1.165 +  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
   1.166 +    "There should be 0 visible nodes in the watch expressions container.");
   1.167 +}
   1.168 +
   1.169 +function testModification(aName, aNewValue, aNewResult, aArgResult) {
   1.170 +  let exprScope = gVars.getScopeAtIndex(0);
   1.171 +  let exprVar = exprScope.get(aName);
   1.172 +
   1.173 +  let finished = promise.all([
   1.174 +    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
   1.175 +    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS)
   1.176 +  ])
   1.177 +  .then(() => {
   1.178 +    let localScope = gVars.getScopeAtIndex(1);
   1.179 +    let argVar = localScope.get("aArg");
   1.180 +
   1.181 +    is(argVar.visible, true,
   1.182 +      "Should have the right visibility state for 'aArg'.");
   1.183 +    is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
   1.184 +      "Should have the right name for 'aArg'.");
   1.185 +    is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
   1.186 +      "Should have the right new value for 'aArg'.");
   1.187 +
   1.188 +    let exprScope = gVars.getScopeAtIndex(0);
   1.189 +    let exprOldVar = exprScope.get(aName);
   1.190 +    let exprNewVar = exprScope.get(aNewValue.trim());
   1.191 +
   1.192 +    if (!aNewValue.trim()) {
   1.193 +      ok(!exprOldVar,
   1.194 +        "The old watch expression should have been removed.");
   1.195 +      ok(!exprNewVar,
   1.196 +        "No new watch expression should have been added.");
   1.197 +    } else {
   1.198 +      ok(!exprOldVar,
   1.199 +        "The old watch expression should have been removed.");
   1.200 +      ok(exprNewVar,
   1.201 +        "The new watch expression should have been added.");
   1.202 +
   1.203 +      is(exprNewVar.visible, true,
   1.204 +        "Should have the right visibility state for the watch expression.");
   1.205 +      is(exprNewVar.target.querySelector(".name").getAttribute("value"), aNewValue.trim(),
   1.206 +        "Should have the right name for the watch expression.");
   1.207 +      is(exprNewVar.target.querySelector(".value").getAttribute("value"), aNewResult,
   1.208 +        "Should have the right new value for the watch expression.");
   1.209 +    }
   1.210 +  });
   1.211 +
   1.212 +  let varValue = exprVar.target.querySelector(".title > .name");
   1.213 +  EventUtils.sendMouseEvent({ type: "dblclick" }, varValue, gDebugger);
   1.214 +
   1.215 +  let varInput = exprVar.target.querySelector(".title > .element-name-input");
   1.216 +  setText(varInput, aNewValue);
   1.217 +  EventUtils.sendKey("RETURN", gDebugger);
   1.218 +
   1.219 +  return finished;
   1.220 +}
   1.221 +
   1.222 +function testExprDeletion(aName, aArgResult) {
   1.223 +  let exprScope = gVars.getScopeAtIndex(0);
   1.224 +  let exprVar = exprScope.get(aName);
   1.225 +
   1.226 +  let finished = promise.all([
   1.227 +    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
   1.228 +    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS)
   1.229 +  ])
   1.230 +  .then(() => {
   1.231 +    let localScope = gVars.getScopeAtIndex(1);
   1.232 +    let argVar = localScope.get("aArg");
   1.233 +
   1.234 +    is(argVar.visible, true,
   1.235 +      "Should have the right visibility state for 'aArg'.");
   1.236 +    is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
   1.237 +      "Should have the right name for 'aArg'.");
   1.238 +    is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
   1.239 +      "Should have the right new value for 'aArg'.");
   1.240 +
   1.241 +    let exprScope = gVars.getScopeAtIndex(0);
   1.242 +    let exprOldVar = exprScope.get(aName);
   1.243 +
   1.244 +    ok(!exprOldVar,
   1.245 +      "The watch expression should have been deleted.");
   1.246 +  });
   1.247 +
   1.248 +  let varDelete = exprVar.target.querySelector(".variables-view-delete");
   1.249 +  EventUtils.sendMouseEvent({ type: "click" }, varDelete, gDebugger);
   1.250 +
   1.251 +  return finished;
   1.252 +}
   1.253 +
   1.254 +function testExprFinalDeletion(aName, aArgResult) {
   1.255 +  let exprScope = gVars.getScopeAtIndex(0);
   1.256 +  let exprVar = exprScope.get(aName);
   1.257 +
   1.258 +  let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
   1.259 +    let localScope = gVars.getScopeAtIndex(0);
   1.260 +    let argVar = localScope.get("aArg");
   1.261 +
   1.262 +    is(argVar.visible, true,
   1.263 +      "Should have the right visibility state for 'aArg'.");
   1.264 +    is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
   1.265 +      "Should have the right name for 'aArg'.");
   1.266 +    is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
   1.267 +      "Should have the right new value for 'aArg'.");
   1.268 +
   1.269 +    let exprScope = gVars.getScopeAtIndex(0);
   1.270 +    let exprOldVar = exprScope.get(aName);
   1.271 +
   1.272 +    ok(!exprOldVar,
   1.273 +      "The watch expression should have been deleted.");
   1.274 +  });
   1.275 +
   1.276 +  let varDelete = exprVar.target.querySelector(".variables-view-delete");
   1.277 +  EventUtils.sendMouseEvent({ type: "click" }, varDelete, gDebugger);
   1.278 +
   1.279 +  return finished;
   1.280 +}
   1.281 +
   1.282 +function testIntegrity1() {
   1.283 +  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
   1.284 +    "There should be 5 hidden nodes in the watch expressions container.");
   1.285 +  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
   1.286 +    "There should be 0 visible nodes in the watch expressions container.");
   1.287 +
   1.288 +  let exprScope = gVars.getScopeAtIndex(0);
   1.289 +  ok(exprScope,
   1.290 +    "There should be a wach expressions scope in the variables view.");
   1.291 +  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
   1.292 +    "The scope's name should be marked as 'Watch Expressions'.");
   1.293 +  is(exprScope._store.size, 5,
   1.294 +    "There should be 5 visible evaluations available.");
   1.295 +
   1.296 +  is(gWatch.itemCount, 5,
   1.297 +    "There should be 5 hidden expression input available.");
   1.298 +  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
   1.299 +    "The first textbox input value is not the correct one.");
   1.300 +  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
   1.301 +    "The first textbox input value is not the correct one.");
   1.302 +  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
   1.303 +    "The second textbox input value is not the correct one.");
   1.304 +  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
   1.305 +    "The second textbox input value is not the correct one.");
   1.306 +  is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "aArg",
   1.307 +    "The third textbox input value is not the correct one.");
   1.308 +  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg",
   1.309 +    "The third textbox input value is not the correct one.");
   1.310 +  is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "ermahgerd",
   1.311 +    "The fourth textbox input value is not the correct one.");
   1.312 +  is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
   1.313 +    "The fourth textbox input value is not the correct one.");
   1.314 +  is(gWatch.getItemAtIndex(4).attachment.view.inputNode.value, "this",
   1.315 +    "The fifth textbox input value is not the correct one.");
   1.316 +  is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
   1.317 +    "The fifth textbox input value is not the correct one.");
   1.318 +}
   1.319 +
   1.320 +function testIntegrity2() {
   1.321 +  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
   1.322 +    "There should be 5 hidden nodes in the watch expressions container.");
   1.323 +  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
   1.324 +    "There should be 0 visible nodes in the watch expressions container.");
   1.325 +
   1.326 +  let exprScope = gVars.getScopeAtIndex(0);
   1.327 +  ok(exprScope,
   1.328 +    "There should be a wach expressions scope in the variables view.");
   1.329 +  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
   1.330 +    "The scope's name should be marked as 'Watch Expressions'.");
   1.331 +  is(exprScope._store.size, 5,
   1.332 +    "There should be 5 visible evaluations available.");
   1.333 +
   1.334 +  is(gWatch.itemCount, 5,
   1.335 +    "There should be 5 hidden expression input available.");
   1.336 +  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
   1.337 +    "The first textbox input value is not the correct one.");
   1.338 +  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
   1.339 +    "The first textbox input value is not the correct one.");
   1.340 +  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
   1.341 +    "The second textbox input value is not the correct one.");
   1.342 +  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
   1.343 +    "The second textbox input value is not the correct one.");
   1.344 +  is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "aArg = 44",
   1.345 +    "The third textbox input value is not the correct one.");
   1.346 +  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg = 44",
   1.347 +    "The third textbox input value is not the correct one.");
   1.348 +  is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "ermahgerd",
   1.349 +    "The fourth textbox input value is not the correct one.");
   1.350 +  is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
   1.351 +    "The fourth textbox input value is not the correct one.");
   1.352 +  is(gWatch.getItemAtIndex(4).attachment.view.inputNode.value, "this",
   1.353 +    "The fifth textbox input value is not the correct one.");
   1.354 +  is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
   1.355 +    "The fifth textbox input value is not the correct one.");
   1.356 +}
   1.357 +
   1.358 +function testIntegrity3() {
   1.359 +  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 4,
   1.360 +    "There should be 4 hidden nodes in the watch expressions container.");
   1.361 +  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
   1.362 +    "There should be 0 visible nodes in the watch expressions container.");
   1.363 +
   1.364 +  let exprScope = gVars.getScopeAtIndex(0);
   1.365 +  ok(exprScope,
   1.366 +    "There should be a wach expressions scope in the variables view.");
   1.367 +  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
   1.368 +    "The scope's name should be marked as 'Watch Expressions'.");
   1.369 +  is(exprScope._store.size, 4,
   1.370 +    "There should be 4 visible evaluations available.");
   1.371 +
   1.372 +  is(gWatch.itemCount, 4,
   1.373 +    "There should be 4 hidden expression input available.");
   1.374 +  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
   1.375 +    "The first textbox input value is not the correct one.");
   1.376 +  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
   1.377 +    "The first textbox input value is not the correct one.");
   1.378 +  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
   1.379 +    "The second textbox input value is not the correct one.");
   1.380 +  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
   1.381 +    "The second textbox input value is not the correct one.");
   1.382 +  is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "ermahgerd",
   1.383 +    "The third textbox input value is not the correct one.");
   1.384 +  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "ermahgerd",
   1.385 +    "The third textbox input value is not the correct one.");
   1.386 +  is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "this",
   1.387 +    "The fourth textbox input value is not the correct one.");
   1.388 +  is(gWatch.getItemAtIndex(3).attachment.currentExpression, "this",
   1.389 +    "The fourth textbox input value is not the correct one.");
   1.390 +}
   1.391 +
   1.392 +function testIntegrity4() {
   1.393 +  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 3,
   1.394 +    "There should be 3 hidden nodes in the watch expressions container.");
   1.395 +  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
   1.396 +    "There should be 0 visible nodes in the watch expressions container.");
   1.397 +
   1.398 +  let exprScope = gVars.getScopeAtIndex(0);
   1.399 +  ok(exprScope,
   1.400 +    "There should be a wach expressions scope in the variables view.");
   1.401 +  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
   1.402 +    "The scope's name should be marked as 'Watch Expressions'.");
   1.403 +  is(exprScope._store.size, 3,
   1.404 +    "There should be 3 visible evaluations available.");
   1.405 +
   1.406 +  is(gWatch.itemCount, 3,
   1.407 +    "There should be 3 hidden expression input available.");
   1.408 +  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title",
   1.409 +    "The first textbox input value is not the correct one.");
   1.410 +  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title",
   1.411 +    "The first textbox input value is not the correct one.");
   1.412 +  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "ermahgerd",
   1.413 +    "The second textbox input value is not the correct one.");
   1.414 +  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "ermahgerd",
   1.415 +    "The second textbox input value is not the correct one.");
   1.416 +  is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "this",
   1.417 +    "The third textbox input value is not the correct one.");
   1.418 +  is(gWatch.getItemAtIndex(2).attachment.currentExpression, "this",
   1.419 +    "The third textbox input value is not the correct one.");
   1.420 +}
   1.421 +
   1.422 +function testIntegrity5() {
   1.423 +  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 2,
   1.424 +    "There should be 2 hidden nodes in the watch expressions container.");
   1.425 +  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
   1.426 +    "There should be 0 visible nodes in the watch expressions container.");
   1.427 +
   1.428 +  let exprScope = gVars.getScopeAtIndex(0);
   1.429 +  ok(exprScope,
   1.430 +    "There should be a wach expressions scope in the variables view.");
   1.431 +  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
   1.432 +    "The scope's name should be marked as 'Watch Expressions'.");
   1.433 +  is(exprScope._store.size, 2,
   1.434 +    "There should be 2 visible evaluations available.");
   1.435 +
   1.436 +  is(gWatch.itemCount, 2,
   1.437 +    "There should be 2 hidden expression input available.");
   1.438 +  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "ermahgerd",
   1.439 +    "The first textbox input value is not the correct one.");
   1.440 +  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "ermahgerd",
   1.441 +    "The first textbox input value is not the correct one.");
   1.442 +  is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "this",
   1.443 +    "The second textbox input value is not the correct one.");
   1.444 +  is(gWatch.getItemAtIndex(1).attachment.currentExpression, "this",
   1.445 +    "The second textbox input value is not the correct one.");
   1.446 +}
   1.447 +
   1.448 +function testIntegrity6() {
   1.449 +  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 1,
   1.450 +    "There should be 1 hidden nodes in the watch expressions container.");
   1.451 +  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
   1.452 +    "There should be 0 visible nodes in the watch expressions container.");
   1.453 +
   1.454 +  let exprScope = gVars.getScopeAtIndex(0);
   1.455 +  ok(exprScope,
   1.456 +    "There should be a wach expressions scope in the variables view.");
   1.457 +  is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
   1.458 +    "The scope's name should be marked as 'Watch Expressions'.");
   1.459 +  is(exprScope._store.size, 1,
   1.460 +    "There should be 1 visible evaluation available.");
   1.461 +
   1.462 +  is(gWatch.itemCount, 1,
   1.463 +    "There should be 1 hidden expression input available.");
   1.464 +  is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "ermahgerd",
   1.465 +    "The first textbox input value is not the correct one.");
   1.466 +  is(gWatch.getItemAtIndex(0).attachment.currentExpression, "ermahgerd",
   1.467 +    "The first textbox input value is not the correct one.");
   1.468 +}
   1.469 +
   1.470 +function testIntegrity7() {
   1.471 +  is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 0,
   1.472 +    "There should be 0 hidden nodes in the watch expressions container.");
   1.473 +  is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
   1.474 +    "There should be 0 visible nodes in the watch expressions container.");
   1.475 +
   1.476 +  let localScope = gVars.getScopeAtIndex(0);
   1.477 +  ok(localScope,
   1.478 +    "There should be a local scope in the variables view.");
   1.479 +  isnot(localScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
   1.480 +    "The scope's name should not be marked as 'Watch Expressions'.");
   1.481 +  isnot(localScope._store.size, 0,
   1.482 +    "There should be some variables available.");
   1.483 +
   1.484 +  is(gWatch.itemCount, 0,
   1.485 +    "The watch expressions container should be empty.");
   1.486 +}
   1.487 +
   1.488 +function addExpression(aString) {
   1.489 +  gWatch.addExpression(aString);
   1.490 +  gEditor.focus();
   1.491 +}
   1.492 +
   1.493 +function addCmdExpression(aString) {
   1.494 +  gWatch._onCmdAddExpression(aString);
   1.495 +  gEditor.focus();
   1.496 +}
   1.497 +
   1.498 +registerCleanupFunction(function() {
   1.499 +  gTab = null;
   1.500 +  gDebuggee = null;
   1.501 +  gPanel = null;
   1.502 +  gDebugger = null;
   1.503 +  gL10N = null;
   1.504 +  gEditor = null;
   1.505 +  gVars = null;
   1.506 +  gWatch = null;
   1.507 +});

mercurial