chore: unrelease 'fonts' screenshot option (#13300)

This commit is contained in:
Dmitry Gozman 2022-04-04 14:51:11 -07:00 committed by GitHub
parent 732afa7cb9
commit a09b8dfa36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 27 deletions

View File

@ -975,7 +975,6 @@ When set to `"hide"`, screenshot will hide text caret. When set to `"initial"`,
- %%-screenshot-option-quality-%%
- %%-screenshot-option-path-%%
- %%-screenshot-option-scale-%%
- %%-screenshot-option-fonts-%%
- %%-screenshot-option-caret-%%
- %%-screenshot-option-type-%%
- %%-screenshot-option-mask-%%

View File

@ -200,6 +200,7 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> implements
selector: locator._selector,
}));
}
copy.fonts = (options as any)._fonts;
const result = await this._elementChannel.screenshot(copy);
const buffer = Buffer.from(result.binary, 'base64');
if (options.path) {

View File

@ -489,6 +489,7 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
selector: locator._selector,
}));
}
copy.fonts = (options as any)._fonts;
const result = await this._channel.screenshot(copy);
const buffer = Buffer.from(result.binary, 'base64');
if (options.path) {

View File

@ -8154,13 +8154,6 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
*/
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
* `#FF00FF` that completely covers its bounding box.
@ -15748,13 +15741,6 @@ export interface LocatorScreenshotOptions {
*/
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
* `#FF00FF` that completely covers its bounding box.
@ -15932,13 +15918,6 @@ export interface PageScreenshotOptions {
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
* `false`.

View File

@ -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 screenshotOptions = {
animations: config?.animations ?? 'disabled',
fonts: config?.fonts ?? 'ready',
_fonts: config?.fonts ?? 'ready',
scale: config?.scale ?? 'css',
caret: config?.caret ?? 'hide',
...helper.allOptions,

View File

@ -785,13 +785,13 @@ it.describe('page screenshot animations', () => {
const noIconsScreenshot = await page.screenshot();
// Make sure screenshot times out while webfont is stalled.
const error = await page.screenshot({
fonts: 'ready',
_fonts: 'ready',
timeout: 200,
}).catch(e => e);
} as any).catch(e => e);
expect(error.message).toContain('waiting for fonts to load...');
expect(error.message).toContain('Timeout 200ms exceeded');
const [iconsScreenshot] = await Promise.all([
page.screenshot({ fonts: 'ready' }),
page.screenshot({ _fonts: 'ready' } as any),
server.serveFile(serverRequest, serverResponse),
]);
expect(iconsScreenshot).toMatchSnapshot('screenshot-web-font.png', {

View File

@ -369,7 +369,8 @@ test('should compile with different option combinations', async ({ runTSC }) =>
maxDiffPixelRatio: 0.2,
animations: "disabled",
omitBackground: true,
fonts: "nowait",
// TODO: uncomment when enabling "fonts".
// fonts: "nowait",
caret: "initial",
scale: "device",
timeout: 1000,