browser/devtools/debugger/test/browser_dbg_variables-view-edit-watch.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 or removing watch expressions works properly.
michael@0 6 */
michael@0 7
michael@0 8 const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html";
michael@0 9
michael@0 10 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 11 let gL10N, gEditor, gVars, gWatch;
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 gL10N = gDebugger.L10N;
michael@0 20 gEditor = gDebugger.DebuggerView.editor;
michael@0 21 gVars = gDebugger.DebuggerView.Variables;
michael@0 22 gWatch = gDebugger.DebuggerView.WatchExpressions;
michael@0 23
michael@0 24 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS)
michael@0 25 .then(() => testInitialVariablesInScope())
michael@0 26 .then(() => testInitialExpressionsInScope())
michael@0 27 .then(() => testModification("document.title = 42", "document.title = 43", "43", "undefined"))
michael@0 28 .then(() => testIntegrity1())
michael@0 29 .then(() => testModification("aArg", "aArg = 44", "44", "44"))
michael@0 30 .then(() => testIntegrity2())
michael@0 31 .then(() => testModification("aArg = 44", "\ \t\r\ndocument.title\ \t\r\n", "\"43\"", "44"))
michael@0 32 .then(() => testIntegrity3())
michael@0 33 .then(() => testModification("document.title = 43", "\ \t\r\ndocument.title\ \t\r\n", "\"43\"", "44"))
michael@0 34 .then(() => testIntegrity4())
michael@0 35 .then(() => testModification("document.title", "\ \t\r\n", "\"43\"", "44"))
michael@0 36 .then(() => testIntegrity5())
michael@0 37 .then(() => testExprDeletion("this", "44"))
michael@0 38 .then(() => testIntegrity6())
michael@0 39 .then(() => testExprFinalDeletion("ermahgerd", "44"))
michael@0 40 .then(() => testIntegrity7())
michael@0 41 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
michael@0 42 .then(null, aError => {
michael@0 43 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 44 });
michael@0 45
michael@0 46 addExpressions();
michael@0 47 gDebuggee.ermahgerd();
michael@0 48 });
michael@0 49 }
michael@0 50
michael@0 51 function addExpressions() {
michael@0 52 addExpression("this");
michael@0 53 addExpression("ermahgerd");
michael@0 54 addExpression("aArg");
michael@0 55 addExpression("document.title");
michael@0 56 addCmdExpression("document.title = 42");
michael@0 57
michael@0 58 is(gWatch.itemCount, 5,
michael@0 59 "There should be 5 items availalble in the watch expressions view.");
michael@0 60
michael@0 61 is(gWatch.getItemAtIndex(4).attachment.initialExpression, "this",
michael@0 62 "The first expression's initial value should be correct.");
michael@0 63 is(gWatch.getItemAtIndex(3).attachment.initialExpression, "ermahgerd",
michael@0 64 "The second expression's initial value should be correct.");
michael@0 65 is(gWatch.getItemAtIndex(2).attachment.initialExpression, "aArg",
michael@0 66 "The third expression's initial value should be correct.");
michael@0 67 is(gWatch.getItemAtIndex(1).attachment.initialExpression, "document.title",
michael@0 68 "The fourth expression's initial value should be correct.");
michael@0 69 is(gWatch.getItemAtIndex(0).attachment.initialExpression, "document.title = 42",
michael@0 70 "The fifth expression's initial value should be correct.");
michael@0 71
michael@0 72 is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
michael@0 73 "The first expression's current value should be correct.");
michael@0 74 is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
michael@0 75 "The second expression's current value should be correct.");
michael@0 76 is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg",
michael@0 77 "The third expression's current value should be correct.");
michael@0 78 is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
michael@0 79 "The fourth expression's current value should be correct.");
michael@0 80 is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 42",
michael@0 81 "The fifth expression's current value should be correct.");
michael@0 82 }
michael@0 83
michael@0 84 function testInitialVariablesInScope() {
michael@0 85 let localScope = gVars.getScopeAtIndex(1);
michael@0 86 let argVar = localScope.get("aArg");
michael@0 87
michael@0 88 is(argVar.visible, true,
michael@0 89 "Should have the right visibility state for 'aArg'.");
michael@0 90 is(argVar.name, "aArg",
michael@0 91 "Should have the right name for 'aArg'.");
michael@0 92 is(argVar.value.type, "undefined",
michael@0 93 "Should have the right initial value for 'aArg'.");
michael@0 94 }
michael@0 95
michael@0 96 function testInitialExpressionsInScope() {
michael@0 97 let exprScope = gVars.getScopeAtIndex(0);
michael@0 98 let thisExpr = exprScope.get("this");
michael@0 99 let ermExpr = exprScope.get("ermahgerd");
michael@0 100 let argExpr = exprScope.get("aArg");
michael@0 101 let docExpr = exprScope.get("document.title");
michael@0 102 let docExpr2 = exprScope.get("document.title = 42");
michael@0 103
michael@0 104 ok(exprScope,
michael@0 105 "There should be a wach expressions scope in the variables view.");
michael@0 106 is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
michael@0 107 "The scope's name should be marked as 'Watch Expressions'.");
michael@0 108 is(exprScope._store.size, 5,
michael@0 109 "There should be 5 evaluations available.");
michael@0 110
michael@0 111 is(thisExpr.visible, true,
michael@0 112 "Should have the right visibility state for 'this'.");
michael@0 113 is(thisExpr.target.querySelectorAll(".variables-view-delete").length, 1,
michael@0 114 "Should have the one close button visible for 'this'.");
michael@0 115 is(thisExpr.name, "this",
michael@0 116 "Should have the right name for 'this'.");
michael@0 117 is(thisExpr.value.type, "object",
michael@0 118 "Should have the right value type for 'this'.");
michael@0 119 is(thisExpr.value.class, "Window",
michael@0 120 "Should have the right value type for 'this'.");
michael@0 121
michael@0 122 is(ermExpr.visible, true,
michael@0 123 "Should have the right visibility state for 'ermahgerd'.");
michael@0 124 is(ermExpr.target.querySelectorAll(".variables-view-delete").length, 1,
michael@0 125 "Should have the one close button visible for 'ermahgerd'.");
michael@0 126 is(ermExpr.name, "ermahgerd",
michael@0 127 "Should have the right name for 'ermahgerd'.");
michael@0 128 is(ermExpr.value.type, "object",
michael@0 129 "Should have the right value type for 'ermahgerd'.");
michael@0 130 is(ermExpr.value.class, "Function",
michael@0 131 "Should have the right value type for 'ermahgerd'.");
michael@0 132
michael@0 133 is(argExpr.visible, true,
michael@0 134 "Should have the right visibility state for 'aArg'.");
michael@0 135 is(argExpr.target.querySelectorAll(".variables-view-delete").length, 1,
michael@0 136 "Should have the one close button visible for 'aArg'.");
michael@0 137 is(argExpr.name, "aArg",
michael@0 138 "Should have the right name for 'aArg'.");
michael@0 139 is(argExpr.value.type, "undefined",
michael@0 140 "Should have the right value for 'aArg'.");
michael@0 141
michael@0 142 is(docExpr.visible, true,
michael@0 143 "Should have the right visibility state for 'document.title'.");
michael@0 144 is(docExpr.target.querySelectorAll(".variables-view-delete").length, 1,
michael@0 145 "Should have the one close button visible for 'document.title'.");
michael@0 146 is(docExpr.name, "document.title",
michael@0 147 "Should have the right name for 'document.title'.");
michael@0 148 is(docExpr.value, "42",
michael@0 149 "Should have the right value for 'document.title'.");
michael@0 150
michael@0 151 is(docExpr2.visible, true,
michael@0 152 "Should have the right visibility state for 'document.title = 42'.");
michael@0 153 is(docExpr2.target.querySelectorAll(".variables-view-delete").length, 1,
michael@0 154 "Should have the one close button visible for 'document.title = 42'.");
michael@0 155 is(docExpr2.name, "document.title = 42",
michael@0 156 "Should have the right name for 'document.title = 42'.");
michael@0 157 is(docExpr2.value, 42,
michael@0 158 "Should have the right value for 'document.title = 42'.");
michael@0 159
michael@0 160 is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
michael@0 161 "There should be 5 hidden nodes in the watch expressions container.");
michael@0 162 is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
michael@0 163 "There should be 0 visible nodes in the watch expressions container.");
michael@0 164 }
michael@0 165
michael@0 166 function testModification(aName, aNewValue, aNewResult, aArgResult) {
michael@0 167 let exprScope = gVars.getScopeAtIndex(0);
michael@0 168 let exprVar = exprScope.get(aName);
michael@0 169
michael@0 170 let finished = promise.all([
michael@0 171 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
michael@0 172 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS)
michael@0 173 ])
michael@0 174 .then(() => {
michael@0 175 let localScope = gVars.getScopeAtIndex(1);
michael@0 176 let argVar = localScope.get("aArg");
michael@0 177
michael@0 178 is(argVar.visible, true,
michael@0 179 "Should have the right visibility state for 'aArg'.");
michael@0 180 is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
michael@0 181 "Should have the right name for 'aArg'.");
michael@0 182 is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
michael@0 183 "Should have the right new value for 'aArg'.");
michael@0 184
michael@0 185 let exprScope = gVars.getScopeAtIndex(0);
michael@0 186 let exprOldVar = exprScope.get(aName);
michael@0 187 let exprNewVar = exprScope.get(aNewValue.trim());
michael@0 188
michael@0 189 if (!aNewValue.trim()) {
michael@0 190 ok(!exprOldVar,
michael@0 191 "The old watch expression should have been removed.");
michael@0 192 ok(!exprNewVar,
michael@0 193 "No new watch expression should have been added.");
michael@0 194 } else {
michael@0 195 ok(!exprOldVar,
michael@0 196 "The old watch expression should have been removed.");
michael@0 197 ok(exprNewVar,
michael@0 198 "The new watch expression should have been added.");
michael@0 199
michael@0 200 is(exprNewVar.visible, true,
michael@0 201 "Should have the right visibility state for the watch expression.");
michael@0 202 is(exprNewVar.target.querySelector(".name").getAttribute("value"), aNewValue.trim(),
michael@0 203 "Should have the right name for the watch expression.");
michael@0 204 is(exprNewVar.target.querySelector(".value").getAttribute("value"), aNewResult,
michael@0 205 "Should have the right new value for the watch expression.");
michael@0 206 }
michael@0 207 });
michael@0 208
michael@0 209 let varValue = exprVar.target.querySelector(".title > .name");
michael@0 210 EventUtils.sendMouseEvent({ type: "dblclick" }, varValue, gDebugger);
michael@0 211
michael@0 212 let varInput = exprVar.target.querySelector(".title > .element-name-input");
michael@0 213 setText(varInput, aNewValue);
michael@0 214 EventUtils.sendKey("RETURN", gDebugger);
michael@0 215
michael@0 216 return finished;
michael@0 217 }
michael@0 218
michael@0 219 function testExprDeletion(aName, aArgResult) {
michael@0 220 let exprScope = gVars.getScopeAtIndex(0);
michael@0 221 let exprVar = exprScope.get(aName);
michael@0 222
michael@0 223 let finished = promise.all([
michael@0 224 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
michael@0 225 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS)
michael@0 226 ])
michael@0 227 .then(() => {
michael@0 228 let localScope = gVars.getScopeAtIndex(1);
michael@0 229 let argVar = localScope.get("aArg");
michael@0 230
michael@0 231 is(argVar.visible, true,
michael@0 232 "Should have the right visibility state for 'aArg'.");
michael@0 233 is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
michael@0 234 "Should have the right name for 'aArg'.");
michael@0 235 is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
michael@0 236 "Should have the right new value for 'aArg'.");
michael@0 237
michael@0 238 let exprScope = gVars.getScopeAtIndex(0);
michael@0 239 let exprOldVar = exprScope.get(aName);
michael@0 240
michael@0 241 ok(!exprOldVar,
michael@0 242 "The watch expression should have been deleted.");
michael@0 243 });
michael@0 244
michael@0 245 let varDelete = exprVar.target.querySelector(".variables-view-delete");
michael@0 246 EventUtils.sendMouseEvent({ type: "click" }, varDelete, gDebugger);
michael@0 247
michael@0 248 return finished;
michael@0 249 }
michael@0 250
michael@0 251 function testExprFinalDeletion(aName, aArgResult) {
michael@0 252 let exprScope = gVars.getScopeAtIndex(0);
michael@0 253 let exprVar = exprScope.get(aName);
michael@0 254
michael@0 255 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
michael@0 256 let localScope = gVars.getScopeAtIndex(0);
michael@0 257 let argVar = localScope.get("aArg");
michael@0 258
michael@0 259 is(argVar.visible, true,
michael@0 260 "Should have the right visibility state for 'aArg'.");
michael@0 261 is(argVar.target.querySelector(".name").getAttribute("value"), "aArg",
michael@0 262 "Should have the right name for 'aArg'.");
michael@0 263 is(argVar.target.querySelector(".value").getAttribute("value"), aArgResult,
michael@0 264 "Should have the right new value for 'aArg'.");
michael@0 265
michael@0 266 let exprScope = gVars.getScopeAtIndex(0);
michael@0 267 let exprOldVar = exprScope.get(aName);
michael@0 268
michael@0 269 ok(!exprOldVar,
michael@0 270 "The watch expression should have been deleted.");
michael@0 271 });
michael@0 272
michael@0 273 let varDelete = exprVar.target.querySelector(".variables-view-delete");
michael@0 274 EventUtils.sendMouseEvent({ type: "click" }, varDelete, gDebugger);
michael@0 275
michael@0 276 return finished;
michael@0 277 }
michael@0 278
michael@0 279 function testIntegrity1() {
michael@0 280 is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
michael@0 281 "There should be 5 hidden nodes in the watch expressions container.");
michael@0 282 is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
michael@0 283 "There should be 0 visible nodes in the watch expressions container.");
michael@0 284
michael@0 285 let exprScope = gVars.getScopeAtIndex(0);
michael@0 286 ok(exprScope,
michael@0 287 "There should be a wach expressions scope in the variables view.");
michael@0 288 is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
michael@0 289 "The scope's name should be marked as 'Watch Expressions'.");
michael@0 290 is(exprScope._store.size, 5,
michael@0 291 "There should be 5 visible evaluations available.");
michael@0 292
michael@0 293 is(gWatch.itemCount, 5,
michael@0 294 "There should be 5 hidden expression input available.");
michael@0 295 is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
michael@0 296 "The first textbox input value is not the correct one.");
michael@0 297 is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
michael@0 298 "The first textbox input value is not the correct one.");
michael@0 299 is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
michael@0 300 "The second textbox input value is not the correct one.");
michael@0 301 is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
michael@0 302 "The second textbox input value is not the correct one.");
michael@0 303 is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "aArg",
michael@0 304 "The third textbox input value is not the correct one.");
michael@0 305 is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg",
michael@0 306 "The third textbox input value is not the correct one.");
michael@0 307 is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "ermahgerd",
michael@0 308 "The fourth textbox input value is not the correct one.");
michael@0 309 is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
michael@0 310 "The fourth textbox input value is not the correct one.");
michael@0 311 is(gWatch.getItemAtIndex(4).attachment.view.inputNode.value, "this",
michael@0 312 "The fifth textbox input value is not the correct one.");
michael@0 313 is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
michael@0 314 "The fifth textbox input value is not the correct one.");
michael@0 315 }
michael@0 316
michael@0 317 function testIntegrity2() {
michael@0 318 is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 5,
michael@0 319 "There should be 5 hidden nodes in the watch expressions container.");
michael@0 320 is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
michael@0 321 "There should be 0 visible nodes in the watch expressions container.");
michael@0 322
michael@0 323 let exprScope = gVars.getScopeAtIndex(0);
michael@0 324 ok(exprScope,
michael@0 325 "There should be a wach expressions scope in the variables view.");
michael@0 326 is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
michael@0 327 "The scope's name should be marked as 'Watch Expressions'.");
michael@0 328 is(exprScope._store.size, 5,
michael@0 329 "There should be 5 visible evaluations available.");
michael@0 330
michael@0 331 is(gWatch.itemCount, 5,
michael@0 332 "There should be 5 hidden expression input available.");
michael@0 333 is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
michael@0 334 "The first textbox input value is not the correct one.");
michael@0 335 is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
michael@0 336 "The first textbox input value is not the correct one.");
michael@0 337 is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
michael@0 338 "The second textbox input value is not the correct one.");
michael@0 339 is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
michael@0 340 "The second textbox input value is not the correct one.");
michael@0 341 is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "aArg = 44",
michael@0 342 "The third textbox input value is not the correct one.");
michael@0 343 is(gWatch.getItemAtIndex(2).attachment.currentExpression, "aArg = 44",
michael@0 344 "The third textbox input value is not the correct one.");
michael@0 345 is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "ermahgerd",
michael@0 346 "The fourth textbox input value is not the correct one.");
michael@0 347 is(gWatch.getItemAtIndex(3).attachment.currentExpression, "ermahgerd",
michael@0 348 "The fourth textbox input value is not the correct one.");
michael@0 349 is(gWatch.getItemAtIndex(4).attachment.view.inputNode.value, "this",
michael@0 350 "The fifth textbox input value is not the correct one.");
michael@0 351 is(gWatch.getItemAtIndex(4).attachment.currentExpression, "this",
michael@0 352 "The fifth textbox input value is not the correct one.");
michael@0 353 }
michael@0 354
michael@0 355 function testIntegrity3() {
michael@0 356 is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 4,
michael@0 357 "There should be 4 hidden nodes in the watch expressions container.");
michael@0 358 is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
michael@0 359 "There should be 0 visible nodes in the watch expressions container.");
michael@0 360
michael@0 361 let exprScope = gVars.getScopeAtIndex(0);
michael@0 362 ok(exprScope,
michael@0 363 "There should be a wach expressions scope in the variables view.");
michael@0 364 is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
michael@0 365 "The scope's name should be marked as 'Watch Expressions'.");
michael@0 366 is(exprScope._store.size, 4,
michael@0 367 "There should be 4 visible evaluations available.");
michael@0 368
michael@0 369 is(gWatch.itemCount, 4,
michael@0 370 "There should be 4 hidden expression input available.");
michael@0 371 is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title = 43",
michael@0 372 "The first textbox input value is not the correct one.");
michael@0 373 is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title = 43",
michael@0 374 "The first textbox input value is not the correct one.");
michael@0 375 is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "document.title",
michael@0 376 "The second textbox input value is not the correct one.");
michael@0 377 is(gWatch.getItemAtIndex(1).attachment.currentExpression, "document.title",
michael@0 378 "The second textbox input value is not the correct one.");
michael@0 379 is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "ermahgerd",
michael@0 380 "The third textbox input value is not the correct one.");
michael@0 381 is(gWatch.getItemAtIndex(2).attachment.currentExpression, "ermahgerd",
michael@0 382 "The third textbox input value is not the correct one.");
michael@0 383 is(gWatch.getItemAtIndex(3).attachment.view.inputNode.value, "this",
michael@0 384 "The fourth textbox input value is not the correct one.");
michael@0 385 is(gWatch.getItemAtIndex(3).attachment.currentExpression, "this",
michael@0 386 "The fourth textbox input value is not the correct one.");
michael@0 387 }
michael@0 388
michael@0 389 function testIntegrity4() {
michael@0 390 is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 3,
michael@0 391 "There should be 3 hidden nodes in the watch expressions container.");
michael@0 392 is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
michael@0 393 "There should be 0 visible nodes in the watch expressions container.");
michael@0 394
michael@0 395 let exprScope = gVars.getScopeAtIndex(0);
michael@0 396 ok(exprScope,
michael@0 397 "There should be a wach expressions scope in the variables view.");
michael@0 398 is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
michael@0 399 "The scope's name should be marked as 'Watch Expressions'.");
michael@0 400 is(exprScope._store.size, 3,
michael@0 401 "There should be 3 visible evaluations available.");
michael@0 402
michael@0 403 is(gWatch.itemCount, 3,
michael@0 404 "There should be 3 hidden expression input available.");
michael@0 405 is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "document.title",
michael@0 406 "The first textbox input value is not the correct one.");
michael@0 407 is(gWatch.getItemAtIndex(0).attachment.currentExpression, "document.title",
michael@0 408 "The first textbox input value is not the correct one.");
michael@0 409 is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "ermahgerd",
michael@0 410 "The second textbox input value is not the correct one.");
michael@0 411 is(gWatch.getItemAtIndex(1).attachment.currentExpression, "ermahgerd",
michael@0 412 "The second textbox input value is not the correct one.");
michael@0 413 is(gWatch.getItemAtIndex(2).attachment.view.inputNode.value, "this",
michael@0 414 "The third textbox input value is not the correct one.");
michael@0 415 is(gWatch.getItemAtIndex(2).attachment.currentExpression, "this",
michael@0 416 "The third textbox input value is not the correct one.");
michael@0 417 }
michael@0 418
michael@0 419 function testIntegrity5() {
michael@0 420 is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 2,
michael@0 421 "There should be 2 hidden nodes in the watch expressions container.");
michael@0 422 is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
michael@0 423 "There should be 0 visible nodes in the watch expressions container.");
michael@0 424
michael@0 425 let exprScope = gVars.getScopeAtIndex(0);
michael@0 426 ok(exprScope,
michael@0 427 "There should be a wach expressions scope in the variables view.");
michael@0 428 is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
michael@0 429 "The scope's name should be marked as 'Watch Expressions'.");
michael@0 430 is(exprScope._store.size, 2,
michael@0 431 "There should be 2 visible evaluations available.");
michael@0 432
michael@0 433 is(gWatch.itemCount, 2,
michael@0 434 "There should be 2 hidden expression input available.");
michael@0 435 is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "ermahgerd",
michael@0 436 "The first textbox input value is not the correct one.");
michael@0 437 is(gWatch.getItemAtIndex(0).attachment.currentExpression, "ermahgerd",
michael@0 438 "The first textbox input value is not the correct one.");
michael@0 439 is(gWatch.getItemAtIndex(1).attachment.view.inputNode.value, "this",
michael@0 440 "The second textbox input value is not the correct one.");
michael@0 441 is(gWatch.getItemAtIndex(1).attachment.currentExpression, "this",
michael@0 442 "The second textbox input value is not the correct one.");
michael@0 443 }
michael@0 444
michael@0 445 function testIntegrity6() {
michael@0 446 is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 1,
michael@0 447 "There should be 1 hidden nodes in the watch expressions container.");
michael@0 448 is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
michael@0 449 "There should be 0 visible nodes in the watch expressions container.");
michael@0 450
michael@0 451 let exprScope = gVars.getScopeAtIndex(0);
michael@0 452 ok(exprScope,
michael@0 453 "There should be a wach expressions scope in the variables view.");
michael@0 454 is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
michael@0 455 "The scope's name should be marked as 'Watch Expressions'.");
michael@0 456 is(exprScope._store.size, 1,
michael@0 457 "There should be 1 visible evaluation available.");
michael@0 458
michael@0 459 is(gWatch.itemCount, 1,
michael@0 460 "There should be 1 hidden expression input available.");
michael@0 461 is(gWatch.getItemAtIndex(0).attachment.view.inputNode.value, "ermahgerd",
michael@0 462 "The first textbox input value is not the correct one.");
michael@0 463 is(gWatch.getItemAtIndex(0).attachment.currentExpression, "ermahgerd",
michael@0 464 "The first textbox input value is not the correct one.");
michael@0 465 }
michael@0 466
michael@0 467 function testIntegrity7() {
michael@0 468 is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 0,
michael@0 469 "There should be 0 hidden nodes in the watch expressions container.");
michael@0 470 is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
michael@0 471 "There should be 0 visible nodes in the watch expressions container.");
michael@0 472
michael@0 473 let localScope = gVars.getScopeAtIndex(0);
michael@0 474 ok(localScope,
michael@0 475 "There should be a local scope in the variables view.");
michael@0 476 isnot(localScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
michael@0 477 "The scope's name should not be marked as 'Watch Expressions'.");
michael@0 478 isnot(localScope._store.size, 0,
michael@0 479 "There should be some variables available.");
michael@0 480
michael@0 481 is(gWatch.itemCount, 0,
michael@0 482 "The watch expressions container should be empty.");
michael@0 483 }
michael@0 484
michael@0 485 function addExpression(aString) {
michael@0 486 gWatch.addExpression(aString);
michael@0 487 gEditor.focus();
michael@0 488 }
michael@0 489
michael@0 490 function addCmdExpression(aString) {
michael@0 491 gWatch._onCmdAddExpression(aString);
michael@0 492 gEditor.focus();
michael@0 493 }
michael@0 494
michael@0 495 registerCleanupFunction(function() {
michael@0 496 gTab = null;
michael@0 497 gDebuggee = null;
michael@0 498 gPanel = null;
michael@0 499 gDebugger = null;
michael@0 500 gL10N = null;
michael@0 501 gEditor = null;
michael@0 502 gVars = null;
michael@0 503 gWatch = null;
michael@0 504 });

mercurial