This reverts commit ec7d37d92f.
			
			
This commit is contained in:
		
							parent
							
								
									7b6e9b9be9
								
							
						
					
					
						commit
						103f8ddd06
					
				|  | @ -1,16 +1,17 @@ | |||
| # Ignore everything by default | ||||
| **/* | ||||
| 
 | ||||
| # Check ts files in src/ | ||||
| !src | ||||
| !src/**/*.ts | ||||
| src/**/*.d.ts | ||||
| test/assets/modernizr.js | ||||
| lib/ | ||||
| *.js | ||||
| src/generated/* | ||||
| src/server/chromium/protocol.ts | ||||
| src/server/firefox/protocol.ts | ||||
| src/server/webkit/protocol.ts | ||||
| 
 | ||||
| # Check ts files in tests/ | ||||
| !tests | ||||
| !tests/**/*.ts | ||||
| tests/**/*.d.ts | ||||
| src/third_party/ | ||||
| /types/* | ||||
| /index.d.ts | ||||
| utils/generate_types/overrides.d.ts | ||||
| utils/generate_types/test/test.ts | ||||
| node_modules/ | ||||
| browser_patches/*/checkout/ | ||||
| browser_patches/chromium/output/ | ||||
| **/*.d.ts | ||||
| output/ | ||||
|  |  | |||
|  | @ -26,7 +26,6 @@ import { Events } from './events'; | |||
| import { Page } from './page'; | ||||
| import { Waiter } from './waiter'; | ||||
| import * as api from '../../types/types'; | ||||
| import { Serializable } from '../../types/structs'; | ||||
| 
 | ||||
| export type NetworkCookie = { | ||||
|   name: string, | ||||
|  | @ -303,7 +302,7 @@ export class Route extends ChannelOwner<channels.RouteChannel, channels.RouteIni | |||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   async intercept(options: { url?: string, method?: string, headers?: Headers, postData?: string | Buffer, interceptResponse?: boolean } = {}) : Promise<api.Response> { | ||||
|   async intercept(options: { url?: string, method?: string, headers?: Headers, postData?: string | Buffer, interceptResponse?: boolean } = {}): Promise<api.Response> { | ||||
|     return await this._continue('route.intercept', options, true); | ||||
|   } | ||||
| 
 | ||||
|  | @ -311,9 +310,9 @@ export class Route extends ChannelOwner<channels.RouteChannel, channels.RouteIni | |||
|     await this._continue('route.continue', options, false); | ||||
|   } | ||||
| 
 | ||||
|   async _continue(apiName: string, options: { url?: string, method?: string, headers?: Headers, postData?: string | Buffer }, interceptResponse: NotInterceptResponse) : Promise<null>; | ||||
|   async _continue(apiName: string, options: { url?: string, method?: string, headers?: Headers, postData?: string | Buffer }, interceptResponse: InterceptResponse) : Promise<api.Response>; | ||||
|   async _continue(apiName: string, options: { url?: string, method?: string, headers?: Headers, postData?: string | Buffer }, interceptResponse: boolean) : Promise<null|api.Response> { | ||||
|   async _continue(apiName: string, options: { url?: string, method?: string, headers?: Headers, postData?: string | Buffer }, interceptResponse: NotInterceptResponse): Promise<null>; | ||||
|   async _continue(apiName: string, options: { url?: string, method?: string, headers?: Headers, postData?: string | Buffer }, interceptResponse: InterceptResponse): Promise<api.Response>; | ||||
|   async _continue(apiName: string, options: { url?: string, method?: string, headers?: Headers, postData?: string | Buffer }, interceptResponse: boolean): Promise<null|api.Response> { | ||||
|     return await this._wrapApiCall(apiName, async (channel: channels.RouteChannel) => { | ||||
|       const postDataBuffer = isString(options.postData) ? Buffer.from(options.postData, 'utf8') : options.postData; | ||||
|       const result = await channel.continue({ | ||||
|  |  | |||
|  | @ -14,7 +14,7 @@ | |||
|  * limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { InterceptedResponse, Request, Response, Route, WebSocket } from '../server/network'; | ||||
| import { Request, Response, Route, WebSocket } from '../server/network'; | ||||
| import * as channels from '../protocol/channels'; | ||||
| import { Dispatcher, DispatcherScope, lookupNullableDispatcher, existingDispatcher } from './dispatcher'; | ||||
| import { FrameDispatcher } from './frameDispatcher'; | ||||
|  |  | |||
|  | @ -229,9 +229,10 @@ async function urlToWSEndpoint(endpointURL: string) { | |||
|   const httpURL = endpointURL.endsWith('/') ? `${endpointURL}json/version/` : `${endpointURL}/json/version/`; | ||||
|   const json = await new Promise<string>((resolve, reject) => { | ||||
|     http.get(httpURL, resp => { | ||||
|       if (resp.statusCode! < 200 || resp.statusCode! >= 400) | ||||
|       if (resp.statusCode! < 200 || resp.statusCode! >= 400) { | ||||
|         reject(new Error(`Unexpected status ${resp.statusCode} when connecting to ${httpURL}.\n` + | ||||
|         `This does not look like a DevTools server, try connecting via ws://.`)); | ||||
|       } | ||||
|       let data = ''; | ||||
|       resp.on('data', chunk => data += chunk); | ||||
|       resp.on('end', () => resolve(data)); | ||||
|  |  | |||
|  | @ -187,7 +187,7 @@ export class CRNetworkManager { | |||
|         return; | ||||
|       } | ||||
|       request._onInterceptedResponse!(event); | ||||
|       return | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     const requestId = event.networkId; | ||||
|  | @ -310,13 +310,14 @@ export class CRNetworkManager { | |||
|       }; | ||||
|     } | ||||
|     const response = new network.Response(request.request, responsePayload.status, responsePayload.statusText, headersObjectToArray(responsePayload.headers), timing, getResponseBody); | ||||
|     if (responsePayload?.remoteIPAddress && typeof responsePayload?.remotePort === 'number') | ||||
|     if (responsePayload?.remoteIPAddress && typeof responsePayload?.remotePort === 'number') { | ||||
|       response._serverAddrFinished({ | ||||
|         ipAddress: responsePayload.remoteIPAddress, | ||||
|         port: responsePayload.remotePort, | ||||
|       }); | ||||
|     else | ||||
|     } else { | ||||
|       response._serverAddrFinished(); | ||||
|     } | ||||
|     response._securityDetailsFinished({ | ||||
|       protocol: responsePayload?.securityDetails?.protocol, | ||||
|       subjectName: responsePayload?.securityDetails?.subjectName, | ||||
|  |  | |||
|  | @ -89,13 +89,12 @@ export class FFNetworkManager { | |||
|       responseStart: this._relativeTiming(event.timing.responseStart), | ||||
|     }; | ||||
|     const response = new network.Response(request.request, event.status, event.statusText, event.headers, timing, getResponseBody); | ||||
|     if (event?.remoteIPAddress && typeof event?.remotePort === 'number') | ||||
|     if (event?.remoteIPAddress && typeof event?.remotePort === 'number') { | ||||
|       response._serverAddrFinished({ | ||||
|         ipAddress: event.remoteIPAddress, | ||||
|         port: event.remotePort, | ||||
|       }); | ||||
|     else | ||||
|       response._serverAddrFinished() | ||||
|     } else {response._serverAddrFinished();} | ||||
|     response._securityDetailsFinished({ | ||||
|       protocol: event?.securityDetails?.protocol, | ||||
|       subjectName: event?.securityDetails?.subjectName, | ||||
|  |  | |||
|  | @ -258,7 +258,7 @@ export class Route extends SdkObject { | |||
|         throw new Error('New URL must have same protocol as overridden URL'); | ||||
|     } | ||||
|     this._response = await this._delegate.continue(overrides); | ||||
|     return this._response | ||||
|     return this._response; | ||||
|   } | ||||
| 
 | ||||
|   async responseBody(): Promise<Buffer> { | ||||
|  | @ -285,7 +285,7 @@ export type ResourceTiming = { | |||
| export type RemoteAddr = { | ||||
|   ipAddress: string; | ||||
|   port: number; | ||||
| } | ||||
| }; | ||||
| 
 | ||||
| export type SecurityDetails = { | ||||
|     protocol?: string; | ||||
|  |  | |||
|  | @ -91,9 +91,9 @@ export class JavaScriptLanguageGenerator implements LanguageGenerator { | |||
|     const suffix = (signals.waitForNavigation || emitPromiseAll) ? '' : ';'; | ||||
|     formatter.add(`${prefix}${subject}.${actionCall}${suffix}`); | ||||
| 
 | ||||
|     if (emitPromiseAll) | ||||
|     if (emitPromiseAll) { | ||||
|       formatter.add(`]);`); | ||||
|     else if (signals.assertNavigation) { | ||||
|     } else if (signals.assertNavigation) { | ||||
|       if (this._isTest) | ||||
|         formatter.add(`  expect(${pageAlias}.url()).toBe(${quote(signals.assertNavigation.url)});`); | ||||
|       else | ||||
|  |  | |||
|  | @ -23,8 +23,6 @@ import { BrowserType } from '../browserType'; | |||
| import { ConnectionTransport } from '../transport'; | ||||
| import { BrowserOptions, PlaywrightOptions } from '../browser'; | ||||
| import * as types from '../types'; | ||||
| import * as fs from 'fs'; | ||||
| import { assert } from '../../utils/utils'; | ||||
| 
 | ||||
| export class WebKit extends BrowserType { | ||||
|   constructor(playwrightOptions: PlaywrightOptions) { | ||||
|  |  | |||
|  | @ -100,7 +100,7 @@ export class WKInterceptableRequest implements network.RouteDelegate { | |||
|       mimeType = contentType.split(';')[0].trim(); | ||||
| 
 | ||||
|     const isResponseIntercepted = await this._responseInterceptedPromise; | ||||
|     await this._session.sendMayFail(isResponseIntercepted ? 'Network.interceptWithResponse' :'Network.interceptRequestWithResponse', { | ||||
|     await this._session.sendMayFail(isResponseIntercepted ? 'Network.interceptWithResponse' : 'Network.interceptRequestWithResponse', { | ||||
|       requestId: this._requestId, | ||||
|       status: response.status, | ||||
|       statusText: network.STATUS_TEXTS[String(response.status)], | ||||
|  |  | |||
|  | @ -673,7 +673,7 @@ export class WKPage implements PageDelegate { | |||
|       this._updateState('Network.addInterception', { url: '.*', stage: 'request', isRegex: true }), | ||||
|     ]; | ||||
|     if (this._needsResponseInterception) | ||||
|       this._updateState('Network.addInterception', { url: '.*', stage: 'response', isRegex: true }) | ||||
|       this._updateState('Network.addInterception', { url: '.*', stage: 'response', isRegex: true }); | ||||
|     await Promise.all(promises); | ||||
|   } | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ | |||
|  * limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| /* eslint-disable no-console */ | ||||
| import colors from 'colors/safe'; | ||||
| import fs from 'fs'; | ||||
| import path from 'path'; | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ | |||
| import * as fs from 'fs'; | ||||
| import * as path from 'path'; | ||||
| import * as os from 'os'; | ||||
| import type { LaunchOptions, BrowserContextOptions, Page, BrowserContext } from '../../types/types'; | ||||
| import type { LaunchOptions, BrowserContextOptions, Page } from '../../types/types'; | ||||
| import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, FullConfig, TestInfo } from '../../types/test'; | ||||
| import { rootTestType } from './testType'; | ||||
| import { createGuid, removeFolders } from '../utils/utils'; | ||||
|  |  | |||
|  | @ -190,7 +190,7 @@ export class Loader { | |||
|     let testDir = takeFirst(projectConfig.testDir, rootDir); | ||||
|     if (!path.isAbsolute(testDir)) | ||||
|       testDir = path.resolve(rootDir, testDir); | ||||
|     let outputDir = takeFirst(this._configOverrides.outputDir, projectConfig.outputDir, this._config.outputDir, path.resolve(process.cwd(), 'test-results')) | ||||
|     let outputDir = takeFirst(this._configOverrides.outputDir, projectConfig.outputDir, this._config.outputDir, path.resolve(process.cwd(), 'test-results')); | ||||
|     if (!path.isAbsolute(outputDir)) | ||||
|       outputDir = path.resolve(rootDir, outputDir); | ||||
|     const fullProject: FullProject = { | ||||
|  |  | |||
|  | @ -0,0 +1,5 @@ | |||
| { | ||||
|     "rules": { | ||||
|         "no-console": "off" | ||||
|     } | ||||
| } | ||||
|  | @ -14,6 +14,7 @@ | |||
|  * limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| /* eslint-disable no-console */ | ||||
| import colors from 'colors/safe'; | ||||
| // @ts-ignore
 | ||||
| import milliseconds from 'ms'; | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ | |||
|  * limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| /* eslint-disable no-console */ | ||||
| import rimraf from 'rimraf'; | ||||
| import * as fs from 'fs'; | ||||
| import * as path from 'path'; | ||||
|  |  | |||
|  | @ -87,7 +87,7 @@ export function fetchData(url: string): Promise<string> { | |||
| type OnProgressCallback = (downloadedBytes: number, totalBytes: number) => void; | ||||
| type DownloadFileLogger = (message: string) => void; | ||||
| 
 | ||||
| export function downloadFile(url: string, destinationPath: string, options : {progressCallback?: OnProgressCallback, log?: DownloadFileLogger} = {}): Promise<{error: any}> { | ||||
| export function downloadFile(url: string, destinationPath: string, options: {progressCallback?: OnProgressCallback, log?: DownloadFileLogger} = {}): Promise<{error: any}> { | ||||
|   const { | ||||
|     progressCallback, | ||||
|     log = () => {}, | ||||
|  |  | |||
|  | @ -318,7 +318,7 @@ test('should report an expected error when the endpointURL returns a non-expecte | |||
|   }); | ||||
|   await expect(browserType.connectOverCDP({ | ||||
|     endpointURL: server.PREFIX, | ||||
|   })).rejects.toThrowError(`browserType.connectOverCDP: Unexpected status 404 when connecting to ${server.PREFIX}/json/version/`) | ||||
|   })).rejects.toThrowError(`browserType.connectOverCDP: Unexpected status 404 when connecting to ${server.PREFIX}/json/version/`); | ||||
| }); | ||||
| 
 | ||||
| test('should report an expected error when the endpoint URL JSON webSocketDebuggerUrl is undefined', async ({ browserType, server }) => { | ||||
|  |  | |||
|  | @ -78,7 +78,6 @@ test('test', async ({ page }) => {`; | |||
| 
 | ||||
| test('should print load storageState', async ({ browserName, channel, runCLI }, testInfo) => { | ||||
|   const loadFileName = testInfo.outputPath('load.json'); | ||||
|   const saveFileName = testInfo.outputPath('save.json'); | ||||
|   await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8'); | ||||
|   const cli = runCLI([`--load-storage=${loadFileName}`, emptyHTML]); | ||||
|   const expectedResult = `const { test, expect } = require('@playwright/test');
 | ||||
|  |  | |||
|  | @ -226,7 +226,7 @@ it.describe('Drag and drop', () => { | |||
|     await page.mouse.up(); | ||||
|     route.abort(); | ||||
|     expect(await page.$eval('#target', target => target.contains(document.querySelector('#source')))).toBe(true); // could not find source in target
 | ||||
|   }) | ||||
|   }); | ||||
| 
 | ||||
|   async function trackEvents(target: ElementHandle) { | ||||
|     const eventsHandle = await target.evaluateHandle(target => { | ||||
|  |  | |||
|  | @ -558,7 +558,7 @@ it('should not use Array.prototype.toJSON when evaluating', async ({ page }) => | |||
| 
 | ||||
| it('should not add a toJSON property to newly created Arrays after evaluation', async ({ page, browserName }) => { | ||||
|   await page.evaluate(() => []); | ||||
|   const hasToJSONProperty = await page.evaluate(() => "toJSON" in []); | ||||
|   const hasToJSONProperty = await page.evaluate(() => 'toJSON' in []); | ||||
|   expect(hasToJSONProperty).toEqual(false); | ||||
| }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,9 +15,9 @@ | |||
|  * limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
|  import { fail } from 'assert'; | ||||
| import { fail } from 'assert'; | ||||
| import type { Route } from '../../index'; | ||||
|  import { test as it, expect } from './pageTest'; | ||||
| import { test as it, expect } from './pageTest'; | ||||
| 
 | ||||
| it('should fulfill intercepted response', async ({page, server, browserName}) => { | ||||
|   it.fixme(browserName === 'firefox'); | ||||
|  | @ -53,7 +53,7 @@ it('should throw on continue after intercept', async ({page, server, browserName | |||
|     await route.continue(); | ||||
|     fail('did not throw'); | ||||
|   } catch (e) { | ||||
|     expect(e.message).toContain('Cannot call continue after response interception!') | ||||
|     expect(e.message).toContain('Cannot call continue after response interception!'); | ||||
|   } | ||||
| }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -126,7 +126,7 @@ async function runPlaywrightTest(baseDir: string, params: any, env: Env): Promis | |||
|   const reportFile = path.join(outputDir, 'report.json'); | ||||
|   const args = [path.join(__dirname, '..', '..', 'lib', 'cli', 'cli.js'), 'test']; | ||||
|   if (!params.usesCustomOutputDir) | ||||
|     args.push('--output=' + outputDir) | ||||
|     args.push('--output=' + outputDir); | ||||
|   args.push( | ||||
|       '--reporter=dot,json', | ||||
|       '--workers=2', | ||||
|  |  | |||
|  | @ -28,7 +28,7 @@ export class VideoPlayer { | |||
|   videoHeight: number; | ||||
| 
 | ||||
|   constructor(fileName: string) { | ||||
|     var output = spawnSync(ffmpeg, ['-i', fileName, '-r', '25', `${fileName}-%03d.png`]).stderr.toString(); | ||||
|     const output = spawnSync(ffmpeg, ['-i', fileName, '-r', '25', `${fileName}-%03d.png`]).stderr.toString(); | ||||
|     const lines = output.split('\n'); | ||||
|     const streamLine = lines.find(l => l.trim().startsWith('Stream #0:0')); | ||||
|     const resolutionMatch = streamLine.match(/, (\d+)x(\d+),/); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue