Simplify setting up Chrome debugging sessionHost
This commit is contained in:
parent
00b19d95b8
commit
8d73a8e985
|
@ -45,15 +45,8 @@ export function registerTypeConverter(type, handler) {
|
|||
}
|
||||
|
||||
export function createSession(host) {
|
||||
let oldHost = sessionHost;
|
||||
|
||||
try {
|
||||
sessionHost = host;
|
||||
sessionId = sendRequest('create_session');
|
||||
} catch (e) {
|
||||
sessionHost = oldHost;
|
||||
throw e;
|
||||
}
|
||||
sessionId = sendRequest('create_session', null, host);
|
||||
sessionHost = host;
|
||||
|
||||
return sessionId;
|
||||
}
|
||||
|
@ -165,8 +158,8 @@ function deserializeDict(realmId, info) {
|
|||
return object;
|
||||
}
|
||||
|
||||
function sendRequest(command, data) {
|
||||
if (!sessionHost) {
|
||||
function sendRequest(command, data, host = sessionHost) {
|
||||
if (!host) {
|
||||
throw new Error('Must first create RPC session with a valid host');
|
||||
}
|
||||
|
||||
|
@ -174,7 +167,7 @@ function sendRequest(command, data) {
|
|||
|
||||
let body = JSON.stringify(data);
|
||||
let request = new XMLHttpRequest();
|
||||
let url = 'http://' + sessionHost + '/' + command;
|
||||
let url = 'http://' + host + '/' + command;
|
||||
|
||||
request.open('POST', url, false);
|
||||
request.send(body);
|
||||
|
|
Loading…
Reference in New Issue