| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * @fileoverview This file contains small testing framework along with the | 7 * @fileoverview This file contains small testing framework along with the |
| 8 * test suite for the frontend. These tests are a part of the continues build | 8 * test suite for the frontend. These tests are a part of the continues build |
| 9 * and are executed by the devtools_sanity_unittest.cc as a part of the | 9 * and are executed by the devtools_sanity_unittest.cc as a part of the |
| 10 * Interactive UI Test suite. | 10 * Interactive UI Test suite. |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 if (window.domAutomationController) { | 13 if (window.domAutomationController) { |
| 14 | 14 |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Test suite for interactive UI tests. | 17 * Test suite for interactive UI tests. |
| 18 * @constructor | 18 * @constructor |
| 19 */ | 19 */ |
| 20 TestSuite = function() { | 20 TestSuite = function() { |
| 21 this.controlTaken_ = false; |
| 22 this.timerId_ = -1; |
| 21 }; | 23 }; |
| 22 | 24 |
| 23 | 25 |
| 24 /** | 26 /** |
| 25 * Reports test failure. | 27 * Reports test failure. |
| 26 * @param {string} message Failure description. | 28 * @param {string} message Failure description. |
| 27 */ | 29 */ |
| 28 TestSuite.prototype.fail = function(message) { | 30 TestSuite.prototype.fail = function(message) { |
| 29 throw message; | 31 if (this.controlTaken_) { |
| 32 this.reportFailure_(message); |
| 33 } else { |
| 34 throw message; |
| 35 } |
| 30 }; | 36 }; |
| 31 | 37 |
| 32 | 38 |
| 33 /** | 39 /** |
| 34 * Equals assertion tests that expected == actual. | 40 * Equals assertion tests that expected == actual. |
| 35 * @param {Object} expected Expected object. | 41 * @param {Object} expected Expected object. |
| 36 * @param {Object} actual Actual object. | 42 * @param {Object} actual Actual object. |
| 37 */ | 43 */ |
| 38 TestSuite.prototype.assertEquals = function(expected, actual) { | 44 TestSuite.prototype.assertEquals = function(expected, actual) { |
| 39 if (expected != actual) { | 45 if (expected != actual) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 * @param {string} substring Inner. | 64 * @param {string} substring Inner. |
| 59 */ | 65 */ |
| 60 TestSuite.prototype.assertContains = function(string, substring) { | 66 TestSuite.prototype.assertContains = function(string, substring) { |
| 61 if (string.indexOf(substring) == -1) { | 67 if (string.indexOf(substring) == -1) { |
| 62 this.fail('Expected to: "' + string + '" to contain "' + substring + '"'); | 68 this.fail('Expected to: "' + string + '" to contain "' + substring + '"'); |
| 63 } | 69 } |
| 64 }; | 70 }; |
| 65 | 71 |
| 66 | 72 |
| 67 /** | 73 /** |
| 68 * Runs all global functions starting with 'test' as unit tests. | |
| 69 */ | |
| 70 TestSuite.prototype.runAllTests = function() { | |
| 71 // For debugging purposes. | |
| 72 for (var name in this) { | |
| 73 if (name.substring(0, 4) == 'test' && | |
| 74 typeof this[name] == 'function') { | |
| 75 this.runTest(name); | |
| 76 } | |
| 77 } | |
| 78 }; | |
| 79 | |
| 80 | |
| 81 /** | |
| 82 * Manual controller for async tests. | |
| 83 * @constructor. | |
| 84 */ | |
| 85 TestSuite.Controller = function() { | |
| 86 this.controlTaken_ = false; | |
| 87 this.timerId_ = -1; | |
| 88 }; | |
| 89 | |
| 90 | |
| 91 /** | |
| 92 * Takes control over execution. | 74 * Takes control over execution. |
| 93 */ | 75 */ |
| 94 TestSuite.Controller.prototype.takeControl = function() { | 76 TestSuite.prototype.takeControl = function() { |
| 95 this.controlTaken_ = true; | 77 this.controlTaken_ = true; |
| 96 // Set up guard timer. | 78 // Set up guard timer. |
| 97 var self = this; | 79 var self = this; |
| 98 this.timerId_ = setTimeout(function() { | 80 this.timerId_ = setTimeout(function() { |
| 99 self.reportFailure_('Timeout exceeded: 20 sec'); | 81 self.reportFailure_('Timeout exceeded: 20 sec'); |
| 100 }, 20000); | 82 }, 20000); |
| 101 }; | 83 }; |
| 102 | 84 |
| 103 | 85 |
| 104 /** | 86 /** |
| 105 * Releases control over execution. | 87 * Releases control over execution. |
| 106 */ | 88 */ |
| 107 TestSuite.Controller.prototype.releaseControl = function() { | 89 TestSuite.prototype.releaseControl = function() { |
| 108 this.controlTaken_ = false; | |
| 109 if (this.timerId_ != -1) { | 90 if (this.timerId_ != -1) { |
| 91 clearTimeout(this.timerId_); |
| 110 this.timerId_ = -1; | 92 this.timerId_ = -1; |
| 111 clearTimeout(this.timerId_); | |
| 112 } | 93 } |
| 113 this.reportOk_(); | 94 this.reportOk_(); |
| 114 }; | 95 }; |
| 115 | 96 |
| 116 | 97 |
| 117 /** | 98 /** |
| 118 * Async tests use this one to report that they are completed. | 99 * Async tests use this one to report that they are completed. |
| 119 */ | 100 */ |
| 120 TestSuite.Controller.prototype.reportOk_ = function() { | 101 TestSuite.prototype.reportOk_ = function() { |
| 121 window.domAutomationController.send('[OK]'); | 102 window.domAutomationController.send('[OK]'); |
| 122 }; | 103 }; |
| 123 | 104 |
| 124 | 105 |
| 125 /** | 106 /** |
| 126 * Async tests use this one to report failures. | 107 * Async tests use this one to report failures. |
| 127 */ | 108 */ |
| 128 TestSuite.Controller.prototype.reportFailure_ = function(error) { | 109 TestSuite.prototype.reportFailure_ = function(error) { |
| 129 if (this.timerId_ != -1) { | 110 if (this.timerId_ != -1) { |
| 111 clearTimeout(this.timerId_); |
| 130 this.timerId_ = -1; | 112 this.timerId_ = -1; |
| 131 clearTimeout(this.timerId_); | |
| 132 } | 113 } |
| 133 window.domAutomationController.send('[FAILED] ' + error); | 114 window.domAutomationController.send('[FAILED] ' + error); |
| 134 }; | 115 }; |
| 135 | 116 |
| 136 | 117 |
| 137 /** | 118 /** |
| 138 * Runs all global functions starting with 'test' as unit tests. | 119 * Runs all global functions starting with 'test' as unit tests. |
| 139 */ | 120 */ |
| 140 TestSuite.prototype.runTest = function(testName) { | 121 TestSuite.prototype.runTest = function(testName) { |
| 141 var controller = new TestSuite.Controller(); | |
| 142 try { | 122 try { |
| 143 this[testName](controller); | 123 this[testName](); |
| 144 if (!controller.controlTaken_) { | 124 if (!this.controlTaken_) { |
| 145 controller.reportOk_(); | 125 this.reportOk_(); |
| 146 } | 126 } |
| 147 } catch (e) { | 127 } catch (e) { |
| 148 controller.reportFailure_(e); | 128 this.reportFailure_(e); |
| 149 } | 129 } |
| 150 }; | 130 }; |
| 151 | 131 |
| 152 | 132 |
| 153 /** | 133 /** |
| 154 * @param {string} panelName Name of the panel to show. | 134 * @param {string} panelName Name of the panel to show. |
| 155 */ | 135 */ |
| 156 TestSuite.prototype.showPanel = function(panelName) { | 136 TestSuite.prototype.showPanel = function(panelName) { |
| 157 // Open Scripts panel. | 137 // Open Scripts panel. |
| 158 var toolbar = document.getElementById('toolbar'); | 138 var toolbar = document.getElementById('toolbar'); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 for (var id in resources) { | 177 for (var id in resources) { |
| 198 tokens.push(resources[id].lastPathComponent); | 178 tokens.push(resources[id].lastPathComponent); |
| 199 } | 179 } |
| 200 this.assertEquals('simple_page.html', tokens.join(',')); | 180 this.assertEquals('simple_page.html', tokens.join(',')); |
| 201 }; | 181 }; |
| 202 | 182 |
| 203 | 183 |
| 204 /** | 184 /** |
| 205 * Tests that resources tab is enabled when corresponding item is selected. | 185 * Tests that resources tab is enabled when corresponding item is selected. |
| 206 */ | 186 */ |
| 207 TestSuite.prototype.testEnableResourcesTab = function(controller) { | 187 TestSuite.prototype.testEnableResourcesTab = function() { |
| 208 this.showPanel('resources'); | 188 this.showPanel('resources'); |
| 209 | 189 |
| 210 var test = this; | 190 var test = this; |
| 211 var oldAddResource = WebInspector.addResource; | 191 var oldAddResource = WebInspector.addResource; |
| 212 WebInspector.addResource = function(identifier, payload) { | 192 WebInspector.addResource = function(identifier, payload) { |
| 213 WebInspector.addResource = oldAddResource; | 193 WebInspector.addResource = oldAddResource; |
| 214 oldAddResource.call(this, identifier, payload); | 194 oldAddResource.call(this, identifier, payload); |
| 215 test.assertEquals('simple_page.html', payload.lastPathComponent); | 195 test.assertEquals('simple_page.html', payload.lastPathComponent); |
| 216 WebInspector.panels.resources.refresh(); | 196 WebInspector.panels.resources.refresh(); |
| 217 WebInspector.resources[identifier]._resourcesTreeElement.select(); | 197 WebInspector.resources[identifier]._resourcesTreeElement.select(); |
| 218 | 198 |
| 219 controller.releaseControl(); | 199 test.releaseControl(); |
| 220 }; | 200 }; |
| 221 | 201 |
| 222 // Following call should lead to reload that we capture in the | 202 // Following call should lead to reload that we capture in the |
| 223 // addResource override. | 203 // addResource override. |
| 224 WebInspector.panels.resources._enableResourceTracking(); | 204 WebInspector.panels.resources._enableResourceTracking(); |
| 225 | 205 |
| 226 // We now have some time to report results to controller. | 206 // We now have some time to report results to controller. |
| 227 controller.takeControl(); | 207 this.takeControl(); |
| 228 }; | 208 }; |
| 229 | 209 |
| 230 | 210 |
| 231 /** | 211 /** |
| 232 * Tests resource headers. | 212 * Tests resource headers. |
| 233 */ | 213 */ |
| 234 TestSuite.prototype.testResourceHeaders = function(controller) { | 214 TestSuite.prototype.testResourceHeaders = function() { |
| 235 this.showPanel('resources'); | 215 this.showPanel('resources'); |
| 236 | 216 |
| 237 var test = this; | 217 var test = this; |
| 238 var oldAddResource = WebInspector.addResource; | 218 var oldAddResource = WebInspector.addResource; |
| 239 var oldUpdateResource = WebInspector.updateResource; | 219 var oldUpdateResource = WebInspector.updateResource; |
| 240 | 220 |
| 241 var requestOk = false; | 221 var requestOk = false; |
| 242 var responseOk = false; | 222 var responseOk = false; |
| 243 var timingOk = false; | 223 var timingOk = false; |
| 244 | 224 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 274 if (payload.didTimingChange) { | 254 if (payload.didTimingChange) { |
| 275 test.assertTrue(typeof resource.startTime != 'undefnied'); | 255 test.assertTrue(typeof resource.startTime != 'undefnied'); |
| 276 timingOk = true; | 256 timingOk = true; |
| 277 } | 257 } |
| 278 | 258 |
| 279 if (payload.didCompletionChange) { | 259 if (payload.didCompletionChange) { |
| 280 test.assertTrue(requestOk); | 260 test.assertTrue(requestOk); |
| 281 test.assertTrue(responseOk); | 261 test.assertTrue(responseOk); |
| 282 test.assertTrue(timingOk); | 262 test.assertTrue(timingOk); |
| 283 test.assertTrue(typeof resource.endTime != 'undefnied'); | 263 test.assertTrue(typeof resource.endTime != 'undefnied'); |
| 284 controller.releaseControl(); | 264 test.releaseControl(); |
| 285 } | 265 } |
| 286 }; | 266 }; |
| 287 | 267 |
| 288 WebInspector.panels.resources._enableResourceTracking(); | 268 WebInspector.panels.resources._enableResourceTracking(); |
| 289 controller.takeControl(); | 269 this.takeControl(); |
| 290 }; | 270 }; |
| 291 | 271 |
| 292 | 272 |
| 293 /** | 273 /** |
| 294 * Test that profiler works. | 274 * Test that profiler works. |
| 295 */ | 275 */ |
| 296 TestSuite.prototype.testProfilerTab = function(controller) { | 276 TestSuite.prototype.testProfilerTab = function() { |
| 297 this.showPanel('profiles'); | 277 this.showPanel('profiles'); |
| 298 | 278 |
| 299 var test = this; | 279 var test = this; |
| 300 var oldAddProfile = WebInspector.addProfile; | 280 var oldAddProfile = WebInspector.addProfile; |
| 301 WebInspector.addProfile = function(profile) { | 281 WebInspector.addProfile = function(profile) { |
| 302 WebInspector.addProfile = oldAddProfile; | 282 WebInspector.addProfile = oldAddProfile; |
| 303 oldAddProfile.call(this, profile); | 283 oldAddProfile.call(this, profile); |
| 304 | 284 |
| 305 var panel = WebInspector.panels.profiles; | 285 var panel = WebInspector.panels.profiles; |
| 306 panel.showProfile(profile); | 286 panel.showProfile(profile); |
| 307 var node = panel.visibleView.profileDataGridTree.children[0]; | 287 var node = panel.visibleView.profileDataGridTree.children[0]; |
| 308 // Iterate over displayed functions and search for a function | 288 // Iterate over displayed functions and search for a function |
| 309 // that is called 'fib' or 'eternal_fib'. If found, it will mean | 289 // that is called 'fib' or 'eternal_fib'. If found, it will mean |
| 310 // that we actually have profiled page's code. | 290 // that we actually have profiled page's code. |
| 311 while (node) { | 291 while (node) { |
| 312 if (node.functionName.indexOf("fib") != -1) { | 292 if (node.functionName.indexOf("fib") != -1) { |
| 313 controller.releaseControl(); | 293 test.releaseControl(); |
| 314 } | 294 } |
| 315 node = node.traverseNextNode(true, null, true); | 295 node = node.traverseNextNode(true, null, true); |
| 316 } | 296 } |
| 317 | 297 |
| 318 test.fail(); | 298 test.fail(); |
| 319 }; | 299 }; |
| 320 | 300 |
| 321 InspectorController.startProfiling(); | 301 InspectorController.startProfiling(); |
| 322 window.setTimeout('InspectorController.stopProfiling();', 1000); | 302 window.setTimeout('InspectorController.stopProfiling();', 1000); |
| 323 controller.takeControl(); | 303 this.takeControl(); |
| 324 }; | 304 }; |
| 325 | 305 |
| 326 | 306 |
| 327 /** | 307 /** |
| 328 * Tests that scripts tab can be open and populated with inspected scripts. | 308 * Tests that scripts tab can be open and populated with inspected scripts. |
| 329 */ | 309 */ |
| 330 TestSuite.prototype.testShowScriptsTab = function(controller) { | 310 TestSuite.prototype.testShowScriptsTab = function() { |
| 331 var parsedDebuggerTestPageHtml = false; | 311 var parsedDebuggerTestPageHtml = false; |
| 332 var parsedDebuggerTestJs = false; | 312 var parsedDebuggerTestJs = false; |
| 333 | 313 |
| 334 // Intercept parsedScriptSource calls to check that all expected scripts are | 314 // Intercept parsedScriptSource calls to check that all expected scripts are |
| 335 // added to the debugger. | 315 // added to the debugger. |
| 336 var test = this; | 316 var test = this; |
| 337 var originalParsedScriptSource = WebInspector.parsedScriptSource; | 317 var originalParsedScriptSource = WebInspector.parsedScriptSource; |
| 338 WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, | 318 WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, |
| 339 startingLine) { | 319 startingLine) { |
| 340 if (sourceURL.search(/debugger_test_page.html$/) != -1) { | 320 if (sourceURL.search(/debugger_test_page.html$/) != -1) { |
| 341 if (parsedDebuggerTestPageHtml) { | 321 if (parsedDebuggerTestPageHtml) { |
| 342 test.fail('Unexpected parse event: ' + sourceURL); | 322 test.fail('Unexpected parse event: ' + sourceURL); |
| 343 } | 323 } |
| 344 parsedDebuggerTestPageHtml = true; | 324 parsedDebuggerTestPageHtml = true; |
| 345 } else if (sourceURL.search(/debugger_test.js$/) != -1) { | 325 } else if (sourceURL.search(/debugger_test.js$/) != -1) { |
| 346 if (parsedDebuggerTestJs) { | 326 if (parsedDebuggerTestJs) { |
| 347 test.fail('Unexpected parse event: ' + sourceURL); | 327 test.fail('Unexpected parse event: ' + sourceURL); |
| 348 } | 328 } |
| 349 parsedDebuggerTestJs = true; | 329 parsedDebuggerTestJs = true; |
| 350 } else { | 330 } else { |
| 351 test.fail('Unexpected script URL: ' + sourceURL); | 331 test.fail('Unexpected script URL: ' + sourceURL); |
| 352 } | 332 } |
| 353 originalParsedScriptSource.apply(this, arguments); | 333 originalParsedScriptSource.apply(this, arguments); |
| 354 | 334 |
| 355 if (!WebInspector.panels.scripts.visibleView) { | 335 if (!WebInspector.panels.scripts.visibleView) { |
| 356 test.fail('No visible script view: ' + sourceURL); | 336 test.fail('No visible script view: ' + sourceURL); |
| 357 } | 337 } |
| 358 | 338 |
| 359 if (parsedDebuggerTestJs && parsedDebuggerTestPageHtml) { | 339 if (parsedDebuggerTestJs && parsedDebuggerTestPageHtml) { |
| 360 controller.releaseControl(); | 340 test.releaseControl(); |
| 361 } | 341 } |
| 362 }; | 342 }; |
| 363 | 343 |
| 364 this.showPanel('scripts'); | 344 this.showPanel('scripts'); |
| 365 | 345 |
| 366 // Wait until all scripts are added to the debugger. | 346 // Wait until all scripts are added to the debugger. |
| 367 controller.takeControl(); | 347 this.takeControl(); |
| 368 }; | 348 }; |
| 369 | 349 |
| 370 | 350 |
| 371 /** | 351 /** |
| 372 * Key event with given key identifier. | 352 * Key event with given key identifier. |
| 373 */ | 353 */ |
| 374 TestSuite.KeyEvent = function(key) { | 354 TestSuite.KeyEvent = function(key) { |
| 375 this.keyIdentifier = key; | 355 this.keyIdentifier = key; |
| 376 }; | 356 }; |
| 377 TestSuite.KeyEvent.prototype.preventDefault = function() {}; | 357 TestSuite.KeyEvent.prototype.preventDefault = function() {}; |
| 378 TestSuite.KeyEvent.prototype.stopPropagation = function() {}; | 358 TestSuite.KeyEvent.prototype.stopPropagation = function() {}; |
| 379 | 359 |
| 380 | 360 |
| 381 /** | 361 /** |
| 382 * Tests console eval. | 362 * Tests console eval. |
| 383 */ | 363 */ |
| 384 TestSuite.prototype.testConsoleEval = function(controller) { | 364 TestSuite.prototype.testConsoleEval = function() { |
| 385 WebInspector.console.visible = true; | 365 WebInspector.console.visible = true; |
| 386 WebInspector.console.prompt.text = '123'; | 366 WebInspector.console.prompt.text = '123'; |
| 387 WebInspector.console.promptElement.handleKeyEvent( | 367 WebInspector.console.promptElement.handleKeyEvent( |
| 388 new TestSuite.KeyEvent('Enter')); | 368 new TestSuite.KeyEvent('Enter')); |
| 389 | 369 |
| 390 var test = this; | 370 var test = this; |
| 391 var originalConsoleAddMessage = WebInspector.Console.prototype.addMessage; | 371 var originalConsoleAddMessage = WebInspector.Console.prototype.addMessage; |
| 392 WebInspector.Console.prototype.addMessage = function(commandResult) { | 372 WebInspector.Console.prototype.addMessage = function(commandResult) { |
| 393 originalConsoleAddMessage.call(this, commandResult); | 373 originalConsoleAddMessage.call(this, commandResult); |
| 394 WebInspector.Console.prototype.addMessage = originalConsoleAddMessage; | 374 WebInspector.Console.prototype.addMessage = originalConsoleAddMessage; |
| 395 test.assertEquals('123', commandResult.toMessageElement().textContent); | 375 test.assertEquals('123', commandResult.toMessageElement().textContent); |
| 396 controller.releaseControl(); | 376 test.releaseControl(); |
| 397 }; | 377 }; |
| 398 | 378 |
| 399 controller.takeControl(); | 379 this.takeControl(); |
| 400 }; | 380 }; |
| 401 | 381 |
| 402 | 382 |
| 403 /** | 383 /** |
| 404 * Tests console log. | 384 * Tests console log. |
| 405 */ | 385 */ |
| 406 TestSuite.prototype.testConsoleLog = function(controller) { | 386 TestSuite.prototype.testConsoleLog = function() { |
| 407 WebInspector.console.visible = true; | 387 WebInspector.console.visible = true; |
| 408 var messages = WebInspector.console.messages; | 388 var messages = WebInspector.console.messages; |
| 409 var index = 0; | 389 var index = 0; |
| 410 | 390 |
| 411 var test = this; | 391 var test = this; |
| 412 var assertNext = function(line, message, opt_level, opt_count, opt_substr) { | 392 var assertNext = function(line, message, opt_level, opt_count, opt_substr) { |
| 413 var elem = messages[index++].toMessageElement(); | 393 var elem = messages[index++].toMessageElement(); |
| 414 var clazz = elem.getAttribute('class'); | 394 var clazz = elem.getAttribute('class'); |
| 415 var expectation = (opt_count || '') + 'console_test_page.html:' + | 395 var expectation = (opt_count || '') + 'console_test_page.html:' + |
| 416 line + message; | 396 line + message; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 437 assertNext('26', 'count: 2'); | 417 assertNext('26', 'count: 2'); |
| 438 assertNext('29', 'group', 'group-title'); | 418 assertNext('29', 'group', 'group-title'); |
| 439 index++; | 419 index++; |
| 440 assertNext('33', 'timer:', 'log', '', true); | 420 assertNext('33', 'timer:', 'log', '', true); |
| 441 }; | 421 }; |
| 442 | 422 |
| 443 | 423 |
| 444 /** | 424 /** |
| 445 * Tests eval of global objects. | 425 * Tests eval of global objects. |
| 446 */ | 426 */ |
| 447 TestSuite.prototype.testEvalGlobal = function(controller) { | 427 TestSuite.prototype.testEvalGlobal = function() { |
| 448 WebInspector.console.visible = true; | 428 WebInspector.console.visible = true; |
| 449 WebInspector.console.prompt.text = 'foo'; | 429 WebInspector.console.prompt.text = 'foo'; |
| 450 WebInspector.console.promptElement.handleKeyEvent( | 430 WebInspector.console.promptElement.handleKeyEvent( |
| 451 new TestSuite.KeyEvent('Enter')); | 431 new TestSuite.KeyEvent('Enter')); |
| 452 | 432 |
| 453 var test = this; | 433 var test = this; |
| 454 var originalConsoleAddMessage = WebInspector.Console.prototype.addMessage; | 434 var originalConsoleAddMessage = WebInspector.Console.prototype.addMessage; |
| 455 WebInspector.Console.prototype.addMessage = function(commandResult) { | 435 WebInspector.Console.prototype.addMessage = function(commandResult) { |
| 456 originalConsoleAddMessage.call(this, commandResult); | 436 originalConsoleAddMessage.call(this, commandResult); |
| 457 test.assertEquals('fooValue', commandResult.toMessageElement().textContent); | 437 test.assertEquals('fooValue', commandResult.toMessageElement().textContent); |
| 458 controller.releaseControl(); | 438 test.releaseControl(); |
| 459 }; | 439 }; |
| 460 | 440 |
| 461 controller.takeControl(); | 441 this.takeControl(); |
| 462 }; | 442 }; |
| 463 | 443 |
| 464 | 444 |
| 465 /** | 445 /** |
| 466 * Tests eval on call frame. | 446 * Tests eval on call frame. |
| 467 */ | 447 */ |
| 468 TestSuite.prototype.testEvalCallFrame = function(controller) { | 448 TestSuite.prototype.testEvalCallFrame = function() { |
| 469 }; | 449 }; |
| 470 | 450 |
| 471 | 451 |
| 472 var uiTests = new TestSuite(); | 452 /** |
| 453 * Test runner for the test suite. |
| 454 */ |
| 455 var uiTests = {}; |
| 456 |
| 457 |
| 458 /** |
| 459 * Run each test from the test suit on a fresh instance of the suite. |
| 460 */ |
| 461 uiTests.runAllTests = function() { |
| 462 // For debugging purposes. |
| 463 for (var name in TestSuite.prototype) { |
| 464 if (name.substring(0, 4) == 'test' && |
| 465 typeof TestSuite.prototype[name] == 'function') { |
| 466 uiTests.runTest(name); |
| 467 } |
| 468 } |
| 469 }; |
| 470 |
| 471 |
| 472 /** |
| 473 * Run specified test on a fresh instance of the test suite. |
| 474 * @param {string} name Name of a test method from TestSuite class. |
| 475 */ |
| 476 uiTests.runTest = function(name) { |
| 477 new TestSuite().runTest(name); |
| 478 }; |
| 479 |
| 480 |
| 473 } | 481 } |
| OLD | NEW |