Skip to content

Commit

Permalink
test: Fix broken test cases from nodejs#18194
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Jan 22, 2018
1 parent e7ff00d commit b76ea18
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/common/inspector-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ const fs = require('fs');
const http = require('http');
const fixtures = require('../common/fixtures');
const { spawn } = require('child_process');
const { URL, parse: parseURL } = require('url');
const url = require('url');
const { getURLFromFilePath } = require('internal/url');
const path = require('path');

const _MAINSCRIPT = fixtures.path('loop.js');
const DEBUG = false;
Expand Down Expand Up @@ -173,7 +172,9 @@ class InspectorSession {
const scriptId = script['scriptId'];
const url = script['url'];
this._scriptsIdsByUrl.set(scriptId, url);
if (getURLFromFilePath(url).toString() === this.scriptURL().toString()) {
if (this.scriptURL().toString() ===
url.startsWith('file:') ? url :
getURLFromFilePath(url).toString()) {
this.mainScriptId = scriptId;
}
}
Expand Down Expand Up @@ -246,8 +247,7 @@ class InspectorSession {
const callFrame = message['params']['callFrames'][0];
const location = callFrame['location'];
const scriptPath = this._scriptsIdsByUrl.get(location['scriptId']);
assert(scriptPath.toString() === expectedScriptPath.toString(),
`${scriptPath} !== ${expectedScriptPath}`);
assert.strictEqual(scriptPath.toString(), expectedScriptPath.toString());
assert.strictEqual(line, location['lineNumber']);
return true;
}
Expand Down Expand Up @@ -306,6 +306,9 @@ class InspectorSession {
}

scriptURL() {
const scriptPath = this.scriptPath();
if (scriptPath.startsWith('file:'))
return scriptPath;
return getURLFromFilePath(this.scriptPath());
}
}
Expand Down Expand Up @@ -394,7 +397,7 @@ class NodeInstance {
const port = await this.portPromise;
return http.get({
port,
path: parseURL(devtoolsUrl).path,
path: url.parse(devtoolsUrl).path,
headers: {
'Connection': 'Upgrade',
'Upgrade': 'websocket',
Expand Down

0 comments on commit b76ea18

Please sign in to comment.