chore: add "allow" as a default value for animations. (#12663)

This commit is contained in:
Andrey Lushnikov 2022-03-10 18:15:36 -07:00 committed by GitHub
parent 49e66c7f08
commit 42765804bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 14 deletions

View file

@ -902,12 +902,14 @@ Note that outer and inner locators must belong to the same frame. Inner locator
- %%-locator-option-has-%% - %%-locator-option-has-%%
## screenshot-option-animations ## screenshot-option-animations
- `animations` <[ScreenshotAnimations]<"disabled">> - `animations` <[ScreenshotAnimations]<"disabled"|"allow">>
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration: When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:
* finite animations are fast-forwarded to completion, so they'll fire `transitionend` event. * finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* infinite animations are canceled to initial state, and then played over after the screenshot. * infinite animations are canceled to initial state, and then played over after the screenshot.
Defaults to `"allow"` that leaves animations untouched.
## screenshot-option-omit-background ## screenshot-option-omit-background
- `omitBackground` <[boolean]> - `omitBackground` <[boolean]>

View file

@ -1503,7 +1503,7 @@ export type PageExpectScreenshotParams = {
screenshotOptions?: { screenshotOptions?: {
omitBackground?: boolean, omitBackground?: boolean,
fullPage?: boolean, fullPage?: boolean,
animations?: 'disabled', animations?: 'disabled' | 'allow',
clip?: Rect, clip?: Rect,
mask?: { mask?: {
frame: FrameChannel, frame: FrameChannel,
@ -1526,7 +1526,7 @@ export type PageExpectScreenshotOptions = {
screenshotOptions?: { screenshotOptions?: {
omitBackground?: boolean, omitBackground?: boolean,
fullPage?: boolean, fullPage?: boolean,
animations?: 'disabled', animations?: 'disabled' | 'allow',
clip?: Rect, clip?: Rect,
mask?: { mask?: {
frame: FrameChannel, frame: FrameChannel,
@ -1547,7 +1547,7 @@ export type PageScreenshotParams = {
quality?: number, quality?: number,
omitBackground?: boolean, omitBackground?: boolean,
fullPage?: boolean, fullPage?: boolean,
animations?: 'disabled', animations?: 'disabled' | 'allow',
clip?: Rect, clip?: Rect,
size?: 'css' | 'device', size?: 'css' | 'device',
fonts?: 'ready' | 'nowait', fonts?: 'ready' | 'nowait',
@ -1562,7 +1562,7 @@ export type PageScreenshotOptions = {
quality?: number, quality?: number,
omitBackground?: boolean, omitBackground?: boolean,
fullPage?: boolean, fullPage?: boolean,
animations?: 'disabled', animations?: 'disabled' | 'allow',
clip?: Rect, clip?: Rect,
size?: 'css' | 'device', size?: 'css' | 'device',
fonts?: 'ready' | 'nowait', fonts?: 'ready' | 'nowait',
@ -2864,7 +2864,7 @@ export type ElementHandleScreenshotParams = {
type?: 'png' | 'jpeg', type?: 'png' | 'jpeg',
quality?: number, quality?: number,
omitBackground?: boolean, omitBackground?: boolean,
animations?: 'disabled', animations?: 'disabled' | 'allow',
size?: 'css' | 'device', size?: 'css' | 'device',
fonts?: 'ready' | 'nowait', fonts?: 'ready' | 'nowait',
mask?: { mask?: {
@ -2877,7 +2877,7 @@ export type ElementHandleScreenshotOptions = {
type?: 'png' | 'jpeg', type?: 'png' | 'jpeg',
quality?: number, quality?: number,
omitBackground?: boolean, omitBackground?: boolean,
animations?: 'disabled', animations?: 'disabled' | 'allow',
size?: 'css' | 'device', size?: 'css' | 'device',
fonts?: 'ready' | 'nowait', fonts?: 'ready' | 'nowait',
mask?: { mask?: {

View file

@ -1015,6 +1015,7 @@ Page:
type: enum? type: enum?
literals: literals:
- disabled - disabled
- allow
clip: Rect? clip: Rect?
mask: mask:
type: array? type: array?
@ -1049,6 +1050,7 @@ Page:
type: enum? type: enum?
literals: literals:
- disabled - disabled
- allow
clip: Rect? clip: Rect?
size: size:
type: enum? type: enum?
@ -2224,6 +2226,7 @@ ElementHandle:
type: enum? type: enum?
literals: literals:
- disabled - disabled
- allow
size: size:
type: enum? type: enum?
literals: literals:

View file

@ -556,7 +556,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
screenshotOptions: tOptional(tObject({ screenshotOptions: tOptional(tObject({
omitBackground: tOptional(tBoolean), omitBackground: tOptional(tBoolean),
fullPage: tOptional(tBoolean), fullPage: tOptional(tBoolean),
animations: tOptional(tEnum(['disabled'])), animations: tOptional(tEnum(['disabled', 'allow'])),
clip: tOptional(tType('Rect')), clip: tOptional(tType('Rect')),
mask: tOptional(tArray(tObject({ mask: tOptional(tArray(tObject({
frame: tChannel('Frame'), frame: tChannel('Frame'),
@ -570,7 +570,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
quality: tOptional(tNumber), quality: tOptional(tNumber),
omitBackground: tOptional(tBoolean), omitBackground: tOptional(tBoolean),
fullPage: tOptional(tBoolean), fullPage: tOptional(tBoolean),
animations: tOptional(tEnum(['disabled'])), animations: tOptional(tEnum(['disabled', 'allow'])),
clip: tOptional(tType('Rect')), clip: tOptional(tType('Rect')),
size: tOptional(tEnum(['css', 'device'])), size: tOptional(tEnum(['css', 'device'])),
fonts: tOptional(tEnum(['ready', 'nowait'])), fonts: tOptional(tEnum(['ready', 'nowait'])),
@ -1067,7 +1067,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
type: tOptional(tEnum(['png', 'jpeg'])), type: tOptional(tEnum(['png', 'jpeg'])),
quality: tOptional(tNumber), quality: tOptional(tNumber),
omitBackground: tOptional(tBoolean), omitBackground: tOptional(tBoolean),
animations: tOptional(tEnum(['disabled'])), animations: tOptional(tEnum(['disabled', 'allow'])),
size: tOptional(tEnum(['css', 'device'])), size: tOptional(tEnum(['css', 'device'])),
fonts: tOptional(tEnum(['ready', 'nowait'])), fonts: tOptional(tEnum(['ready', 'nowait'])),
mask: tOptional(tArray(tObject({ mask: tOptional(tArray(tObject({

View file

@ -8069,8 +8069,10 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* depending on their duration: * depending on their duration:
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event. * - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot. * - infinite animations are canceled to initial state, and then played over after the screenshot.
*
* Defaults to `"allow"`.
*/ */
animations?: "disabled"; animations?: "disabled"|"allow";
/** /**
* When set to `"ready"`, screenshot will wait for * When set to `"ready"`, screenshot will wait for
@ -15597,8 +15599,10 @@ export interface LocatorScreenshotOptions {
* depending on their duration: * depending on their duration:
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event. * - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot. * - infinite animations are canceled to initial state, and then played over after the screenshot.
*
* Defaults to `"allow"`.
*/ */
animations?: "disabled"; animations?: "disabled"|"allow";
/** /**
* When set to `"ready"`, screenshot will wait for * When set to `"ready"`, screenshot will wait for
@ -15748,8 +15752,10 @@ export interface PageScreenshotOptions {
* depending on their duration: * depending on their duration:
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event. * - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot. * - infinite animations are canceled to initial state, and then played over after the screenshot.
*
* Defaults to `"allow"`.
*/ */
animations?: "disabled"; animations?: "disabled"|"allow";
/** /**
* An object which specifies clipping of the resulting image. Should have the following fields: * An object which specifies clipping of the resulting image. Should have the following fields:

View file

@ -564,7 +564,7 @@ it.describe('page screenshot animations', () => {
}); });
await rafraf(page); await rafraf(page);
// Make sure finite transition is not restarted. // Make sure finite transition is not restarted.
const screenshot2 = await div.screenshot(); const screenshot2 = await div.screenshot({ animations: 'allow' });
expect(screenshot1.equals(screenshot2)).toBe(true); expect(screenshot1.equals(screenshot2)).toBe(true);
expect(await page.evaluate(() => window['__TRANSITION_END'])).toBe(true); expect(await page.evaluate(() => window['__TRANSITION_END'])).toBe(true);