Skip to content

Commit

Permalink
core(driver): add driver.wsEndpoint() (#3864)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish authored Nov 21, 2017
1 parent 407b1af commit 2182513
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lighthouse-core/gather/connections/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class Connection {
return Promise.reject(new Error('Not implemented'));
}


/**
* @return {!Promise<string>}
*/
wsEndpoint() {
return Promise.reject(new Error('Not implemented'));
}


/**
* Call protocol methods
* @param {!string} method
Expand Down
9 changes: 9 additions & 0 deletions lighthouse-core/gather/connections/cri.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ class CriConnection extends Connection {
});
}

/**
* @override
* @return {!Promise<string>}
*/
wsEndpoint() {
return this._runJsonCommand('version').then(response => response.webSocketDebuggerUrl);
}


/**
* @override
* @param {string} message
Expand Down
9 changes: 9 additions & 0 deletions lighthouse-core/gather/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ class Driver {
return this._connection.disconnect();
}

/**
* Get the browser WebSocket endpoint for devtools protocol clients like Puppeteer.
* Only works with WebSocket connection, not extension or devtools.
* @return {!Promise<string>}
*/
wsEndpoint() {
return this._connection.wsEndpoint();
}

/**
* Bind listeners for protocol events
* @param {!string} eventName
Expand Down

0 comments on commit 2182513

Please sign in to comment.