playwright-core
Advanced tools
Comparing version 1.45.0-alpha-2024-05-21 to 1.45.0-alpha-2024-05-22
@@ -348,2 +348,3 @@ "use strict"; | ||
const getResponseBody = async () => { | ||
var _request$_route; | ||
const contentLengthHeader = Object.entries(responsePayload.headers).find(header => header[0].toLowerCase() === 'content-length'); | ||
@@ -357,2 +358,5 @@ const expectedLength = contentLengthHeader ? +contentLengthHeader[1] : undefined; | ||
// Make sure no network requests sent while reading the body for fulfilled requests. | ||
if ((_request$_route = request._route) !== null && _request$_route !== void 0 && _request$_route._fulfilled) return Buffer.from(''); | ||
// For <link prefetch we are going to receive empty body with non-empty content-length expectation. Reach out for the actual content. | ||
@@ -573,2 +577,3 @@ const resource = await session.send('Network.loadNetworkResource', { | ||
this._alreadyContinuedParams = void 0; | ||
this._fulfilled = false; | ||
this._session = session; | ||
@@ -590,2 +595,3 @@ this._interceptionId = interceptionId; | ||
async fulfill(response) { | ||
this._fulfilled = true; | ||
const body = response.isBase64 ? response.body : Buffer.from(response.body).toString('base64'); | ||
@@ -592,0 +598,0 @@ const responseHeaders = splitSetCookieHeader(response.headers); |
@@ -225,6 +225,12 @@ "use strict"; | ||
}); | ||
// All waitForLines must be started immediately. | ||
// Otherwise the lines might come before we are ready. | ||
const waitForXserverError = new Promise(async (resolve, reject) => { | ||
waitForLine(progress, launchedProcess, /Unable to open X display/).then(() => reject(new Error(['Unable to open X display!', `================================`, 'Most likely this is because there is no X server available.', "Use 'xvfb-run' on Linux to launch your tests with an emulated display server.", "For example: 'xvfb-run npm run test:e2e'", `================================`, progress.metadata.log].join('\n')))).catch(() => {}); | ||
}); | ||
const nodeMatch = await waitForLine(progress, launchedProcess, /^Debugger listening on (ws:\/\/.*)$/); | ||
const nodeMatchPromise = waitForLine(progress, launchedProcess, /^Debugger listening on (ws:\/\/.*)$/); | ||
const chromeMatchPromise = waitForLine(progress, launchedProcess, /^DevTools listening on (ws:\/\/.*)$/); | ||
const debuggerDisconnectPromise = waitForLine(progress, launchedProcess, /Waiting for the debugger to disconnect\.\.\./); | ||
const nodeMatch = await nodeMatchPromise; | ||
const nodeTransport = await _transport.WebSocketTransport.connect(progress, nodeMatch[1]); | ||
@@ -234,6 +240,6 @@ const nodeConnection = new _crConnection.CRConnection(nodeTransport, _helper.helper.debugProtocolLogger(), browserLogsCollector); | ||
// Immediately release exiting process under debug. | ||
waitForLine(progress, launchedProcess, /Waiting for the debugger to disconnect\.\.\./).then(() => { | ||
debuggerDisconnectPromise.then(() => { | ||
nodeTransport.close(); | ||
}).catch(() => {}); | ||
const chromeMatch = await Promise.race([waitForLine(progress, launchedProcess, /^DevTools listening on (ws:\/\/.*)$/), waitForXserverError]); | ||
const chromeMatch = await Promise.race([chromeMatchPromise, waitForXserverError]); | ||
const chromeTransport = await _transport.WebSocketTransport.connect(progress, chromeMatch[1]); | ||
@@ -240,0 +246,0 @@ const browserProcess = { |
@@ -227,2 +227,3 @@ "use strict"; | ||
if (redirectStatus.includes(response.statusCode) && options.maxRedirects >= 0) { | ||
var _response$headers$loc; | ||
if (!options.maxRedirects) { | ||
@@ -263,8 +264,11 @@ reject(new Error('Max redirect count exceeded')); | ||
// HTTP-redirect fetch step 4: If locationURL is null, then return response. | ||
if (response.headers.location) { | ||
// Best-effort UTF-8 decoding, per spec it's US-ASCII only, but browsers are more lenient. | ||
// Node.js parses it as Latin1 via std::v8::String, so we convert it to UTF-8. | ||
const locationHeaderValue = Buffer.from((_response$headers$loc = response.headers.location) !== null && _response$headers$loc !== void 0 ? _response$headers$loc : '', 'latin1').toString('utf8'); | ||
if (locationHeaderValue) { | ||
let locationURL; | ||
try { | ||
locationURL = new URL(response.headers.location, url); | ||
locationURL = new URL(locationHeaderValue, url); | ||
} catch (error) { | ||
reject(new Error(`uri requested responds with an invalid redirect URL: ${response.headers.location}`)); | ||
reject(new Error(`uri requested responds with an invalid redirect URL: ${locationHeaderValue}`)); | ||
request.destroy(); | ||
@@ -271,0 +275,0 @@ return; |
@@ -98,2 +98,3 @@ "use strict"; | ||
if (options.headed) params.append('headed', ''); | ||
if (options.outputDir) params.append('outputDir', options.outputDir); | ||
for (const reporter of options.reporter || []) params.append('reporter', reporter); | ||
@@ -100,0 +101,0 @@ const urlPath = `./trace/${options.webApp || 'index.html'}?${params.toString()}`; |
@@ -32,5 +32,7 @@ "use strict"; | ||
} | ||
function getAsBooleanFromENV(name) { | ||
function getAsBooleanFromENV(name, defaultValue) { | ||
const value = getFromENV(name); | ||
return !!value && value !== 'false' && value !== '0'; | ||
if (value === 'false' || value === '0') return false; | ||
if (value) return true; | ||
return !!defaultValue; | ||
} | ||
@@ -37,0 +39,0 @@ function getPackageManager() { |
{ | ||
"name": "playwright-core", | ||
"version": "1.45.0-alpha-2024-05-21", | ||
"version": "1.45.0-alpha-2024-05-22", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7131782
100198