browser_rules_cubicbezier-revert-on-ESC.js (1651B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Tests that changes made to the cubic-bezier timing-function in the 7 // cubic-bezier tooltip are reverted when ESC is pressed. 8 9 const TEST_URI = ` 10 <style type='text/css'> 11 body { 12 animation-timing-function: linear; 13 } 14 </style> 15 `; 16 17 add_task(async function () { 18 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 19 const { view } = await openRuleView(); 20 await testPressingEscapeRevertsChanges(view); 21 }); 22 23 async function testPressingEscapeRevertsChanges(view) { 24 const { propEditor } = await openCubicBezierAndChangeCoords( 25 view, 26 1, 27 0, 28 [0.1, 2, 0.9, -1], 29 { 30 selector: "body", 31 name: "animation-timing-function", 32 value: "cubic-bezier(0.1, 2, 0.9, -1)", 33 } 34 ); 35 36 is( 37 propEditor.valueSpan.textContent, 38 "cubic-bezier(.1,2,.9,-1)", 39 "Got expected property value." 40 ); 41 42 await escapeTooltip(view); 43 44 await waitForComputedStyleProperty( 45 "body", 46 null, 47 "animation-timing-function", 48 "linear" 49 ); 50 is( 51 propEditor.valueSpan.textContent, 52 "linear", 53 "Got expected property value." 54 ); 55 } 56 57 async function escapeTooltip(view) { 58 info("Pressing ESCAPE to close the tooltip"); 59 60 const bezierTooltip = view.tooltips.getTooltip("cubicBezier"); 61 const widget = await bezierTooltip.widget; 62 const onHidden = bezierTooltip.tooltip.once("hidden"); 63 const onModifications = view.once("ruleview-changed"); 64 focusAndSendKey(widget.parent.ownerDocument.defaultView, "ESCAPE"); 65 await onHidden; 66 await onModifications; 67 }