chore: spell overridden (#5605)
This commit is contained in:
parent
c91159f3f7
commit
8906ba332c
|
|
@ -245,7 +245,7 @@ class NetworkRequest {
|
||||||
const body = atob(postData);
|
const body = atob(postData);
|
||||||
synthesized.setData(body, body.length);
|
synthesized.setData(body, body.length);
|
||||||
|
|
||||||
const overridenHeader = (lowerCaseName, defaultValue) => {
|
const overriddenHeader = (lowerCaseName, defaultValue) => {
|
||||||
if (headers) {
|
if (headers) {
|
||||||
for (const header of headers) {
|
for (const header of headers) {
|
||||||
if (header.name.toLowerCase() === lowerCaseName) {
|
if (header.name.toLowerCase() === lowerCaseName) {
|
||||||
|
|
@ -256,8 +256,8 @@ class NetworkRequest {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
// Clear content-length, so that upload stream resets it.
|
// Clear content-length, so that upload stream resets it.
|
||||||
this.httpChannel.setRequestHeader('content-length', overridenHeader('content-length', ''), false /* merge */);
|
this.httpChannel.setRequestHeader('content-length', overriddenHeader('content-length', ''), false /* merge */);
|
||||||
this.httpChannel.explicitSetUploadStream(synthesized, overridenHeader('content-type', 'application/octet-stream'), -1, this.httpChannel.requestMethod, false);
|
this.httpChannel.explicitSetUploadStream(synthesized, overriddenHeader('content-type', 'application/octet-stream'), -1, this.httpChannel.requestMethod, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ export default class UtilityScript {
|
||||||
if (value && typeof value === 'object' && typeof value.then === 'function') {
|
if (value && typeof value === 'object' && typeof value.then === 'function') {
|
||||||
return (async () => {
|
return (async () => {
|
||||||
// By using async function we ensure that return value is a native Promise,
|
// By using async function we ensure that return value is a native Promise,
|
||||||
// and not some overriden Promise in the page.
|
// and not some overridden Promise in the page.
|
||||||
// This makes Firefox and WebKit debugging protocols recognize it as a Promise,
|
// This makes Firefox and WebKit debugging protocols recognize it as a Promise,
|
||||||
// properly await and return the value.
|
// properly await and return the value.
|
||||||
const promiseValue = await value;
|
const promiseValue = await value;
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ export class Route extends SdkObject {
|
||||||
const newUrl = new URL(overrides.url);
|
const newUrl = new URL(overrides.url);
|
||||||
const oldUrl = new URL(this._request.url());
|
const oldUrl = new URL(this._request.url());
|
||||||
if (oldUrl.protocol !== newUrl.protocol)
|
if (oldUrl.protocol !== newUrl.protocol)
|
||||||
throw new Error('New URL must have same protocol as overriden URL');
|
throw new Error('New URL must have same protocol as overridden URL');
|
||||||
}
|
}
|
||||||
await this._delegate.continue(overrides);
|
await this._delegate.continue(overrides);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,19 +73,19 @@ export class Screenshotter {
|
||||||
if (options.fullPage) {
|
if (options.fullPage) {
|
||||||
const fullPageSize = await this._fullPageSize();
|
const fullPageSize = await this._fullPageSize();
|
||||||
let documentRect = { x: 0, y: 0, width: fullPageSize.width, height: fullPageSize.height };
|
let documentRect = { x: 0, y: 0, width: fullPageSize.width, height: fullPageSize.height };
|
||||||
let overridenViewportSize: types.Size | null = null;
|
let overriddenViewportSize: types.Size | null = null;
|
||||||
const fitsViewport = fullPageSize.width <= viewportSize.width && fullPageSize.height <= viewportSize.height;
|
const fitsViewport = fullPageSize.width <= viewportSize.width && fullPageSize.height <= viewportSize.height;
|
||||||
if (!this._page._delegate.canScreenshotOutsideViewport() && !fitsViewport) {
|
if (!this._page._delegate.canScreenshotOutsideViewport() && !fitsViewport) {
|
||||||
overridenViewportSize = fullPageSize;
|
overriddenViewportSize = fullPageSize;
|
||||||
progress.throwIfAborted(); // Avoid side effects.
|
progress.throwIfAborted(); // Avoid side effects.
|
||||||
await this._page.setViewportSize(overridenViewportSize);
|
await this._page.setViewportSize(overriddenViewportSize);
|
||||||
progress.cleanupWhenAborted(() => this._restoreViewport(originalViewportSize));
|
progress.cleanupWhenAborted(() => this._restoreViewport(originalViewportSize));
|
||||||
}
|
}
|
||||||
if (options.clip)
|
if (options.clip)
|
||||||
documentRect = trimClipToSize(options.clip, documentRect);
|
documentRect = trimClipToSize(options.clip, documentRect);
|
||||||
const buffer = await this._screenshot(progress, format, documentRect, undefined, options);
|
const buffer = await this._screenshot(progress, format, documentRect, undefined, options);
|
||||||
progress.throwIfAborted(); // Avoid restoring after failure - should be done by cleanup.
|
progress.throwIfAborted(); // Avoid restoring after failure - should be done by cleanup.
|
||||||
if (overridenViewportSize)
|
if (overriddenViewportSize)
|
||||||
await this._restoreViewport(originalViewportSize);
|
await this._restoreViewport(originalViewportSize);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
@ -106,15 +106,15 @@ export class Screenshotter {
|
||||||
assert(boundingBox.width !== 0, 'Node has 0 width.');
|
assert(boundingBox.width !== 0, 'Node has 0 width.');
|
||||||
assert(boundingBox.height !== 0, 'Node has 0 height.');
|
assert(boundingBox.height !== 0, 'Node has 0 height.');
|
||||||
|
|
||||||
let overridenViewportSize: types.Size | null = null;
|
let overriddenViewportSize: types.Size | null = null;
|
||||||
const fitsViewport = boundingBox.width <= viewportSize.width && boundingBox.height <= viewportSize.height;
|
const fitsViewport = boundingBox.width <= viewportSize.width && boundingBox.height <= viewportSize.height;
|
||||||
if (!this._page._delegate.canScreenshotOutsideViewport() && !fitsViewport) {
|
if (!this._page._delegate.canScreenshotOutsideViewport() && !fitsViewport) {
|
||||||
overridenViewportSize = helper.enclosingIntSize({
|
overriddenViewportSize = helper.enclosingIntSize({
|
||||||
width: Math.max(viewportSize.width, boundingBox.width),
|
width: Math.max(viewportSize.width, boundingBox.width),
|
||||||
height: Math.max(viewportSize.height, boundingBox.height),
|
height: Math.max(viewportSize.height, boundingBox.height),
|
||||||
});
|
});
|
||||||
progress.throwIfAborted(); // Avoid side effects.
|
progress.throwIfAborted(); // Avoid side effects.
|
||||||
await this._page.setViewportSize(overridenViewportSize);
|
await this._page.setViewportSize(overriddenViewportSize);
|
||||||
progress.cleanupWhenAborted(() => this._restoreViewport(originalViewportSize));
|
progress.cleanupWhenAborted(() => this._restoreViewport(originalViewportSize));
|
||||||
|
|
||||||
await handle._waitAndScrollIntoViewIfNeeded(progress);
|
await handle._waitAndScrollIntoViewIfNeeded(progress);
|
||||||
|
|
@ -131,7 +131,7 @@ export class Screenshotter {
|
||||||
documentRect.y += scrollOffset.y;
|
documentRect.y += scrollOffset.y;
|
||||||
const buffer = await this._screenshot(progress, format, helper.enclosingIntRect(documentRect), undefined, options);
|
const buffer = await this._screenshot(progress, format, helper.enclosingIntRect(documentRect), undefined, options);
|
||||||
progress.throwIfAborted(); // Avoid restoring after failure - should be done by cleanup.
|
progress.throwIfAborted(); // Avoid restoring after failure - should be done by cleanup.
|
||||||
if (overridenViewportSize)
|
if (overriddenViewportSize)
|
||||||
await this._restoreViewport(originalViewportSize);
|
await this._restoreViewport(originalViewportSize);
|
||||||
return buffer;
|
return buffer;
|
||||||
}).catch(rewriteError);
|
}).catch(rewriteError);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export * as trace from '../common/traceEvents';
|
||||||
export type SerializedFrameSnapshot = {
|
export type SerializedFrameSnapshot = {
|
||||||
html: string;
|
html: string;
|
||||||
resourcesByUrl: { [key: string]: { resourceId: string, frameId: string }[] };
|
resourcesByUrl: { [key: string]: { resourceId: string, frameId: string }[] };
|
||||||
overridenUrls: { [key: string]: boolean };
|
overriddenUrls: { [key: string]: boolean };
|
||||||
resourceOverrides: { [key: string]: string };
|
resourceOverrides: { [key: string]: string };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -83,11 +83,11 @@ export class FrameSnapshot {
|
||||||
html += `<script>${this.contextEntry.created.snapshotScript}</script>`;
|
html += `<script>${this.contextEntry.created.snapshotScript}</script>`;
|
||||||
|
|
||||||
const resourcesByUrl = this.contextEntry.resourcesByUrl;
|
const resourcesByUrl = this.contextEntry.resourcesByUrl;
|
||||||
const overridenUrls = this.contextEntry.overridenUrls;
|
const overriddenUrls = this.contextEntry.overriddenUrls;
|
||||||
const resourceOverrides: any = {};
|
const resourceOverrides: any = {};
|
||||||
for (const o of this._snapshots[this._index].snapshot.resourceOverrides)
|
for (const o of this._snapshots[this._index].snapshot.resourceOverrides)
|
||||||
resourceOverrides[o.url] = o.sha1;
|
resourceOverrides[o.url] = o.sha1;
|
||||||
return { html, resourcesByUrl, overridenUrls, resourceOverrides };
|
return { html, resourcesByUrl, overriddenUrls: overriddenUrls, resourceOverrides };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,18 +171,18 @@ export class SnapshotServer {
|
||||||
|
|
||||||
if (request.mode === 'navigate') {
|
if (request.mode === 'navigate') {
|
||||||
const htmlResponse = await fetch(`/snapshot-data?pageId=${parsed.pageId}&snapshotId=${parsed.snapshotId || ''}×tamp=${parsed.timestamp || ''}&frameId=${parsed.frameId || ''}`);
|
const htmlResponse = await fetch(`/snapshot-data?pageId=${parsed.pageId}&snapshotId=${parsed.snapshotId || ''}×tamp=${parsed.timestamp || ''}&frameId=${parsed.frameId || ''}`);
|
||||||
const { html, resourcesByUrl, overridenUrls, resourceOverrides } = await htmlResponse.json();
|
const { html, resourcesByUrl, overriddenUrls, resourceOverrides } = await htmlResponse.json();
|
||||||
if (!html)
|
if (!html)
|
||||||
return respondNotAvailable();
|
return respondNotAvailable();
|
||||||
pageToResourcesByUrl.set(parsed.pageId, resourcesByUrl);
|
pageToResourcesByUrl.set(parsed.pageId, resourcesByUrl);
|
||||||
pageToOverriddenUrls.set(parsed.pageId, overridenUrls);
|
pageToOverriddenUrls.set(parsed.pageId, overriddenUrls);
|
||||||
snapshotToResourceOverrides.set(parsed.snapshotId + '@' + parsed.timestamp, resourceOverrides);
|
snapshotToResourceOverrides.set(parsed.snapshotId + '@' + parsed.timestamp, resourceOverrides);
|
||||||
const response = new Response(html, { status: 200, headers: { 'Content-Type': 'text/html' } });
|
const response = new Response(html, { status: 200, headers: { 'Content-Type': 'text/html' } });
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
const resourcesByUrl = pageToResourcesByUrl.get(parsed.pageId);
|
const resourcesByUrl = pageToResourcesByUrl.get(parsed.pageId);
|
||||||
const overridenUrls = pageToOverriddenUrls.get(parsed.pageId);
|
const overriddenUrls = pageToOverriddenUrls.get(parsed.pageId);
|
||||||
const resourceOverrides = snapshotToResourceOverrides.get(parsed.snapshotId + '@' + parsed.timestamp);
|
const resourceOverrides = snapshotToResourceOverrides.get(parsed.snapshotId + '@' + parsed.timestamp);
|
||||||
const urlWithoutHash = removeHash(request.url);
|
const urlWithoutHash = removeHash(request.url);
|
||||||
const resourcesWithUrl = resourcesByUrl?.[urlWithoutHash] || [];
|
const resourcesWithUrl = resourcesByUrl?.[urlWithoutHash] || [];
|
||||||
|
|
@ -201,7 +201,7 @@ export class SnapshotServer {
|
||||||
// as the original request url.
|
// as the original request url.
|
||||||
// Response url turns into resource base uri that is used to resolve
|
// Response url turns into resource base uri that is used to resolve
|
||||||
// relative links, e.g. url(/foo/bar) in style sheets.
|
// relative links, e.g. url(/foo/bar) in style sheets.
|
||||||
if (overridenUrls?.[urlWithoutHash]) {
|
if (overriddenUrls?.[urlWithoutHash]) {
|
||||||
// No cache, so that we refetch overridden resources.
|
// No cache, so that we refetch overridden resources.
|
||||||
headers.set('Cache-Control', 'no-cache');
|
headers.set('Cache-Control', 'no-cache');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export class TraceModel {
|
||||||
destroyed: undefined as any,
|
destroyed: undefined as any,
|
||||||
pages: [],
|
pages: [],
|
||||||
resourcesByUrl: {},
|
resourcesByUrl: {},
|
||||||
overridenUrls: {}
|
overriddenUrls: {}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ export class TraceModel {
|
||||||
override.sha1 = refOverride?.sha1;
|
override.sha1 = refOverride?.sha1;
|
||||||
delete override.ref;
|
delete override.ref;
|
||||||
}
|
}
|
||||||
contextEntry.overridenUrls[override.url] = true;
|
contextEntry.overriddenUrls[override.url] = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +184,7 @@ export type ContextEntry = {
|
||||||
destroyed: trace.ContextDestroyedTraceEvent;
|
destroyed: trace.ContextDestroyedTraceEvent;
|
||||||
pages: PageEntry[];
|
pages: PageEntry[];
|
||||||
resourcesByUrl: { [key: string]: { resourceId: string, frameId: string }[] };
|
resourcesByUrl: { [key: string]: { resourceId: string, frameId: string }[] };
|
||||||
overridenUrls: { [key: string]: boolean };
|
overriddenUrls: { [key: string]: boolean };
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InterestingPageEvent = trace.DialogOpenedEvent | trace.DialogClosedEvent | trace.NavigationEvent | trace.LoadEvent;
|
export type InterestingPageEvent = trace.DialogOpenedEvent | trace.DialogClosedEvent | trace.NavigationEvent | trace.LoadEvent;
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ it('should not allow changing protocol when overriding url', async ({page, serve
|
||||||
});
|
});
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
expect(error).toBeTruthy();
|
expect(error).toBeTruthy();
|
||||||
expect(error.message).toContain('New URL must have same protocol as overriden URL');
|
expect(error.message).toContain('New URL must have same protocol as overridden URL');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should override method along with url', async ({page, server}) => {
|
it('should override method along with url', async ({page, server}) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue