INNER CODE UNIT · JavaScript
Context
cyrus-and/chrome-har-capturer · lib/context.js:8
class Context {
constructor(options) {
this._cleanup = [];
this._options = options;
}
async create() {
const {host, port, cache} = this._options;
// fetch the browser version (since Chrome 62 the browser target URL is
// generated at runtime and can be obtained via the '/json/version'
// endpoint, fallback to '/devtools/browser' if not present)
const {webSocketDebuggerUrl} = await CDP.Version({host, port});
// connect to the browser target
const browser = await CDP({
host, port,
target: webSocketDebuggerUrl || BROWSER_TARGET,
local: true
});