summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/devtools/front_end/js_main/JsMain.js
blob: 59a109da11388438bf6d6aa1d878e95bd0b11b5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2018 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.

/**
 * @implements {Common.Runnable}
 */
JsMain.JsMain = class extends Common.Object {
  /**
   * @override
   */
  run() {
    Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSDirectly);
    const target = SDK.targetManager.createTarget(
        'main', Common.UIString('Main'), SDK.Target.Capability.JS, this._createMainConnection.bind(this), null, true /* isNodeJS */);
    target.runtimeAgent().runIfWaitingForDebugger();
    InspectorFrontendHost.connectionReady();
  }

  /**
   * @param {!Protocol.InspectorBackend.Connection.Params} params
   * @return {!Protocol.InspectorBackend.Connection}
   */
  _createMainConnection(params) {
    return SDK.createMainConnection(params, () => Components.TargetDetachedDialog.webSocketConnectionLost());
  }
};