2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * @fileoverview This file contains small testing framework along with the
34 * test suite for the frontend. These tests are a part of the continues build
35 * and are executed by the devtools_sanity_unittest.cc as a part of the
36 * Interactive UI Test suite.
37 * FIXME: change field naming style to use trailing underscore.
40 if (window.domAutomationController) {
42 var ___interactiveUiTestsMode = true;
45 * Test suite for interactive UI tests.
48 TestSuite = function()
50 this.controlTaken_ = false;
56 * Reports test failure.
57 * @param {string} message Failure description.
59 TestSuite.prototype.fail = function(message)
61 if (this.controlTaken_)
62 this.reportFailure_(message);
69 * Equals assertion tests that expected === actual.
70 * @param {!Object} expected Expected object.
71 * @param {!Object} actual Actual object.
72 * @param {string} opt_message User message to print if the test fails.
74 TestSuite.prototype.assertEquals = function(expected, actual, opt_message)
76 if (expected !== actual) {
77 var message = "Expected: '" + expected + "', but was '" + actual + "'";
79 message = opt_message + "(" + message + ")";
85 * True assertion tests that value == true.
86 * @param {!Object} value Actual object.
87 * @param {string} opt_message User message to print if the test fails.
89 TestSuite.prototype.assertTrue = function(value, opt_message)
91 this.assertEquals(true, !!value, opt_message);
96 * HasKey assertion tests that object has given key.
97 * @param {!Object} object
100 TestSuite.prototype.assertHasKey = function(object, key)
102 if (!object.hasOwnProperty(key))
103 this.fail("Expected object to contain key '" + key + "'");
108 * Contains assertion tests that string contains substring.
109 * @param {string} string Outer.
110 * @param {string} substring Inner.
112 TestSuite.prototype.assertContains = function(string, substring)
114 if (string.indexOf(substring) === -1)
115 this.fail("Expected to: '" + string + "' to contain '" + substring + "'");
120 * Takes control over execution.
122 TestSuite.prototype.takeControl = function()
124 this.controlTaken_ = true;
125 // Set up guard timer.
127 this.timerId_ = setTimeout(function() {
128 self.reportFailure_("Timeout exceeded: 20 sec");
134 * Releases control over execution.
136 TestSuite.prototype.releaseControl = function()
138 if (this.timerId_ !== -1) {
139 clearTimeout(this.timerId_);
147 * Async tests use this one to report that they are completed.
149 TestSuite.prototype.reportOk_ = function()
151 window.domAutomationController.send("[OK]");
156 * Async tests use this one to report failures.
158 TestSuite.prototype.reportFailure_ = function(error)
160 if (this.timerId_ !== -1) {
161 clearTimeout(this.timerId_);
164 window.domAutomationController.send("[FAILED] " + error);
169 * Runs all global functions starting with "test" as unit tests.
171 TestSuite.prototype.runTest = function(testName)
175 if (!this.controlTaken_)
178 this.reportFailure_(e);
184 * @param {string} panelName Name of the panel to show.
186 TestSuite.prototype.showPanel = function(panelName)
188 return WebInspector.inspectorView.showPanel(panelName);
193 * Overrides the method with specified name until it's called first time.
194 * @param {!Object} receiver An object whose method to override.
195 * @param {string} methodName Name of the method to override.
196 * @param {!Function} override A function that should be called right after the
197 * overridden method returns.
198 * @param {boolean} opt_sticky Whether restore original method after first run
201 TestSuite.prototype.addSniffer = function(receiver, methodName, override, opt_sticky)
203 var orig = receiver[methodName];
204 if (typeof orig !== "function")
205 this.fail("Cannot find method to override: " + methodName);
207 receiver[methodName] = function(var_args) {
209 var result = orig.apply(this, arguments);
212 receiver[methodName] = orig;
214 // In case of exception the override won't be called.
216 override.apply(this, arguments);
218 test.fail("Exception in overriden method '" + methodName + "': " + e);
225 * Waits for current throttler invocations, if any.
226 * @param {!WebInspector.Throttler} throttler
227 * @param {!function} callback
229 TestSuite.prototype.waitForThrottler = function(throttler, callback)
232 var scheduleShouldFail = true;
233 test.addSniffer(throttler, "schedule", onSchedule);
235 function hasSomethingScheduled()
237 return throttler._isRunningProcess || throttler._process;
240 function checkState()
242 if (!hasSomethingScheduled()) {
243 scheduleShouldFail = false;
248 test.addSniffer(throttler, "_processCompletedForTests", checkState);
251 function onSchedule()
253 if (scheduleShouldFail)
254 test.fail("Unexpected Throttler.schedule");
264 * Tests that scripts tab can be open and populated with inspected scripts.
266 TestSuite.prototype.testShowScriptsTab = function()
269 this.showPanel("sources").then(function() {
270 // There should be at least main page script.
271 this._waitUntilScriptsAreParsed(["debugger_test_page.html"],
273 test.releaseControl();
276 // Wait until all scripts are added to the debugger.
282 * Tests that scripts tab is populated with inspected scripts even if it
283 * hadn't been shown by the moment inspected paged refreshed.
284 * @see http://crbug.com/26312
286 TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh = function()
289 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, waitUntilScriptIsParsed);
291 this.showPanel("elements").then(function() {
292 // Reload inspected page. It will reset the debugger agent.
293 test.evaluateInConsole_("window.location.reload(true);", function(resultText) {});
296 function waitUntilScriptIsParsed()
298 WebInspector.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, waitUntilScriptIsParsed);
299 test.showPanel("sources").then(function() {
300 test._waitUntilScriptsAreParsed(["debugger_test_page.html"],
302 test.releaseControl();
307 // Wait until all scripts are added to the debugger.
313 * Tests that scripts list contains content scripts.
315 TestSuite.prototype.testContentScriptIsPresent = function()
318 this.showPanel("sources").then(function() {
319 test._waitUntilScriptsAreParsed(
320 ["page_with_content_script.html", "simple_content_script.js"],
322 test.releaseControl();
326 // Wait until all scripts are added to the debugger.
332 * Tests that scripts are not duplicaed on Scripts tab switch.
334 TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function()
338 // There should be two scripts: one for the main page and another
339 // one which is source of console API(see
340 // InjectedScript._ensureCommandLineAPIInstalled).
341 var expectedScriptsCount = 2;
342 var parsedScripts = [];
344 function switchToElementsTab() {
345 test.showPanel("elements").then(function() {
346 setTimeout(switchToScriptsTab, 0);
350 function switchToScriptsTab() {
351 test.showPanel("sources").then(function() {
352 setTimeout(checkScriptsPanel, 0);
356 function checkScriptsPanel() {
357 test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html"]), "Some scripts are missing.");
359 test.releaseControl();
362 function checkNoDuplicates() {
363 var uiSourceCodes = test.nonAnonymousUISourceCodes_();
364 for (var i = 0; i < uiSourceCodes.length; i++) {
365 var scriptName = uiSourceCodes[i].url;
366 for (var j = i + 1; j < uiSourceCodes.length; j++)
367 test.assertTrue(scriptName !== uiSourceCodes[j].url, "Found script duplicates: " + test.uiSourceCodesToString_(uiSourceCodes));
371 this.showPanel("sources").then(function() {
372 test._waitUntilScriptsAreParsed(
373 ["debugger_test_page.html"],
376 setTimeout(switchToElementsTab, 0);
380 // Wait until all scripts are added to the debugger.
385 // Tests that debugger works correctly if pause event occurs when DevTools
386 // frontend is being loaded.
387 TestSuite.prototype.testPauseWhenLoadingDevTools = function()
389 if (WebInspector.debuggerModel.debuggerPausedDetails)
392 this.showPanel("sources").then(function() {
393 // Script execution can already be paused.
395 this._waitForScriptPause(this.releaseControl.bind(this));
402 // Tests that pressing "Pause" will pause script execution if the script
403 // is already running.
404 TestSuite.prototype.testPauseWhenScriptIsRunning = function()
406 this.showPanel("sources").then(function() {
407 this.evaluateInConsole_(
408 'setTimeout("handleClick()", 0)',
409 didEvaluateInConsole.bind(this));
412 function didEvaluateInConsole(resultText) {
413 this.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText);
414 // Wait for some time to make sure that inspected page is running the
416 setTimeout(testScriptPause.bind(this), 300);
419 function testScriptPause() {
420 // The script should be in infinite loop. Click "Pause" button to
421 // pause it and wait for the result.
422 WebInspector.panels.sources._pauseButton.element.click();
424 this._waitForScriptPause(this.releaseControl.bind(this));
432 * Tests network size.
434 TestSuite.prototype.testNetworkSize = function()
438 function finishResource(resource, finishTime)
440 test.assertEquals(219, resource.transferSize, "Incorrect total encoded data length");
441 test.assertEquals(25, resource.resourceSize, "Incorrect total data length");
442 test.releaseControl();
445 this.addSniffer(WebInspector.NetworkDispatcher.prototype, "_finishNetworkRequest", finishResource);
447 // Reload inspected page to sniff network events
448 test.evaluateInConsole_("window.location.reload(true);", function(resultText) {});
455 * Tests network sync size.
457 TestSuite.prototype.testNetworkSyncSize = function()
461 function finishResource(resource, finishTime)
463 test.assertEquals(219, resource.transferSize, "Incorrect total encoded data length");
464 test.assertEquals(25, resource.resourceSize, "Incorrect total data length");
465 test.releaseControl();
468 this.addSniffer(WebInspector.NetworkDispatcher.prototype, "_finishNetworkRequest", finishResource);
470 // Send synchronous XHR to sniff network events
471 test.evaluateInConsole_("var xhr = new XMLHttpRequest(); xhr.open(\"GET\", \"chunked\", false); xhr.send(null);", function() {});
478 * Tests network raw headers text.
480 TestSuite.prototype.testNetworkRawHeadersText = function()
484 function finishResource(resource, finishTime)
486 if (!resource.responseHeadersText)
487 test.fail("Failure: resource does not have response headers text");
488 test.assertEquals(164, resource.responseHeadersText.length, "Incorrect response headers text length");
489 test.releaseControl();
492 this.addSniffer(WebInspector.NetworkDispatcher.prototype, "_finishNetworkRequest", finishResource);
494 // Reload inspected page to sniff network events
495 test.evaluateInConsole_("window.location.reload(true);", function(resultText) {});
502 * Tests network timing.
504 TestSuite.prototype.testNetworkTiming = function()
508 function finishResource(resource, finishTime)
510 // Setting relaxed expectations to reduce flakiness.
511 // Server sends headers after 100ms, then sends data during another 100ms.
512 // We expect these times to be measured at least as 70ms.
513 test.assertTrue(resource.timing.receiveHeadersEnd - resource.timing.connectStart >= 70,
514 "Time between receiveHeadersEnd and connectStart should be >=70ms, but was " +
515 "receiveHeadersEnd=" + resource.timing.receiveHeadersEnd + ", connectStart=" + resource.timing.connectStart + ".");
516 test.assertTrue(resource.responseReceivedTime - resource.startTime >= 0.07,
517 "Time between responseReceivedTime and startTime should be >=0.07s, but was " +
518 "responseReceivedTime=" + resource.responseReceivedTime + ", startTime=" + resource.startTime + ".");
519 test.assertTrue(resource.endTime - resource.startTime >= 0.14,
520 "Time between endTime and startTime should be >=0.14s, but was " +
521 "endtime=" + resource.endTime + ", startTime=" + resource.startTime + ".");
523 test.releaseControl();
526 this.addSniffer(WebInspector.NetworkDispatcher.prototype, "_finishNetworkRequest", finishResource);
528 // Reload inspected page to sniff network events
529 test.evaluateInConsole_("window.location.reload(true);", function(resultText) {});
535 TestSuite.prototype.testConsoleOnNavigateBack = function()
537 if (WebInspector.multitargetConsoleModel.messages().length === 1)
538 firstConsoleMessageReceived.call(this);
540 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, firstConsoleMessageReceived, this);
542 function firstConsoleMessageReceived() {
543 WebInspector.multitargetConsoleModel.removeEventListener(WebInspector.ConsoleModel.Events.MessageAdded, firstConsoleMessageReceived, this);
544 this.evaluateInConsole_("clickLink();", didClickLink.bind(this));
547 function didClickLink() {
548 // Check that there are no new messages(command is not a message).
549 this.assertEquals(3, WebInspector.multitargetConsoleModel.messages().length);
550 this.evaluateInConsole_("history.back();", didNavigateBack.bind(this));
553 function didNavigateBack()
555 // Make sure navigation completed and possible console messages were pushed.
556 this.evaluateInConsole_("void 0;", didCompleteNavigation.bind(this));
559 function didCompleteNavigation() {
560 this.assertEquals(7, WebInspector.multitargetConsoleModel.messages().length);
561 this.releaseControl();
567 TestSuite.prototype.testReattachAfterCrash = function()
569 PageAgent.navigate("about:crash");
570 PageAgent.navigate("about:blank");
571 WebInspector.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.ExecutionContextCreated, this.releaseControl, this);
575 TestSuite.prototype.testSharedWorker = function()
577 function didEvaluateInConsole(resultText) {
578 this.assertEquals("2011", resultText);
579 this.releaseControl();
581 this.evaluateInConsole_("globalVar", didEvaluateInConsole.bind(this));
586 TestSuite.prototype.testPauseInSharedWorkerInitialization1 = function()
588 // Make sure the worker is loaded.
591 return WebInspector.targetManager.targets().length == 2;
597 this.addSniffer(WebInspector.TargetManager.prototype, "addTarget", targetAdded.bind(this));
599 function targetAdded()
602 this.releaseControl();
605 this.addSniffer(WebInspector.TargetManager.prototype, "addTarget", targetAdded.bind(this));
609 TestSuite.prototype.testPauseInSharedWorkerInitialization2 = function()
611 if (WebInspector.debuggerModel.isPaused())
613 this._waitForScriptPause(this.releaseControl.bind(this));
617 TestSuite.prototype.enableTouchEmulation = function()
619 WebInspector.targetManager.mainTarget().domModel.emulateTouchEventObjects(true);
623 // Regression test for crbug.com/370035.
624 TestSuite.prototype.testDeviceMetricsOverrides = function()
626 const dumpPageMetrics = function()
628 return JSON.stringify({
629 width: window.innerWidth,
630 height: window.innerHeight,
631 deviceScaleFactor: window.devicePixelRatio
637 function testOverrides(params, metrics, callback)
639 PageAgent.invoke_setDeviceMetricsOverride(params, getMetrics);
641 function getMetrics()
643 test.evaluateInConsole_("(" + dumpPageMetrics.toString() + ")()", checkMetrics);
646 function checkMetrics(consoleResult)
648 test.assertEquals('"' + JSON.stringify(metrics) + '"', consoleResult, "Wrong metrics for params: " + JSON.stringify(params));
655 testOverrides({width: 1200, height: 1000, deviceScaleFactor: 1, mobile: false, fitWindow: true}, {width: 1200, height: 1000, deviceScaleFactor: 1}, step2);
660 testOverrides({width: 1200, height: 1000, deviceScaleFactor: 1, mobile: false, fitWindow: false}, {width: 1200, height: 1000, deviceScaleFactor: 1}, step3);
665 testOverrides({width: 1200, height: 1000, deviceScaleFactor: 3, mobile: false, fitWindow: true}, {width: 1200, height: 1000, deviceScaleFactor: 3}, step4);
670 testOverrides({width: 1200, height: 1000, deviceScaleFactor: 3, mobile: false, fitWindow: false}, {width: 1200, height: 1000, deviceScaleFactor: 3}, finish);
675 test.releaseControl();
678 WebInspector.overridesSupport._deviceMetricsChangedListenerMuted = true;
680 this.waitForThrottler(WebInspector.overridesSupport._deviceMetricsThrottler, step1);
683 TestSuite.prototype.waitForTestResultsInConsole = function()
685 var messages = WebInspector.multitargetConsoleModel.messages();
686 for (var i = 0; i < messages.length; ++i) {
687 var text = messages[i].messageText;
690 else if (/^FAIL/.test(text))
691 this.fail(text); // This will throw.
693 // Neither PASS nor FAIL, so wait for more messages.
694 function onConsoleMessage(event)
696 var text = event.data.messageText;
698 this.releaseControl();
699 else if (/^FAIL/.test(text))
703 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage, this);
707 TestSuite.prototype.checkLogAndErrorMessages = function()
709 var messages = WebInspector.multitargetConsoleModel.messages();
711 var matchesCount = 0;
712 function validMessage(message)
714 if (message.text === "log" && message.level === WebInspector.ConsoleMessage.MessageLevel.Log) {
719 if (message.text === "error" && message.level === WebInspector.ConsoleMessage.MessageLevel.Error) {
726 for (var i = 0; i < messages.length; ++i) {
727 if (validMessage(messages[i]))
729 this.fail(messages[i].text + ":" + messages[i].level); // This will throw.
732 if (matchesCount === 2)
735 // Wait for more messages.
736 function onConsoleMessage(event)
738 var message = event.data;
739 if (validMessage(message)) {
740 if (matchesCount === 2) {
741 this.releaseControl();
745 this.fail(message.text + ":" + messages[i].level);
748 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage, this);
753 * Serializes array of uiSourceCodes to string.
754 * @param {!Array.<!WebInspectorUISourceCode>} uiSourceCodes
757 TestSuite.prototype.uiSourceCodesToString_ = function(uiSourceCodes)
760 for (var i = 0; i < uiSourceCodes.length; i++)
761 names.push('"' + uiSourceCodes[i].url + '"');
762 return names.join(",");
767 * Returns all loaded non anonymous uiSourceCodes.
768 * @return {!Array.<!WebInspectorUISourceCode>}
770 TestSuite.prototype.nonAnonymousUISourceCodes_ = function()
772 function filterOutAnonymous(uiSourceCode)
774 return !!uiSourceCode.url;
777 function filterOutService(uiSourceCode)
779 return !uiSourceCode.project().isServiceProject();
782 var uiSourceCodes = WebInspector.workspace.uiSourceCodes();
783 uiSourceCodes = uiSourceCodes.filter(filterOutService);
784 return uiSourceCodes.filter(filterOutAnonymous);
789 * Evaluates the code in the console as if user typed it manually and invokes
790 * the callback when the result message is received and added to the console.
791 * @param {string} code
792 * @param {function(string)} callback
794 TestSuite.prototype.evaluateInConsole_ = function(code, callback)
796 function innerEvaluate()
798 WebInspector.context.removeFlavorChangeListener(WebInspector.ExecutionContext, showConsoleAndEvaluate, this);
799 var consoleView = WebInspector.ConsolePanel._view();
800 consoleView._prompt.text = code;
801 consoleView._promptElement.dispatchEvent(TestSuite.createKeyEvent("Enter"));
803 this.addSniffer(WebInspector.ConsoleView.prototype, "_consoleMessageAddedForTest",
804 function(viewMessage) {
805 callback(viewMessage.toMessageElement().textContent);
809 function showConsoleAndEvaluate()
811 WebInspector.console.showPromise().then(innerEvaluate.bind(this));
814 if (!WebInspector.context.flavor(WebInspector.ExecutionContext)) {
815 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, showConsoleAndEvaluate, this);
818 showConsoleAndEvaluate.call(this);
822 * Checks that all expected scripts are present in the scripts list
823 * in the Scripts panel.
824 * @param {!Array.<string>} expected Regular expressions describing
825 * expected script names.
826 * @return {boolean} Whether all the scripts are in "scripts-files" select
829 TestSuite.prototype._scriptsAreParsed = function(expected)
831 var uiSourceCodes = this.nonAnonymousUISourceCodes_();
832 // Check that at least all the expected scripts are present.
833 var missing = expected.slice(0);
834 for (var i = 0; i < uiSourceCodes.length; ++i) {
835 for (var j = 0; j < missing.length; ++j) {
836 if (uiSourceCodes[i].name().search(missing[j]) !== -1) {
837 missing.splice(j, 1);
842 return missing.length === 0;
847 * Waits for script pause, checks expectations, and invokes the callback.
848 * @param {function():void} callback
850 TestSuite.prototype._waitForScriptPause = function(callback)
852 this.addSniffer(WebInspector.DebuggerModel.prototype, "_pausedScript", callback);
857 * Waits until all the scripts are parsed and asynchronously executes the code
858 * in the inspected page.
860 TestSuite.prototype._executeCodeWhenScriptsAreParsed = function(code, expectedScripts)
864 function executeFunctionInInspectedPage() {
865 // Since breakpoints are ignored in evals' calculate() function is
866 // execute after zero-timeout so that the breakpoint is hit.
867 test.evaluateInConsole_(
868 'setTimeout("' + code + '" , 0)',
869 function(resultText) {
870 test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText + ". Code: " + code);
874 test._waitUntilScriptsAreParsed(expectedScripts, executeFunctionInInspectedPage);
879 * Waits until all the scripts are parsed and invokes the callback.
881 TestSuite.prototype._waitUntilScriptsAreParsed = function(expectedScripts, callback)
885 function waitForAllScripts() {
886 if (test._scriptsAreParsed(expectedScripts))
889 test.addSniffer(WebInspector.panels.sources.sourcesView(), "_addUISourceCode", waitForAllScripts);
897 * Key event with given key identifier.
899 TestSuite.createKeyEvent = function(keyIdentifier)
901 var evt = document.createEvent("KeyboardEvent");
902 evt.initKeyboardEvent("keydown", true /* can bubble */, true /* can cancel */, null /* view */, keyIdentifier, "");
908 * Test runner for the test suite.
914 * Run each test from the test suit on a fresh instance of the suite.
916 uiTests.runAllTests = function()
918 // For debugging purposes.
919 for (var name in TestSuite.prototype) {
920 if (name.substring(0, 4) === "test" && typeof TestSuite.prototype[name] === "function")
921 uiTests.runTest(name);
927 * Run specified test on a fresh instance of the test suite.
928 * @param {string} name Name of a test method from TestSuite class.
930 uiTests.runTest = function(name)
932 if (uiTests._populatedInterface)
933 new TestSuite().runTest(name);
935 uiTests._pendingTestName = name;
942 uiTests._populatedInterface = true;
943 var name = uiTests._pendingTestName;
944 delete uiTests._pendingTestName;
946 new TestSuite().runTest(name);
949 WebInspector.notifications.addEventListener(WebInspector.NotificationService.Events.InspectorAgentEnabledForTests, runTests);