| // Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| (async function() { |
| TestRunner.addResult(`Tests traceCalls(fn) console command.\n`); |
| await TestRunner.loadModule('sources_test_runner'); |
| await TestRunner.loadModule('console_test_runner'); |
| await TestRunner.showPanel('sources'); |
| await TestRunner.evaluateInPagePromise(` |
| function simpleTestFunction() |
| { |
| return 0; |
| } |
| `); |
| await TestRunner.evaluateInPagePromise(` |
| function simpleTestFunction2() |
| { |
| return simpleTestFunction3(); |
| } |
| |
| function simpleTestFunction3() |
| { |
| return 0; |
| } |
| `); |
| |
| var currentSourceFrame; |
| SourcesTestRunner.setQuiet(true); |
| SourcesTestRunner.runDebuggerTestSuite([ |
| function testSimpleMonitor(next) { |
| monitorAndRun(next, 'simpleTestFunction', 'simpleTestFunction();'); |
| }, |
| |
| function testSimpleMonitorWith1Arg(next) { |
| monitorAndRun(next, 'simpleTestFunction', 'simpleTestFunction(1);'); |
| }, |
| |
| function testSimpleMonitorWithManyArgs(next) { |
| monitorAndRun(next, 'simpleTestFunction', 'simpleTestFunction(1, 2, 3, 4 ,5);'); |
| }, |
| |
| function testSimpleUnmonitor(next) { |
| ConsoleTestRunner.evaluateInConsole('monitor(simpleTestFunction2)'); |
| ConsoleTestRunner.evaluateInConsole('unmonitor(simpleTestFunction2)'); |
| monitorAndRun(next, 'simpleTestFunction3', 'simpleTestFunction2();'); |
| }, |
| |
| function testUnmonitorFuntionNotMonitored(next) { |
| ConsoleTestRunner.evaluateInConsole('monitor(simpleTestFunction)', next); |
| } |
| ]); |
| |
| function monitorAndRun(next, functionName, runCmd) { |
| ConsoleTestRunner.evaluateInConsole('monitor(' + functionName + ')'); |
| TestRunner.addResult('Start monitoring function.'); |
| |
| ConsoleTestRunner.evaluateInConsole('setTimeout(function() { ' + runCmd + ' }, 0)'); |
| TestRunner.addResult('Set timer for test function.'); |
| ConsoleTestRunner.waitUntilMessageReceived(didReceive); |
| |
| function didReceive(message) { |
| if (message.type === SDK.ConsoleMessage.MessageType.Result) { |
| ConsoleTestRunner.waitUntilMessageReceived(didReceive); |
| return; |
| } |
| |
| TestRunner.addResult('Console message received: ' + message.messageText); |
| ConsoleTestRunner.evaluateInConsole('unmonitor(' + functionName + ')'); |
| TestRunner.addResult('Stop monitoring.'); |
| next(); |
| } |
| } |
| })(); |