Commit 584db3f5 authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Implement onremove event for web animations.

Spec:
https://drafts.csswg.org/web-animations-1/#remove-replaced-animations

Intent:
https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/H5sz_dg6fKc/1X7K7U4XCgAJ

Bug: 981905
Change-Id: I9267e3e4fda14133f2edcc0e8aea1e8a031959a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2020245
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735437}
parent 0d3547ab
...@@ -2508,6 +2508,8 @@ enum WebFeature { ...@@ -2508,6 +2508,8 @@ enum WebFeature {
kTaskControllerSetPriority= 3143, kTaskControllerSetPriority= 3143,
kTaskSignalPriority = 3144, kTaskSignalPriority = 3144,
kSchedulerPostTask = 3145, kSchedulerPostTask = 3145,
kV8Animation_Onremove_AttributeGetter = 3146,
kV8Animation_Onremove_AttributeSetter = 3147,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -173,6 +173,7 @@ class CORE_EXPORT Animation : public EventTargetWithInlineData, ...@@ -173,6 +173,7 @@ class CORE_EXPORT Animation : public EventTargetWithInlineData,
DEFINE_ATTRIBUTE_EVENT_LISTENER(finish, kFinish) DEFINE_ATTRIBUTE_EVENT_LISTENER(finish, kFinish)
DEFINE_ATTRIBUTE_EVENT_LISTENER(cancel, kCancel) DEFINE_ATTRIBUTE_EVENT_LISTENER(cancel, kCancel)
DEFINE_ATTRIBUTE_EVENT_LISTENER(remove, kRemove)
const AtomicString& InterfaceName() const override; const AtomicString& InterfaceName() const override;
ExecutionContext* GetExecutionContext() const override; ExecutionContext* GetExecutionContext() const override;
......
...@@ -58,6 +58,7 @@ enum ReplaceState { "active", "removed", "persisted" }; ...@@ -58,6 +58,7 @@ enum ReplaceState { "active", "removed", "persisted" };
[Measure] void cancel(); [Measure] void cancel();
[Measure] attribute EventHandler onfinish; [Measure] attribute EventHandler onfinish;
[Measure] attribute EventHandler oncancel; [Measure] attribute EventHandler oncancel;
[RuntimeEnabled=WebAnimationsAPI, Measure] attribute EventHandler onremove;
[RuntimeEnabled=WebAnimationsAPI, CallWith=ScriptState] readonly attribute Promise<Animation> finished; [RuntimeEnabled=WebAnimationsAPI, CallWith=ScriptState] readonly attribute Promise<Animation> finished;
[RuntimeEnabled=WebAnimationsAPI, CallWith=ScriptState] readonly attribute Promise<Animation> ready; [RuntimeEnabled=WebAnimationsAPI, CallWith=ScriptState] readonly attribute Promise<Animation> ready;
}; };
...@@ -3088,7 +3088,6 @@ crbug.com/967018 external/wpt/html/semantics/scripting-1/the-script-element/css- ...@@ -3088,7 +3088,6 @@ crbug.com/967018 external/wpt/html/semantics/scripting-1/the-script-element/css-
crbug.com/967018 external/wpt/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html [ Failure ] crbug.com/967018 external/wpt/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html [ Failure ]
crbug.com/967018 virtual/web-components-v0-disabled/external/wpt/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html [ Failure ] crbug.com/967018 virtual/web-components-v0-disabled/external/wpt/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html [ Failure ]
crbug.com/626703 external/wpt/css/css-ui/webkit-appearance-auto-001.html [ Failure ] crbug.com/626703 external/wpt/css/css-ui/webkit-appearance-auto-001.html [ Failure ]
crbug.com/626703 external/wpt/web-animations/interfaces/Animation/persist.html [ Timeout ]
crbug.com/626703 external/wpt/css/css-writing-modes/text-combine-upright-digits-004-manual.html [ Skip ] crbug.com/626703 external/wpt/css/css-writing-modes/text-combine-upright-digits-004-manual.html [ Skip ]
crbug.com/626703 external/wpt/html/semantics/scripting-1/the-script-element/json-module/parse-error.tentative.html [ Timeout ] crbug.com/626703 external/wpt/html/semantics/scripting-1/the-script-element/json-module/parse-error.tentative.html [ Timeout ]
crbug.com/626703 [ Mac10.13 ] external/wpt/preload/onload-event.html [ Failure Timeout ] crbug.com/626703 [ Mac10.13 ] external/wpt/preload/onload-event.html [ Failure Timeout ]
......
This is a testharness.js-based test. This is a testharness.js-based test.
Found 143 tests; 137 PASS, 6 FAIL, 0 TIMEOUT, 0 NOTRUN. Found 143 tests; 139 PASS, 4 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup PASS idl_test setup
PASS idl_test validation PASS idl_test validation
PASS Partial interface Document: original interface defined PASS Partial interface Document: original interface defined
...@@ -57,7 +57,7 @@ PASS Animation interface: attribute ready ...@@ -57,7 +57,7 @@ PASS Animation interface: attribute ready
PASS Animation interface: attribute finished PASS Animation interface: attribute finished
PASS Animation interface: attribute onfinish PASS Animation interface: attribute onfinish
PASS Animation interface: attribute oncancel PASS Animation interface: attribute oncancel
FAIL Animation interface: attribute onremove assert_true: The prototype object must have a property "onremove" expected true got false PASS Animation interface: attribute onremove
PASS Animation interface: operation cancel() PASS Animation interface: operation cancel()
PASS Animation interface: operation finish() PASS Animation interface: operation finish()
PASS Animation interface: operation play() PASS Animation interface: operation play()
...@@ -81,7 +81,7 @@ PASS Animation interface: new Animation() must inherit property "ready" with the ...@@ -81,7 +81,7 @@ PASS Animation interface: new Animation() must inherit property "ready" with the
PASS Animation interface: new Animation() must inherit property "finished" with the proper type PASS Animation interface: new Animation() must inherit property "finished" with the proper type
PASS Animation interface: new Animation() must inherit property "onfinish" with the proper type PASS Animation interface: new Animation() must inherit property "onfinish" with the proper type
PASS Animation interface: new Animation() must inherit property "oncancel" with the proper type PASS Animation interface: new Animation() must inherit property "oncancel" with the proper type
FAIL Animation interface: new Animation() must inherit property "onremove" with the proper type assert_inherits: property "onremove" not found in prototype chain PASS Animation interface: new Animation() must inherit property "onremove" with the proper type
PASS Animation interface: new Animation() must inherit property "cancel()" with the proper type PASS Animation interface: new Animation() must inherit property "cancel()" with the proper type
PASS Animation interface: new Animation() must inherit property "finish()" with the proper type PASS Animation interface: new Animation() must inherit property "finish()" with the proper type
PASS Animation interface: new Animation() must inherit property "play()" with the proper type PASS Animation interface: new Animation() must inherit property "play()" with the proper type
......
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.onremove</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-onremove">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
async_test(t => {
const div = createDiv(t);
const animA = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const animB = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
let finishedTimelineTime = null;
animB.onfinish = event => {
finishedTimelineTime = event.timelineTime;
};
animA.onremove = t.step_func_done(event => {
assert_equals(animA.replaceState, 'removed');
assert_equals(event.currentTime, 1);
assert_true(finishedTimelineTime != null, 'finished event fired');
assert_true(event.timelineTime == finishedTimelineTime,
'timeline time is set');
});
}, 'onremove event is fired when replaced animation is removed.');
promise_test(async t => {
const div = createDiv(t);
const animA = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const animB = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const animC = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const animD = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const removed = [];
animA.onremove = () => { removed.push('A'); };
animB.onremove = () => { removed.push('B'); };
animC.onremove = () => { removed.push('C'); };
animD.onremove = event => {
assert_unreached('onremove event should not be fired');
};
await waitForAnimationFrames(2);
assert_equals(removed.join(''), 'ABC');
}, 'onremove events are fired in the correct order');
</script>
</body>
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL All property keys are recognized assert_in_array: Test property 'onremove' should be one of the properties on Animation value "onremove" not in array ["effect", "startTime", "currentTime", "playbackRate", "playState", "pending", "id", "onfinish", "oncancel", "finish", "play", "pause", "reverse", "updatePlaybackRate", "cancel", "finished", "ready", "replaceState", "timeline", "persist", "Animation constructor"] FAIL All property keys are recognized assert_in_array: Test property 'commitStyles' should be one of the properties on Animation value "commitStyles" not in array ["effect", "startTime", "currentTime", "playbackRate", "playState", "pending", "id", "onfinish", "oncancel", "finish", "play", "pause", "reverse", "updatePlaybackRate", "cancel", "finished", "ready", "replaceState", "timeline", "onremove", "persist", "Animation constructor"]
PASS Animation.effect produces expected style change events PASS Animation.effect produces expected style change events
PASS Animation.startTime produces expected style change events PASS Animation.startTime produces expected style change events
PASS Animation.currentTime produces expected style change events PASS Animation.currentTime produces expected style change events
...@@ -19,6 +19,7 @@ PASS Animation.finished produces expected style change events ...@@ -19,6 +19,7 @@ PASS Animation.finished produces expected style change events
PASS Animation.ready produces expected style change events PASS Animation.ready produces expected style change events
PASS Animation.replaceState produces expected style change events PASS Animation.replaceState produces expected style change events
FAIL Animation.timeline produces expected style change events promise_test: Unhandled rejection with value: object "TypeError: Cannot assign to read only property 'timeline' of object '#<Animation>'" FAIL Animation.timeline produces expected style change events promise_test: Unhandled rejection with value: object "TypeError: Cannot assign to read only property 'timeline' of object '#<Animation>'"
PASS Animation.onremove produces expected style change events
PASS Animation.persist produces expected style change events PASS Animation.persist produces expected style change events
PASS Animation.Animation constructor produces expected style change events PASS Animation.Animation constructor produces expected style change events
Harness: the test ran to completion. Harness: the test ran to completion.
......
...@@ -176,6 +176,7 @@ interface Animation : EventTarget ...@@ -176,6 +176,7 @@ interface Animation : EventTarget
getter id getter id
getter oncancel getter oncancel
getter onfinish getter onfinish
getter onremove
getter pending getter pending
getter playState getter playState
getter playbackRate getter playbackRate
...@@ -196,6 +197,7 @@ interface Animation : EventTarget ...@@ -196,6 +197,7 @@ interface Animation : EventTarget
setter id setter id
setter oncancel setter oncancel
setter onfinish setter onfinish
setter onremove
setter playbackRate setter playbackRate
setter startTime setter startTime
interface AnimationEffect interface AnimationEffect
......
...@@ -26054,6 +26054,8 @@ to ensure that the crash string is shown properly on the user-facing crash UI. ...@@ -26054,6 +26054,8 @@ to ensure that the crash string is shown properly on the user-facing crash UI.
<int value="3143" label="TaskControllerSetPriority"/> <int value="3143" label="TaskControllerSetPriority"/>
<int value="3144" label="TaskSignalPriority"/> <int value="3144" label="TaskSignalPriority"/>
<int value="3145" label="SchedulerPostTask"/> <int value="3145" label="SchedulerPostTask"/>
<int value="3146" label="V8Animation_Onremove_AttributeGetter"/>
<int value="3147" label="V8Animation_Onremove_AttributeSetter"/>
</enum> </enum>
<enum name="FeaturePolicyAllowlistType"> <enum name="FeaturePolicyAllowlistType">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment