chore: unrelease 'fonts' screenshot option (#13300)
This commit is contained in:
parent
732afa7cb9
commit
a09b8dfa36
|
|
@ -975,7 +975,6 @@ When set to `"hide"`, screenshot will hide text caret. When set to `"initial"`,
|
||||||
- %%-screenshot-option-quality-%%
|
- %%-screenshot-option-quality-%%
|
||||||
- %%-screenshot-option-path-%%
|
- %%-screenshot-option-path-%%
|
||||||
- %%-screenshot-option-scale-%%
|
- %%-screenshot-option-scale-%%
|
||||||
- %%-screenshot-option-fonts-%%
|
|
||||||
- %%-screenshot-option-caret-%%
|
- %%-screenshot-option-caret-%%
|
||||||
- %%-screenshot-option-type-%%
|
- %%-screenshot-option-type-%%
|
||||||
- %%-screenshot-option-mask-%%
|
- %%-screenshot-option-mask-%%
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,7 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> implements
|
||||||
selector: locator._selector,
|
selector: locator._selector,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
copy.fonts = (options as any)._fonts;
|
||||||
const result = await this._elementChannel.screenshot(copy);
|
const result = await this._elementChannel.screenshot(copy);
|
||||||
const buffer = Buffer.from(result.binary, 'base64');
|
const buffer = Buffer.from(result.binary, 'base64');
|
||||||
if (options.path) {
|
if (options.path) {
|
||||||
|
|
|
||||||
|
|
@ -489,6 +489,7 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
|
||||||
selector: locator._selector,
|
selector: locator._selector,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
copy.fonts = (options as any)._fonts;
|
||||||
const result = await this._channel.screenshot(copy);
|
const result = await this._channel.screenshot(copy);
|
||||||
const buffer = Buffer.from(result.binary, 'base64');
|
const buffer = Buffer.from(result.binary, 'base64');
|
||||||
if (options.path) {
|
if (options.path) {
|
||||||
|
|
|
||||||
21
packages/playwright-core/types/types.d.ts
vendored
21
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -8154,13 +8154,6 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
|
||||||
*/
|
*/
|
||||||
caret?: "hide"|"initial";
|
caret?: "hide"|"initial";
|
||||||
|
|
||||||
/**
|
|
||||||
* When set to `"ready"`, screenshot will wait for
|
|
||||||
* [`document.fonts.ready`](https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready) promise to resolve in all
|
|
||||||
* frames. Defaults to `"nowait"`.
|
|
||||||
*/
|
|
||||||
fonts?: "ready"|"nowait";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
|
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
|
||||||
* `#FF00FF` that completely covers its bounding box.
|
* `#FF00FF` that completely covers its bounding box.
|
||||||
|
|
@ -15748,13 +15741,6 @@ export interface LocatorScreenshotOptions {
|
||||||
*/
|
*/
|
||||||
caret?: "hide"|"initial";
|
caret?: "hide"|"initial";
|
||||||
|
|
||||||
/**
|
|
||||||
* When set to `"ready"`, screenshot will wait for
|
|
||||||
* [`document.fonts.ready`](https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready) promise to resolve in all
|
|
||||||
* frames. Defaults to `"nowait"`.
|
|
||||||
*/
|
|
||||||
fonts?: "ready"|"nowait";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
|
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
|
||||||
* `#FF00FF` that completely covers its bounding box.
|
* `#FF00FF` that completely covers its bounding box.
|
||||||
|
|
@ -15932,13 +15918,6 @@ export interface PageScreenshotOptions {
|
||||||
height: number;
|
height: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* When set to `"ready"`, screenshot will wait for
|
|
||||||
* [`document.fonts.ready`](https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready) promise to resolve in all
|
|
||||||
* frames. Defaults to `"nowait"`.
|
|
||||||
*/
|
|
||||||
fonts?: "ready"|"nowait";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
|
* When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
|
||||||
* `false`.
|
* `false`.
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@ export async function toHaveScreenshot(
|
||||||
const [page, locator] = pageOrLocator.constructor.name === 'Page' ? [(pageOrLocator as PageEx), undefined] : [(pageOrLocator as Locator).page() as PageEx, pageOrLocator as LocatorEx];
|
const [page, locator] = pageOrLocator.constructor.name === 'Page' ? [(pageOrLocator as PageEx), undefined] : [(pageOrLocator as Locator).page() as PageEx, pageOrLocator as LocatorEx];
|
||||||
const screenshotOptions = {
|
const screenshotOptions = {
|
||||||
animations: config?.animations ?? 'disabled',
|
animations: config?.animations ?? 'disabled',
|
||||||
fonts: config?.fonts ?? 'ready',
|
_fonts: config?.fonts ?? 'ready',
|
||||||
scale: config?.scale ?? 'css',
|
scale: config?.scale ?? 'css',
|
||||||
caret: config?.caret ?? 'hide',
|
caret: config?.caret ?? 'hide',
|
||||||
...helper.allOptions,
|
...helper.allOptions,
|
||||||
|
|
|
||||||
|
|
@ -785,13 +785,13 @@ it.describe('page screenshot animations', () => {
|
||||||
const noIconsScreenshot = await page.screenshot();
|
const noIconsScreenshot = await page.screenshot();
|
||||||
// Make sure screenshot times out while webfont is stalled.
|
// Make sure screenshot times out while webfont is stalled.
|
||||||
const error = await page.screenshot({
|
const error = await page.screenshot({
|
||||||
fonts: 'ready',
|
_fonts: 'ready',
|
||||||
timeout: 200,
|
timeout: 200,
|
||||||
}).catch(e => e);
|
} as any).catch(e => e);
|
||||||
expect(error.message).toContain('waiting for fonts to load...');
|
expect(error.message).toContain('waiting for fonts to load...');
|
||||||
expect(error.message).toContain('Timeout 200ms exceeded');
|
expect(error.message).toContain('Timeout 200ms exceeded');
|
||||||
const [iconsScreenshot] = await Promise.all([
|
const [iconsScreenshot] = await Promise.all([
|
||||||
page.screenshot({ fonts: 'ready' }),
|
page.screenshot({ _fonts: 'ready' } as any),
|
||||||
server.serveFile(serverRequest, serverResponse),
|
server.serveFile(serverRequest, serverResponse),
|
||||||
]);
|
]);
|
||||||
expect(iconsScreenshot).toMatchSnapshot('screenshot-web-font.png', {
|
expect(iconsScreenshot).toMatchSnapshot('screenshot-web-font.png', {
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,8 @@ test('should compile with different option combinations', async ({ runTSC }) =>
|
||||||
maxDiffPixelRatio: 0.2,
|
maxDiffPixelRatio: 0.2,
|
||||||
animations: "disabled",
|
animations: "disabled",
|
||||||
omitBackground: true,
|
omitBackground: true,
|
||||||
fonts: "nowait",
|
// TODO: uncomment when enabling "fonts".
|
||||||
|
// fonts: "nowait",
|
||||||
caret: "initial",
|
caret: "initial",
|
||||||
scale: "device",
|
scale: "device",
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue