summary-graph_end-delay-sign_head.js (2639B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /* import-globals-from head.js */ 7 8 // Test for following EndDelaySign component works. 9 // * element existance 10 // * marginInlineStart position 11 // * width 12 // * additinal class 13 14 const TEST_DATA = [ 15 { 16 targetClass: "enddelay-positive", 17 expectedResult: { 18 marginInlineStart: "75%", 19 width: "25%", 20 }, 21 }, 22 { 23 targetClass: "enddelay-negative", 24 expectedResult: { 25 additionalClass: "negative", 26 marginInlineStart: "50%", 27 width: "25%", 28 }, 29 }, 30 { 31 targetClass: "enddelay-with-fill-forwards", 32 expectedResult: { 33 additionalClass: "fill", 34 marginInlineStart: "75%", 35 width: "25%", 36 }, 37 }, 38 { 39 targetClass: "enddelay-with-iterations-infinity", 40 }, 41 { 42 targetClass: "delay-negative", 43 }, 44 ]; 45 46 // eslint-disable-next-line no-unused-vars 47 async function testSummaryGraphEndDelaySign() { 48 await addTab(URL_ROOT + "doc_multi_timings.html"); 49 await removeAnimatedElementsExcept(TEST_DATA.map(t => `.${t.targetClass}`)); 50 const { panel } = await openAnimationInspector(); 51 52 for (const { targetClass, expectedResult } of TEST_DATA) { 53 const animationItemEl = await findAnimationItemByTargetSelector( 54 panel, 55 `.${targetClass}` 56 ); 57 58 info(`Checking endDelay sign existance for ${targetClass}`); 59 const endDelaySignEl = animationItemEl.querySelector( 60 ".animation-end-delay-sign" 61 ); 62 63 if (expectedResult) { 64 ok( 65 endDelaySignEl, 66 "The endDelay sign element should be in animation item element" 67 ); 68 69 function assertExpected(key) { 70 const actual = parseFloat(endDelaySignEl.style[key]); 71 const expected = parseFloat(expectedResult[key]); 72 Assert.less( 73 Math.abs(actual - expected), 74 0.01, 75 `${key} should be ${expected} (got ${actual})` 76 ); 77 } 78 79 assertExpected(`marginInlineStart`); 80 assertExpected(`width`); 81 82 if (expectedResult.additionalClass) { 83 ok( 84 endDelaySignEl.classList.contains(expectedResult.additionalClass), 85 `endDelay sign element should have ${expectedResult.additionalClass} class` 86 ); 87 } else { 88 ok( 89 !endDelaySignEl.classList.contains(expectedResult.additionalClass), 90 "endDelay sign element should not have " + 91 `${expectedResult.additionalClass} class` 92 ); 93 } 94 } else { 95 ok( 96 !endDelaySignEl, 97 "The endDelay sign element should not be in animation item element" 98 ); 99 } 100 } 101 }