MCPcopy
hub / github.com/vercel/next.js / setup

Method setup

test/lib/browsers/playwright.ts:168–224  ·  view source on GitHub ↗
(
    browserName: string,
    locale: string,
    javaScriptEnabled: boolean,
    ignoreHTTPSErrors: boolean,
    headless: boolean,
    userAgent: string | undefined,
    permissions: Permissions
  )

Source from the content-addressed store, hash-verified

166 }
167
168 async setup(
169 browserName: string,
170 locale: string,
171 javaScriptEnabled: boolean,
172 ignoreHTTPSErrors: boolean,
173 headless: boolean,
174 userAgent: string | undefined,
175 permissions: Permissions
176 ) {
177 let device
178
179 if (process.env.DEVICE_NAME) {
180 device = devices[process.env.DEVICE_NAME]
181
182 if (!device) {
183 throw new Error(
184 `Invalid playwright device name ${process.env.DEVICE_NAME}`
185 )
186 }
187 }
188
189 if (browser) {
190 if (
191 contextHasJSEnabled !== javaScriptEnabled ||
192 // Even triggers on same set of permissions, but we don't want to deal
193 // with the complexity of diffing them, so we just always recreate the
194 // context when permissions are set.
195 contextPermissions !== permissions
196 ) {
197 // If we have switched from having JS enable/disabled we need to recreate the context.
198 await teardown(this.teardownTracing.bind(this))
199 await context?.close()
200 context = await browser.newContext({
201 locale,
202 javaScriptEnabled,
203 ignoreHTTPSErrors,
204 ...(userAgent ? { userAgent } : {}),
205 ...device,
206 permissions,
207 })
208 contextHasJSEnabled = javaScriptEnabled
209 contextPermissions = permissions
210 }
211 return
212 }
213
214 browser = await this.launchBrowser(browserName, { headless })
215 context = await browser.newContext({
216 locale,
217 javaScriptEnabled,
218 ignoreHTTPSErrors,
219 ...(userAgent ? { userAgent } : {}),
220 ...device,
221 permissions,
222 })
223 contextHasJSEnabled = javaScriptEnabled
224 }
225

Callers 1

webdriverFunction · 0.95

Calls 4

launchBrowserMethod · 0.95
teardownFunction · 0.70
closeMethod · 0.65
bindMethod · 0.45

Tested by

no test coverage detected