text: // 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 the async call stacks and framework black-boxing features working together.\n`);
    await TestRunner.loadModule('sources_test_runner');
    await TestRunner.showPanel('sources');
    await TestRunner.loadHTML(`
        <input type="button" onclick="testFunction()" value="Test">
      `);
    await TestRunner.addScriptTag('../debugger/resources/framework.js');
    await TestRunner.evaluateInPagePromise(`
        window.callbackFromFramework = function(next)
        {
            return next();
        }
  
        function testFunction()
        {
            setTimeout(timeout1, 0);
        }
  
        function timeout1()
        {
            Framework.safeRun(Framework.empty, callback1);
        }
  
        function callback1()
        {
            Framework.doSomeAsyncChainCalls(callback2);
        }
  
        function callback2()
        {
            debugger;
        }
    `);
  
    var frameworkRegexString = '/framework\\.js$';
    var maxAsyncCallStackDepth = 8;
  
    Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString);
  
    SourcesTestRunner.setQuiet(true);
    SourcesTestRunner.startDebuggerTest(step1);
  
    function step1() {
      TestRunner.DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth).then(step2);
    }
  
    function step2() {
      SourcesTestRunner.runTestFunctionAndWaitUntilPaused(didPause);
    }
  
    async function didPause(callFrames, reason, breakpointIds, asyncStackTrace) {
      await SourcesTestRunner.captureStackTrace(callFrames, asyncStackTrace, {'dropFrameworkCallFrames': false});
      TestRunner.addResult('\nPrinting visible call stack:');
      await SourcesTestRunner.captureStackTrace(callFrames, asyncStackTrace, {'dropFrameworkCallFrames': true});
      SourcesTestRunner.completeDebuggerTest();
    }
  })();
  