| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c231130 commit 2e7b078
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -681,17 +681,20 @@ bool AgentImpl::RespondToGet(InspectorSocket* socket, const std::string& path) { | |||
| 681 | 681 | ||
| 682 | 682 | if (match_path_segment(command, "list") || command[0] == '\0') { | |
| 683 | 683 | SendTargentsListResponse(socket); | |
| 684 | + return true; | ||
| 684 | 685 | } else if (match_path_segment(command, "protocol")) { | |
| 685 | 686 | SendProtocolJson(socket); | |
| 687 | + return true; | ||
| 686 | 688 | } else if (match_path_segment(command, "version")) { | |
| 687 | 689 | SendVersionResponse(socket); | |
| 688 | - } else { | ||
| 689 | - const char* pid = match_path_segment(command, "activate"); | ||
| 690 | + return true; | ||
| 691 | + } else if (const char* pid = match_path_segment(command, "activate")) { | ||
| 690 | 692 | if (pid != id_) | |
| 691 | 693 | return false; | |
| 692 | 694 | SendHttpResponse(socket, "Target activated"); | |
| 695 | + return true; | ||
| 693 | 696 | } | |
| 694 | - return true; | ||
| 697 | + return false; | ||
| 695 | 698 | } | |
| 696 | 699 | ||
| 697 | 700 | // static | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,7 +86,17 @@ function checkHttpResponse(port, path, callback) { | |||
| 86 | 86 | res.setEncoding('utf8'); | |
| 87 | 87 | res | |
| 88 | 88 | .on('data', (data) => response += data.toString()) | |
| 89 | - .on('end', () => callback(JSON.parse(response))); | ||
| 89 | + .on('end', () => { | ||
| 90 | + let err = null; | ||
| 91 | + let json = undefined; | ||
| 92 | + try { | ||
| 93 | + json = JSON.parse(response); | ||
| 94 | + } catch (e) { | ||
| 95 | + err = e; | ||
| 96 | + err.response = response; | ||
| 97 | + } | ||
| 98 | + callback(err, json); | ||
| 99 | + }); | ||
| 90 | 100 | }); | |
| 91 | 101 | } | |
| 92 | 102 | ||
@@ -284,8 +294,8 @@ TestSession.prototype.disconnect = function(childDone) { | |||
| 284 | 294 | ||
| 285 | 295 | TestSession.prototype.testHttpResponse = function(path, check) { | |
| 286 | 296 | return this.enqueue((callback) => | |
| 287 | - checkHttpResponse(this.harness_.port, path, (response) => { | ||
| 288 | - check.call(this, response); | ||
| 297 | + checkHttpResponse(this.harness_.port, path, (err, response) => { | ||
| 298 | + check.call(this, err, response); | ||
| 289 | 299 | callback(); | |
| 290 | 300 | })); | |
| 291 | 301 | }; | |
@@ -352,8 +362,8 @@ Harness.prototype.enqueue_ = function(task) { | |||
| 352 | 362 | ||
| 353 | 363 | Harness.prototype.testHttpResponse = function(path, check) { | |
| 354 | 364 | return this.enqueue_((doneCallback) => { | |
| 355 | - checkHttpResponse(this.port, path, (response) => { | ||
| 356 | - check.call(this, response); | ||
| 365 | + checkHttpResponse(this.port, path, (err, response) => { | ||
| 366 | + check.call(this, err, response); | ||
| 357 | 367 | doneCallback(); | |
| 358 | 368 | }); | |
| 359 | 369 | }); | |
@@ -393,7 +403,8 @@ Harness.prototype.wsHandshake = function(devtoolsUrl, tests, readyCallback) { | |||
| 393 | 403 | ||
| 394 | 404 | Harness.prototype.runFrontendSession = function(tests) { | |
| 395 | 405 | return this.enqueue_((callback) => { | |
| 396 | - checkHttpResponse(this.port, '/json/list', (response) => { | ||
| 406 | + checkHttpResponse(this.port, '/json/list', (err, response) => { | ||
| 407 | + assert.ifError(err); | ||
| 397 | 408 | this.wsHandshake(response[0]['webSocketDebuggerUrl'], tests, callback); | |
| 398 | 409 | }); | |
| 399 | 410 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,14 +5,26 @@ const helper = require('./inspector-helper.js'); | |||
| 5 | 5 | ||
| 6 | 6 | let scopeId; | |
| 7 | 7 | ||
| 8 | - function checkListResponse(response) { | ||
| 8 | + function checkListResponse(err, response) { | ||
| 9 | + assert.ifError(err); | ||
| 9 | 10 | assert.strictEqual(1, response.length); | |
| 10 | 11 | assert.ok(response[0]['devtoolsFrontendUrl']); | |
| 11 | 12 | assert.ok( | |
| 12 | 13 | response[0]['webSocketDebuggerUrl'] | |
| 13 | 14 | .match(/ws:\/\/localhost:\d+\/[0-9A-Fa-f]{8}-/)); | |
| 14 | 15 | } | |
| 15 | 16 | ||
| 17 | + function checkVersion(err, response) { | ||
| 18 | + assert.ifError(err); | ||
| 19 | + assert.ok(response); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + function checkBadPath(err, response) { | ||
| 23 | + assert(err instanceof SyntaxError); | ||
| 24 | + assert(/Unexpected token/.test(err.message)); | ||
| 25 | + assert(/WebSockets request was expected/.test(err.response)); | ||
| 26 | + } | ||
| 27 | + | ||
| 16 | 28 | function expectMainScriptSource(result) { | |
| 17 | 29 | const expected = helper.mainScriptSource(); | |
| 18 | 30 | const source = result['scriptSource']; | |
@@ -153,7 +165,8 @@ function testInspectScope(session) { | |||
| 153 | 165 | } | |
| 154 | 166 | ||
| 155 | 167 | function testNoUrlsWhenConnected(session) { | |
| 156 | - session.testHttpResponse('/json/list', (response) => { | ||
| 168 | + session.testHttpResponse('/json/list', (err, response) => { | ||
| 169 | + assert.ifError(err); | ||
| 157 | 170 | assert.strictEqual(1, response.length); | |
| 158 | 171 | assert.ok(!response[0].hasOwnProperty('devtoolsFrontendUrl')); | |
| 159 | 172 | assert.ok(!response[0].hasOwnProperty('webSocketDebuggerUrl')); | |
@@ -171,7 +184,10 @@ function runTests(harness) { | |||
| 171 | 184 | harness | |
| 172 | 185 | .testHttpResponse('/json', checkListResponse) | |
| 173 | 186 | .testHttpResponse('/json/list', checkListResponse) | |
| 174 | - .testHttpResponse('/json/version', assert.ok) | ||
| 187 | + .testHttpResponse('/json/version', checkVersion) | ||
| 188 | + .testHttpResponse('/json/activate', checkBadPath) | ||
| 189 | + .testHttpResponse('/json/activate/boom', checkBadPath) | ||
| 190 | + .testHttpResponse('/json/badpath', checkBadPath) | ||
| 175 | 191 | .runFrontendSession([ | |
| 176 | 192 | testNoUrlsWhenConnected, | |
| 177 | 193 | testBreakpointOnStart, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments