@@ -9,6 +9,7 @@ const httpProxy = require("http-proxy");
9
9
const Server = require ( "../../lib/Server" ) ;
10
10
const config = require ( "../fixtures/client-config/webpack.config" ) ;
11
11
const runBrowser = require ( "../helpers/run-browser" ) ;
12
+ const sessionSubscribe = require ( "../helpers/session-subscribe" ) ;
12
13
const port1 = require ( "../ports-map" ) . ipc ;
13
14
14
15
const webSocketServers = [ "ws" , "sockjs" ] ;
@@ -72,11 +73,19 @@ describe("web socket server URL", () => {
72
73
const webSocketRequests = [ ] ;
73
74
74
75
if ( webSocketServer === "ws" ) {
75
- const client = page . _client ;
76
+ const session = await page . target ( ) . createCDPSession ( ) ;
76
77
77
- client . on ( "Network.webSocketCreated" , ( test ) => {
78
+ session . on ( "Network.webSocketCreated" , ( test ) => {
78
79
webSocketRequests . push ( test ) ;
79
80
} ) ;
81
+
82
+ await session . send ( "Target.setAutoAttach" , {
83
+ autoAttach : true ,
84
+ flatten : true ,
85
+ waitForDebuggerOnStart : true ,
86
+ } ) ;
87
+
88
+ sessionSubscribe ( session ) ;
80
89
} else {
81
90
page . on ( "request" , ( request ) => {
82
91
if ( / \/ w s \/ / . test ( request . url ( ) ) ) {
@@ -168,11 +177,19 @@ describe("web socket server URL", () => {
168
177
const webSocketRequests = [ ] ;
169
178
170
179
if ( webSocketServer === "ws" ) {
171
- const client = page . _client ;
180
+ const session = await page . target ( ) . createCDPSession ( ) ;
172
181
173
- client . on ( "Network.webSocketCreated" , ( test ) => {
182
+ session . on ( "Network.webSocketCreated" , ( test ) => {
174
183
webSocketRequests . push ( test ) ;
175
184
} ) ;
185
+
186
+ await session . send ( "Target.setAutoAttach" , {
187
+ autoAttach : true ,
188
+ flatten : true ,
189
+ waitForDebuggerOnStart : true ,
190
+ } ) ;
191
+
192
+ sessionSubscribe ( session ) ;
176
193
} else {
177
194
page . on ( "request" , ( request ) => {
178
195
if ( / \/ w s \/ / . test ( request . url ( ) ) ) {
@@ -279,11 +296,19 @@ describe("web socket server URL", () => {
279
296
const webSocketRequests = [ ] ;
280
297
281
298
if ( webSocketServer === "ws" ) {
282
- const client = page . _client ;
299
+ const session = await page . target ( ) . createCDPSession ( ) ;
283
300
284
- client . on ( "Network.webSocketCreated" , ( test ) => {
301
+ session . on ( "Network.webSocketCreated" , ( test ) => {
285
302
webSocketRequests . push ( test ) ;
286
303
} ) ;
304
+
305
+ await session . send ( "Target.setAutoAttach" , {
306
+ autoAttach : true ,
307
+ flatten : true ,
308
+ waitForDebuggerOnStart : true ,
309
+ } ) ;
310
+
311
+ sessionSubscribe ( session ) ;
287
312
} else {
288
313
page . on ( "request" , ( request ) => {
289
314
if ( / \/ w s \/ / . test ( request . url ( ) ) ) {
0 commit comments