| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 482459e commit 0b564a6
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,54 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + common.skipIfInspectorDisabled(); | ||
| 5 | + | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const childProcess = require('child_process'); | ||
| 8 | + const http = require('http'); | ||
| 9 | + | ||
| 10 | + let port; | ||
| 11 | + | ||
| 12 | + const server = http.createServer(common.mustCall((req, res) => { | ||
| 13 | + if (req.url.startsWith('/json')) { | ||
| 14 | + res.writeHead(200); | ||
| 15 | + res.end(`[ { | ||
| 16 | + "description": "", | ||
| 17 | + "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:${port}/devtools/page/DAB7FB6187B554E10B0BD18821265734", | ||
| 18 | + "cid": "DAB7FB6187B554E10B0BD18821265734", | ||
| 19 | + "title": "Fhqwhgads", | ||
| 20 | + "type": "page", | ||
| 21 | + "url": "https://www.example.com/", | ||
| 22 | + "webSocketDebuggerUrl": "ws://localhost:${port}/devtools/page/DAB7FB6187B554E10B0BD18821265734" | ||
| 23 | + } ]`); | ||
| 24 | + } else { | ||
| 25 | + res.setHeader('Upgrade', 'websocket'); | ||
| 26 | + res.setHeader('Connection', 'Upgrade'); | ||
| 27 | + res.setHeader('Sec-WebSocket-Accept', 'fhqwhgads'); | ||
| 28 | + res.setHeader('Sec-WebSocket-Protocol', 'chat'); | ||
| 29 | + res.writeHead(101); | ||
| 30 | + res.end(); | ||
| 31 | + } | ||
| 32 | + }, 2)).listen(0, common.mustCall(() => { | ||
| 33 | + port = server.address().port; | ||
| 34 | + const proc = | ||
| 35 | + childProcess.spawn(process.execPath, ['inspect', `localhost:${port}`]); | ||
| 36 | + | ||
| 37 | + let stdout = ''; | ||
| 38 | + proc.stdout.on('data', (data) => { | ||
| 39 | + stdout += data.toString(); | ||
| 40 | + assert.doesNotMatch(stdout, /\bok\b/); | ||
| 41 | + }); | ||
| 42 | + | ||
| 43 | + let stderr = ''; | ||
| 44 | + proc.stderr.on('data', (data) => { | ||
| 45 | + stderr += data.toString(); | ||
| 46 | + }); | ||
| 47 | + | ||
| 48 | + proc.on('exit', common.mustCall((code, signal) => { | ||
| 49 | + assert.match(stderr, /\bWebSocket secret mismatch\b/); | ||
| 50 | + assert.notStrictEqual(code, 0); | ||
| 51 | + assert.strictEqual(signal, null); | ||
| 52 | + server.close(); | ||
| 53 | + })); | ||
| 54 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments