ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / test / smoke / src / areas / browserView / browserView.test.ts 594 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
import * as assert from 'assert' ;
import * as fs from 'fs' ;
import * as http from 'http' ;
import * as path from 'path' ;
import { fileURLToPath, pathToFileURL } from 'url' ;
import type { Page } from '@playwright/test' ;
import { Application, ApplicationOptions, Logger } from '../../../../automation' ;
import { getCopilotSmokeTestEnv, getMockLlmServerPath getMockLlmServerUrl installAllHandlers MockLlmServer preseedChatExtensionEnablement
browserCommandPrefix
logger Logger
sharedBrowserPageId
mockServer MockLlmServer
ScenarioBuilder registerScenario startServer
request
sharedBrowserPageId request
sharedBrowserPageId
sharedBrowserPageId
sharedBrowserPageId
request
sharedBrowserPageId request
sharedBrowserPageId
mockServer
captureRequests
message logger
logger
options
mediaOptions options
mediaOptions
extraEnv
mediaOptions extraEnv
mockServer userDataDir mediaOptions userDataDir
app
app userDataPath
app userDataPath mockServer
comment
openPages
requestCounts
server http Server
baseUrl
server http request response
requestUrl request url
count requestCounts requestUrl pathname
requestCounts requestUrl pathname count
response
response requestUrl pathname count
resolve reject
server reject
server
server reject
address server
address address
baseUrl
app app Application
pageClosePromises openPages
page page
page page
app workbench quickaccess
pageClosePromises
openPages
resolve reject server error error error
mockServer
app app Application
htmlPath path app workspacePathOrFolder
htmlUrl htmlPath
fs htmlPath
browserPage app code driver path htmlPath
app workbench quickaccess htmlPath path htmlPath
app workbench quickinput
openPages browserPage
browserPage hasText
urlDisplay app code driver currentPage
urlDisplay
assert
path urlDisplay
contentEditable urlDisplay
ariaReadonly urlDisplay
path htmlUrl
contentEditable
ariaReadonly
fs htmlPath force
app app Application
browserPage app openPages
workbenchPage app code driver currentPage
browserPage
browserPage
workbenchPage
workbenchPage
workbenchPage
browserPage
workbenchPage
browserPage
workbenchPage
app browserPage
historyPicker workbenchPage
historyPicker hasText
historyPicker hasText
historyPicker hasText
workbenchPage keyboard
previousCount requestCounts
workbenchPage
browserPage hasText previousCount
app app Application
browserPage app openPages
workbenchPage app code driver currentPage
modifier process platform
browserPage position x y
browserPage keyboard
findWidget workbenchPage
findInput findWidget
findInput
findInput
findWidget hasText
findInput
findWidget hasText
findInput
findWidget state
input browserPage
input
input
input
assert input
input
workbenchPage
workbenchPage keyboard
app app Application
browserPage app openPages
workbenchPage app code driver currentPage
browserPage
dialog workbenchPage
dialog hasText
dialog hasText
browserPage hasText
browserPage workbenchPage
permissionsPicker workbenchPage
permissionsPicker hasText
permissionsPicker hasText
workbenchPage keyboard
previousPermissionResult browserPage
browserPage
browserPage previous document textContent previous previousPermissionResult
assert browserPage
assert workbenchPage
app app Application
browserPage app openPages
workbenchPage app code driver currentPage
target browserPage
modifier process platform
target
browserPage keyboard
browserPage state
target
app workbench chat
workbenchPage hasText
target
browserPage keyboard
browserPage state
target
browserPage document activeElement
browserPage document textContent
browserPage keyboard comment
browserPage keyboard
assert browserPage
app workbench chat
app workbench chat comment
browserPage keyboard
browserPage state
chatInput workbenchPage
chatInput
workbenchPage keyboard process platform
workbenchPage keyboard
browserPage state
browserPage
browserPage workbenchPage
attachment workbenchPage hasText
image attachment
image
assert image element
image element HTMLImageElement
image naturalHeight image naturalWidth
app app Application
browserPage app openPages
workbenchPage app code driver currentPage
clickCount browserPage
shareButton workbenchPage
unshareButton workbenchPage
sharingDialog workbenchPage
shareButton
sharingDialog hasText
unshareButton
shareButton
sharingDialog hasText
sharingDialog hasText
unshareButton
app openPages
workbenchPage hasText
unshareButton
app workbench quickaccess
app workbench chat
app workbench chat
successToolResult mockServer
assert successToolResult
clickCount state
assert clickCount
unshareButton
shareButton
app workbench chat
errorToolResult mockServer
assert
pageMissing errorToolResult
clicks clickCount
pageMissing
clicks
app workbench chat
resharedToolResult mockServer
assert resharedToolResult
browserPage hasText
app app Application
lifecycleUrl
browserPage app lifecycleUrl openPages
workbenchPage app code driver currentPage
browserPage
browserPage
scrollPosition browserPage scrollY
assert scrollPosition
app workbench quickaccess path app workspacePathOrFolder
workbenchPage hasText
assert
value browserPage
scrollY browserPage scrollY
value
scrollY scrollPosition
childPage app code driver browserPage
openPages childPage
childPage
workbenchPage hasText
childPage
openPages childPage
workbenchPage hasText state
workbenchPage hasText
assert browserPage
app
openPages
restoredPage app code driver
openPages restoredPage
restoredPage
app code driver currentPage
app code driver currentPage lifecycleUrl
url
url
filePath path url
process platform filePath filePath
userDataDir mockServerUrl
userDataDir
settingsPath path userDataDir
fs path settingsPath recursive
fs settingsPath
mockServerUrl
mockServerUrl
options ApplicationOptions ApplicationOptions
options
extraArgs options extraArgs
app Application url openPages Set Page Page
workbenchPage app code driver currentPage
browserPage app code driver url
app workbench quickaccess keepOpen
addressInput workbenchPage
addressInput
addressInput url
addressInput
openPages browserPage
browserPage
workbenchPage url
browserPage
workbenchPage Page url
workbenchPage hasText url
workbenchPage Page title
workbenchPage hasText title
app Application browserPage Page command
browserPage position x y
app workbench quickaccess command keepOpen
browserPage Page workbenchPage Page label
browserPage position x y
dropdown workbenchPage
dropdown
workbenchPage
dropdown
item workbenchPage hasText label
item
item
workbenchPage
item
browserPage Page workbenchPage Page label
browserPage position x y
dropdown workbenchPage
dropdown
workbenchPage
dropdown
item workbenchPage hasText label
item
item
workbenchPage
item
result request
type
turns
kind
toolCalls
toolNamePattern
request
pageId request
selector
element
kind
chunks content result delayMs
request title
match request
match
match
mockServer MockLlmServer scenarioId
deadline Date
Date deadline
request mockServer
request body
toolResults request body scenarioId
toolResults length
toolResults toolResults length
resolve resolve
value scenarioId
value value
value
value item item scenarioId
candidate value Record
toolCallId candidate tool_call_id candidate call_id candidate tool_use_id
toolCallId toolCallId scenarioId
result candidate content candidate output
result result result
Object candidate item item scenarioId
route requestCount
route
title body
,
,
,
,
}
from
'../../utils'
;
const
=
'workbench.action.browser'
;
export
function
setup
(
:
)
:
void
{
describe
(
'Integrated Browser'
,
(
)
=>
{
let
:
string
|
undefined
;
let
:
;
before
(
async
function
(
)
{
const
{
,
,
}
=
require
(
getMockLlmServerPath
(
)
)
;
registerScenario
(
'text-only'
,
new
ScenarioBuilder
(
)
.
emit
(
'OK'
)
.
build
(
)
)
;
registerScenario
(
'browser-sharing-click-success'
,
browserClickScenario
(
'SUCCESS'
,
=>
{
=
findBrowserPageId
(
,
'Browser Smoke Sharing'
)
;
return
;
}
)
)
;
registerScenario
(
'browser-sharing-click-error'
,
browserClickScenario
(
'ERROR'
,
(
)
=>
{
if
(
!
)
{
throw
new
Error
(
'Shared browser page ID was not captured'
)
;
}
return
;
}
)
)
;
registerScenario
(
'browser-sharing-click-reshared'
,
browserClickScenario
(
'RESHARED'
,
=>
{
=
findBrowserPageId
(
,
'Browser Smoke Sharing'
)
;
return
;
}
)
)
;
=
await
startServer
(
0
,
{
:
true
,
logger
:
(
:
string
)
=>
.
log
(
` [mock-llm] ${ message} `
)
}
)
;
}
)
;
installAllHandlers
(
,
=>
{
const
=
withFakeMediaDevice
(
)
;
return
{
...
,
:
{
...
(
.
??
{
}
)
,
...
getCopilotSmokeTestEnv
(
,
{
:
.
}
)
}
}
;
}
,
async
=>
{
await
preseedChatExtensionEnablement
(
.
)
;
preseedSettings
(
.
,
getMockLlmServerUrl
(
)
)
;
}
)
;
const
=
'Smoke-test-comment'
;
const
=
new
Set< Page>
(
)
;
const
=
new
Map< string , number >
(
)
;
let
:
.
;
let
:
string
;
before
(
async
function
(
)
{
=
.
createServer
(
(
,
)
=>
{
const
=
new
URL
(
.
??
'/'
,
'http://127.0.0.1'
)
;
const
=
(
.
get
(
.
)
??
0
)
+
1
;
.
set
(
.
,
)
;
.
writeHead
(
200
,
{
'Content-Type'
:
'text/html; charset=utf-8'
,
'Cache-Control'
:
'no-store'
}
)
;
.
end
(
pageForRoute
(
.
,
)
)
;
}
)
;
await
new
Promise < void >
(
(
,
)
=>
{
.
once
(
'error'
,
)
;
.
listen
(
0
,
'127.0.0.1'
,
(
)
=>
{
.
off
(
'error'
,
)
;
resolve
(
)
;
}
)
;
}
)
;
const
=
.
address
(
)
;
if
(
!
||
typeof
===
'string'
)
{
throw
new
Error
(
'Integrated Browser smoke server did not expose a TCP address.'
)
;
}
=
` http://127.0.0.1: ${ address. port} `
;
}
)
;
afterEach
(
async
function
(
)
{
const
=
this
.
as
;
const
=
[
...
]
.
filter
(
=>
!
.
isClosed
(
)
)
.
map
(
=>
.
waitForEvent
(
'close'
)
)
;
await
.
.
.
runCommand
(
'workbench.action.closeAllEditors'
)
;
await
Promise
.
all
(
)
;
.
clear
(
)
;
}
)
;
after
(
async
(
)
=>
{
await
new
Promise < void >
(
(
,
)
=>
.
close
(
=>
?
reject
(
)
:
resolve
(
)
)
)
;
await
.
close
(
)
;
}
)
;
it
(
'opens an HTML file in a locked browser editor'
,
async
function
(
)
{
const
=
this
.
as
;
const
=
.
join
(
.
,
'browser-editor-smoke.html'
)
;
const
=
pathToFileURL
(
)
.
toString
(
)
;
.
writeFileSync
(
,
'<!DOCTYPE html><html><head><title>HTML Browser Editor Smoke</title></head><body><main id="browser-editor-smoke">Loaded in the browser editor</main></body></html>'
)
;
try
{
const
=
await
.
.
.
waitForNewPage
(
.
basename
(
)
,
async
(
)
=>
{
await
.
.
.
openFileQuickAccessAndWait
(
,
.
basename
(
)
)
;
await
.
.
.
selectQuickInputElement
(
0
)
;
}
)
;
.
add
(
)
;
await
.
locator
(
'#browser-editor-smoke'
,
{
:
'Loaded in the browser editor'
}
)
.
waitFor
(
)
;
const
=
.
.
.
.
locator
(
'.browser-root .browser-url-display'
)
;
await
.
waitFor
(
)
;
.
deepStrictEqual
(
{
:
normalizeFileUrl
(
await
.
textContent
(
)
)
,
:
await
.
getAttribute
(
'contenteditable'
)
,
:
await
.
getAttribute
(
'aria-readonly'
)
}
,
{
:
normalizeFileUrl
(
)
,
:
'false'
,
:
'true'
}
)
;
}
finally
{
.
rmSync
(
,
{
:
true
}
)
;
}
}
)
;
it
(
'navigates, reloads, and exposes page history'
,
async
function
(
)
{
const
=
this
.
as
;
const
=
await
openBrowserPage
(
,
` ${ baseUrl} /navigation/a `
,
)
;
const
=
.
.
.
;
await
.
locator
(
'#navigate'
)
.
click
(
)
;
await
.
waitForURL
(
` ${ baseUrl} /navigation/b `
)
;
await
waitForWorkbenchUrl
(
,
` ${ baseUrl} /navigation/b `
)
;
await
waitForActiveBrowserTab
(
,
'Browser Smoke B'
)
;
await
.
locator
(
'.browser-nav-toolbar .action-label[aria-label^="Go Back"]'
)
.
click
(
)
;
await
.
waitForURL
(
` ${ baseUrl} /navigation/a `
)
;
await
.
locator
(
'.browser-nav-toolbar .action-label[aria-label^="Go Forward"]'
)
.
click
(
)
;
await
.
waitForURL
(
` ${ baseUrl} /navigation/b `
)
;
await
waitForWorkbenchUrl
(
,
` ${ baseUrl} /navigation/b `
)
;
await
runBrowserCommand
(
,
,
` ${ browserCommandPrefix} .showHistory `
)
;
const
=
.
locator
(
'.quick-input-widget:visible'
)
;
await
.
locator
(
'.quick-input-title'
,
{
:
'Browser History'
}
)
.
waitFor
(
)
;
await
.
locator
(
'.monaco-list-row'
,
{
:
'Browser Smoke A'
}
)
.
first
(
)
.
waitFor
(
)
;
await
.
locator
(
'.monaco-list-row'
,
{
:
'Browser Smoke B'
}
)
.
first
(
)
.
waitFor
(
)
;
await
.
.
press
(
'Escape'
)
;
const
=
.
get
(
'/navigation/b'
)
??
0
;
await
.
locator
(
'.browser-nav-toolbar .action-label[aria-label^="Reload"]'
)
.
click
(
)
;
await
.
locator
(
'#request-count'
,
{
:
String
(
+
1
)
}
)
.
waitFor
(
)
;
}
)
;
it
(
'integrates page find and keyboard routing with the workbench'
,
async
function
(
)
{
const
=
this
.
as
;
const
=
await
openBrowserPage
(
,
` ${ baseUrl} /keyboard `
,
)
;
const
=
.
.
.
;
const
=
.
===
'darwin'
?
'Meta'
:
'Control'
;
await
.
locator
(
'body'
)
.
click
(
{
:
{
:
1
,
:
1
}
}
)
;
await
.
.
press
(
` ${ modifier} +f `
)
;
const
=
.
locator
(
'.browser-find-widget-wrapper .simple-find-part.visible'
)
;
const
=
.
locator
(
'.monaco-findInput input'
)
;
await
.
waitFor
(
)
;
await
.
fill
(
'FindSmokeToken'
)
;
await
.
locator
(
'.matchesCount'
,
{
:
'1 of 3'
}
)
.
waitFor
(
)
;
await
.
press
(
'Enter'
)
;
await
.
locator
(
'.matchesCount'
,
{
:
'2 of 3'
}
)
.
waitFor
(
)
;
await
.
press
(
'Escape'
)
;
await
.
waitFor
(
{
:
'hidden'
}
)
;
const
=
.
locator
(
'#key-input'
)
;
await
.
fill
(
'NativeSelectionValue'
)
;
await
.
press
(
` ${ modifier} +a `
)
;
await
.
pressSequentially
(
'x'
)
;
.
strictEqual
(
await
.
inputValue
(
)
,
'x'
)
;
await
.
press
(
` ${ modifier} +Shift+p `
)
;
await
.
locator
(
'.quick-input-widget:visible input[placeholder*="Type the name of a command"]'
)
.
waitFor
(
)
;
await
.
.
press
(
'Escape'
)
;
}
)
;
it
(
'prompts for and remembers a camera permission decision'
,
async
function
(
)
{
const
=
this
.
as
;
const
=
await
openBrowserPage
(
,
` ${ baseUrl} /permission `
,
)
;
const
=
.
.
.
;
await
.
locator
(
'#request-camera'
)
.
click
(
)
;
const
=
.
locator
(
'.monaco-dialog-box:visible'
)
;
await
.
locator
(
'#monaco-dialog-message-text'
,
{
:
'wants access to Camera'
}
)
.
waitFor
(
)
;
await
.
locator
(
'.monaco-button'
,
{
:
'Block'
}
)
.
click
(
)
;
await
.
locator
(
'#permission-result'
,
{
:
'NotAllowedError'
}
)
.
waitFor
(
)
;
await
runBrowserOverflowAction
(
,
,
'Site Permissions'
)
;
const
=
.
locator
(
'.quick-input-widget:visible'
)
;
await
.
locator
(
'.quick-input-title'
,
{
:
'Permissions for 127.0.0.1'
}
)
.
waitFor
(
)
;
await
.
locator
(
'.monaco-list-row'
,
{
:
'Camera'
}
)
.
locator
(
'[aria-label="Blocked"]'
)
.
waitFor
(
)
;
await
.
.
press
(
'Escape'
)
;
const
=
await
.
locator
(
'#permission-result'
)
.
textContent
(
)
;
await
.
locator
(
'#request-camera'
)
.
click
(
)
;
await
.
waitForFunction
(
=>
.
querySelector
(
'#permission-result'
)
?.
!==
,
)
;
.
match
(
await
.
locator
(
'#permission-result'
)
.
textContent
(
)
??
''
,
/ ^ NotAllowedError:\d + $ /
)
;
.
strictEqual
(
await
.
locator
(
'.monaco-dialog-box:visible'
)
.
count
(
)
,
0
)
;
}
)
;
it
(
'adds browser context to chat'
,
async
function
(
)
{
const
=
this
.
as
;
const
=
await
openBrowserPage
(
,
` ${ baseUrl} /comment `
,
)
;
const
=
.
.
.
;
const
=
.
locator
(
'#comment-target'
)
;
const
=
.
===
'darwin'
?
'Meta'
:
'Control'
;
await
.
waitFor
(
)
;
await
.
.
press
(
` ${ modifier} +Shift+c `
)
;
await
.
locator
(
'[data-vscode-pick-host]'
)
.
waitFor
(
{
:
'attached'
}
)
;
await
.
click
(
)
;
await
.
.
.
waitForChatView
(
)
;
await
.
locator
(
'div[id="workbench.panel.chat"] .chat-attached-context-attachment'
,
{
:
'button#comment-target'
}
)
.
waitFor
(
)
;
await
.
click
(
)
;
await
.
.
press
(
` ${ modifier} +Alt+c `
)
;
await
.
locator
(
'[data-vscode-pick-host]'
)
.
waitFor
(
{
:
'attached'
}
)
;
await
.
click
(
)
;
await
.
waitForFunction
(
(
)
=>
.
?.
hasAttribute
(
'data-vscode-pick-host'
)
)
;
await
.
evaluate
(
(
)
=>
.
querySelector
(
'#comment-keydown-count'
)
!
.
=
'0'
)
;
await
.
.
type
(
)
;
await
.
.
press
(
'Enter'
)
;
.
strictEqual
(
await
.
locator
(
'#comment-keydown-count'
)
.
textContent
(
)
,
'0'
)
;
await
.
.
.
waitForInputText
(
'@button#comment-target'
)
;
await
.
.
.
waitForInputText
(
)
;
await
.
.
press
(
'Escape'
)
;
await
.
locator
(
'[data-vscode-pick-host]'
)
.
waitFor
(
{
:
'attached'
}
)
;
const
=
.
locator
(
'div[id="workbench.panel.chat"] .interactive-input-part .monaco-editor[role="code"]'
)
;
await
.
click
(
)
;
await
.
.
press
(
.
===
'darwin'
?
'Meta+a'
:
'Control+a'
)
;
await
.
.
press
(
'Backspace'
)
;
await
.
locator
(
'[data-vscode-pick-host]'
)
.
waitFor
(
{
:
'detached'
}
)
;
await
.
goto
(
` ${ baseUrl} /screenshot `
)
;
await
runAddToChatMenuAction
(
,
,
'Add Full Page Screenshot to Chat (Experimental)'
)
;
const
=
.
locator
(
'div[id="workbench.panel.chat"] .chat-attached-context-attachment.image-attachment'
,
{
:
'Browser Full Page Screenshot'
}
)
;
const
=
.
locator
(
'img.chat-attached-context-pill-image'
)
;
await
.
waitFor
(
)
;
.
strictEqual
(
await
.
evaluate
(
=>
{
const
=
as
;
return
.
>
.
*
2
;
}
)
,
true
)
;
}
)
;
it
(
'allows agents to use shared pages and blocks unshared pages'
,
async
function
(
)
{
this
.
timeout
(
5
*
60
*
1000
)
;
const
=
this
.
as
;
const
=
await
openBrowserPage
(
,
` ${ baseUrl} /sharing `
,
)
;
const
=
.
.
.
;
const
=
.
locator
(
'#share-click-count'
)
;
const
=
.
locator
(
'.browser-share-toggle[aria-label="Share with Agent"]'
)
;
const
=
.
locator
(
'.browser-share-toggle[aria-label="Stop Sharing with Agent"]'
)
;
const
=
.
locator
(
'.monaco-dialog-box:visible'
)
;
const
allowSharing
=
async
(
)
=>
{
await
.
click
(
)
;
await
.
locator
(
'.monaco-button'
,
{
:
'Allow'
}
)
.
click
(
)
;
await
.
waitFor
(
)
;
}
;
await
.
click
(
)
;
await
.
locator
(
'#monaco-dialog-message-text'
,
{
:
'Share this browser page with the agent?'
}
)
.
waitFor
(
)
;
await
.
locator
(
'.monaco-button'
,
{
:
'Allow'
}
)
.
click
(
)
;
await
.
waitFor
(
)
;
await
openBrowserPage
(
,
` ${ baseUrl} /navigation/a `
,
)
;
await
allowSharing
(
)
;
await
.
locator
(
'.tab'
,
{
:
'Browser Smoke Sharing'
}
)
.
click
(
)
;
await
.
waitFor
(
)
;
await
.
.
.
runCommand
(
'smoketest.openLocalChat'
)
;
await
.
.
.
waitForChatView
(
)
;
await
.
.
.
sendMessage
(
'[scenario:browser-sharing-click-success]'
)
;
const
=
await
waitForScenarioToolResult
(
,
'browser-sharing-click-success'
)
;
.
doesNotMatch
(
,
/ not found / i
)
;
await
.
waitFor
(
{
:
'attached'
}
)
;
.
strictEqual
(
await
.
textContent
(
)
,
'1'
)
;
await
.
click
(
)
;
await
.
waitFor
(
)
;
await
.
.
.
sendMessage
(
'[scenario:browser-sharing-click-error]'
)
;
const
=
await
waitForScenarioToolResult
(
,
'browser-sharing-click-error'
)
;
.
deepStrictEqual
(
{
:
/ Page "[ 0- 9 a- f -] + " not found / i
.
test
(
)
,
:
await
.
textContent
(
)
}
,
{
:
true
,
:
'1'
}
,
` Unshared page should not be reachable, but the tool returned: ${ errorToolResult} `
)
;
await
allowSharing
(
)
;
await
.
.
.
sendMessage
(
'[scenario:browser-sharing-click-reshared]'
)
;
const
=
await
waitForScenarioToolResult
(
,
'browser-sharing-click-reshared'
)
;
.
doesNotMatch
(
,
/ not found / i
)
;
await
.
locator
(
'#share-click-count'
,
{
:
'2'
}
)
.
waitFor
(
)
;
}
)
;
it
(
'preserves native page lifecycle across editors, popups, and restart'
,
async
function
(
)
{
const
=
this
.
as
;
const
=
` ${ baseUrl} /lifecycle `
;
const
=
await
openBrowserPage
(
,
,
)
;
const
=
.
.
.
;
await
.
locator
(
'#state-input'
)
.
fill
(
'Preserved state'
)
;
await
.
locator
(
'#scroll-marker'
)
.
scrollIntoViewIfNeeded
(
)
;
const
=
await
.
evaluate
(
(
)
=>
)
;
.
ok
(
>
0
)
;
await
.
.
.
openFile
(
.
join
(
.
,
'app.js'
)
)
;
await
.
locator
(
'.tab'
,
{
:
'Browser Smoke Lifecycle'
}
)
.
click
(
)
;
.
deepStrictEqual
(
{
:
await
.
locator
(
'#state-input'
)
.
inputValue
(
)
,
:
await
.
evaluate
(
(
)
=>
)
}
,
{
:
'Preserved state'
,
:
}
)
;
const
=
await
.
.
.
waitForNewPage
(
'/popup-child'
,
(
)
=>
.
locator
(
'#open-popup'
)
.
click
(
)
)
;
.
add
(
)
;
await
.
locator
(
'#popup-child-content'
)
.
waitFor
(
)
;
await
.
locator
(
'.tab'
,
{
:
'Browser Smoke Popup Child'
}
)
.
waitFor
(
)
;
await
.
close
(
)
;
.
delete
(
)
;
await
.
locator
(
'.tab'
,
{
:
'Browser Smoke Popup Child'
}
)
.
waitFor
(
{
:
'detached'
}
)
;
await
.
locator
(
'.tab'
,
{
:
'Browser Smoke Lifecycle'
}
)
.
click
(
)
;
.
strictEqual
(
await
.
locator
(
'#state-input'
)
.
inputValue
(
)
,
'Preserved state'
)
;
await
.
restart
(
)
;
.
clear
(
)
;
const
=
await
.
.
.
waitForPage
(
'/lifecycle'
,
30_000
)
;
.
add
(
)
;
await
.
locator
(
'#lifecycle-content'
)
.
waitFor
(
)
;
await
waitForActiveBrowserTab
(
.
.
.
,
'Browser Smoke Lifecycle'
)
;
await
waitForWorkbenchUrl
(
.
.
.
,
)
;
}
)
;
}
)
;
}
function
normalizeFileUrl
(
:
string
|
null
)
:
string
|
null
{
if
(
!
)
{
return
null
;
}
const
=
.
normalize
(
fileURLToPath
(
)
)
;
return
.
===
'win32'
?
.
toLowerCase
(
)
:
;
}
function
preseedSettings
(
:
string
|
undefined
,
:
string
)
:
void
{
if
(
!
)
{
throw
new
Error
(
'Cannot pre-seed Integrated Browser settings without a user data directory'
)
;
}
const
=
.
join
(
,
'User'
,
'settings.json'
)
;
.
mkdirSync
(
.
dirname
(
)
,
{
:
true
}
)
;
.
writeFileSync
(
,
JSON
.
stringify
(
{
'github.copilot.advanced.debug.overrideProxyUrl'
:
,
'github.copilot.advanced.debug.overrideCapiUrl'
:
,
'github.copilot.advanced.debug.overrideAuthType'
:
'token'
,
'chat.allowAnonymousAccess'
:
true
,
'github.copilot.chat.githubMcpServer.enabled'
:
false
,
'chat.mcp.discovery.enabled'
:
false
,
'chat.mcp.enabled'
:
false
,
'chat.disableAIFeatures'
:
false
,
'chat.tools.riskAssessment.enabled'
:
false
,
'github.copilot.chat.backgroundAgent.enabled'
:
true
,
'window.menuStyle'
:
'custom'
,
'workbench.browser.experimentalUserTools.enabled'
:
true
,
'workbench.editorAssociations'
:
{
'*.html'
:
'workbench.editor.browser'
}
,
}
,
null
,
2
)
)
;
}
function
withFakeMediaDevice
(
:
)
:
{
return
{
...
,
:
[
...
(
.
??
[
]
)
,
'--use-fake-device-for-media-stream'
]
}
;
}
async
function
openBrowserPage
(
:
,
:
string
,
:
<
>
)
:
Promise
<
>
{
const
=
.
.
.
;
const
=
await
.
.
.
waitForNewPage
(
,
async
(
)
=>
{
await
.
.
.
runCommand
(
'workbench.action.browser.open'
,
{
:
true
}
)
;
const
=
.
locator
(
'.quick-input-widget:visible input[placeholder*="enter URL"]'
)
;
await
.
waitFor
(
)
;
await
.
fill
(
)
;
await
.
press
(
'Enter'
)
;
}
)
;
.
add
(
)
;
await
.
waitForLoadState
(
'domcontentloaded'
)
;
await
waitForWorkbenchUrl
(
,
)
;
return
;
}
async
function
waitForWorkbenchUrl
(
:
,
:
string
)
:
Promise
<
void
>
{
await
.
locator
(
'.browser-root .browser-url-display'
,
{
:
}
)
.
waitFor
(
)
;
}
async
function
waitForActiveBrowserTab
(
:
,
:
string
)
:
Promise
<
void
>
{
await
.
locator
(
'.tab.active'
,
{
:
}
)
.
waitFor
(
)
;
}
async
function
runBrowserCommand
(
:
,
:
,
:
string
)
:
Promise
<
void
>
{
await
.
locator
(
'body'
)
.
click
(
{
:
{
:
1
,
:
1
}
}
)
;
await
.
.
.
runCommand
(
,
{
:
true
}
)
;
}
async
function
runBrowserOverflowAction
(
:
,
:
,
:
string
)
:
Promise
<
void
>
{
await
.
locator
(
'body'
)
.
click
(
{
:
{
:
1
,
:
1
}
}
)
;
const
=
.
locator
(
'.browser-actions-toolbar .action-label[aria-label^="More Actions"]'
)
;
await
.
hover
(
)
;
await
.
waitForTimeout
(
500
)
;
await
.
click
(
)
;
const
=
.
locator
(
'.monaco-menu-container:visible .action-menu-item'
,
{
:
}
)
.
last
(
)
;
await
.
waitFor
(
)
;
await
.
hover
(
)
;
await
.
waitForTimeout
(
500
)
;
await
.
click
(
)
;
}
async
function
runAddToChatMenuAction
(
:
,
:
,
:
string
)
:
Promise
<
void
>
{
await
.
locator
(
'body'
)
.
click
(
{
:
{
:
1
,
:
1
}
}
)
;
const
=
.
locator
(
'.browser-actions-toolbar .monaco-dropdown-with-default .dropdown-action-container .action-label'
)
;
await
.
hover
(
)
;
await
.
waitForTimeout
(
500
)
;
await
.
click
(
)
;
const
=
.
locator
(
'.monaco-menu-container:visible .action-menu-item'
,
{
:
}
)
.
last
(
)
;
await
.
waitFor
(
)
;
await
.
hover
(
)
;
await
.
waitForTimeout
(
500
)
;
await
.
click
(
)
;
}
function
browserClickScenario
(
:
'SUCCESS'
|
'ERROR'
|
'RESHARED'
,
getPageId
:
(
:
readonly
unknown
[
]
)
=>
string
)
:
unknown
{
return
{
:
'multi-turn'
,
:
[
{
:
'tool-calls'
,
:
[
{
:
/ click. ? element / i
,
arguments
:
(
:
readonly
unknown
[
]
)
=>
(
{
:
getPageId
(
)
,
:
'#share-target'
,
:
'sharing smoke button'
}
)
}
]
}
,
{
:
'content'
,
:
[
{
:
,
:
0
}
]
}
]
}
;
}
function
findBrowserPageId
(
:
readonly
unknown
[
]
,
:
string
)
:
string
{
const
=
JSON
.
stringify
(
)
.
match
(
new
RegExp
(
` \\[([0-9a-f-]{36})\\]\\s+ ${ title} `
,
'i'
)
)
;
if
(
!
)
{
throw
new
Error
(
` Could not find the page ID for ${ title} in the model request `
)
;
}
return
[
1
]
;
}
async
function
waitForScenarioToolResult
(
:
,
:
string
)
:
Promise
<
string
>
{
const
=
.
now
(
)
+
120_000
;
while
(
.
now
(
)
<
)
{
for
(
const
of
[
...
.
getRequests
(
)
]
.
reverse
(
)
)
{
if
(
!
JSON
.
stringify
(
.
)
.
includes
(
` [scenario: ${ scenarioId} ] `
)
)
{
continue
;
}
const
=
findToolResults
(
.
,
)
;
if
(
.
>
0
)
{
return
[
.
-
1
]
;
}
}
await
new
Promise
(
=>
setTimeout
(
,
250
)
)
;
}
throw
new
Error
(
` Timed out waiting for the ${ scenarioId} tool result `
)
;
}
function
findToolResults
(
:
unknown
,
:
string
)
:
string
[
]
{
if
(
!
||
typeof
!==
'object'
)
{
return
[
]
;
}
if
(
Array
.
isArray
(
)
)
{
return
.
flatMap
(
=>
findToolResults
(
,
)
)
;
}
const
=
as
<
string
,
unknown
>
;
const
=
.
??
.
??
.
;
if
(
typeof
===
'string'
&&
.
includes
(
)
)
{
const
=
.
??
.
;
return
[
typeof
===
'string'
?
:
JSON
.
stringify
(
)
]
;
}
return
.
values
(
)
.
flatMap
(
=>
findToolResults
(
,
)
)
;
}
function
pageForRoute
(
:
string
,
:
number
)
:
string
{
switch
(
)
{
case
'/navigation/a'
:
return
html
(
'Browser Smoke A'
,
'<a id="navigate" href="/navigation/b">Navigate</a>'
)
;
case
'/navigation/b'
:
return
html
(
'Browser Smoke B'
,
` <div id="request-count"> ${ requestCount} </div> `
)
;
case
'/keyboard'
:
return
html
(
'Browser Smoke Keyboard'
,
'<p>FindSmokeToken one</p><p>FindSmokeToken two</p><p>FindSmokeToken three</p><input id="key-input">'
)
;
case
'/permission'
:
return
html
(
'Browser Smoke Permission'
,
` <button id="request-camera">Request camera</button><div id="permission-result"></div><script>
let attempts = 0;
document.querySelector('#request-camera').addEventListener('click', async () => {
attempts++;
try {
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
document.querySelector('#permission-result').textContent = 'Allowed:' + attempts;
stream.getTracks().forEach(track => track.stop());
} catch (error) {
document.querySelector('#permission-result').textContent = error.name + ':' + attempts;
}
});
</script> `
)
;
case
'/comment'
:
return
html
(
'Browser Smoke Comment'
,
` <button id="comment-target">Comment target</button>
<output id="comment-keydown-count">0</output>
<script>
window.addEventListener('keydown', () => {
const output = document.querySelector('#comment-keydown-count');
output.textContent = String(Number(output.textContent) + 1);
});
</script> `
)
;
case
'/screenshot'
:
return
html
(
'Browser Smoke Screenshot'
,
'<div id="screenshot-top">Top</div><div style="height: 2400px"></div><div id="screenshot-bottom">Bottom</div>'
)
;
case
'/sharing'
:
return
html
(
'Browser Smoke Sharing'
,
` <button id="share-target">Click target</button>
<output id="share-click-count">0</output>
<script>
document.querySelector('#share-target').addEventListener('click', () => {
const output = document.querySelector('#share-click-count');
output.textContent = String(Number(output.textContent) + 1);
});
</script> `
)
;
case
'/lifecycle'
:
return
html
(
'Browser Smoke Lifecycle'
,
'<div id="lifecycle-content">Lifecycle content</div><input id="state-input"><a id="open-popup" target="_blank" href="/popup-child">Open child</a><div style="height: 1800px"></div><div id="scroll-marker">Scroll marker</div>'
)
;
case
'/popup-child'
:
return
html
(
'Browser Smoke Popup Child'
,
'<div id="popup-child-content">Popup child</div>'
)
;
default
:
return
html
(
'Browser Smoke Not Found'
,
'Not found'
)
;
}
}
function
html
(
:
string
,
:
string
)
:
string
{
return
` <!DOCTYPE html><html><head><meta charset="utf-8"><title> ${ title} </title></head><body> ${ body} </body></html> `
;
}