Move on{animation,transition}XX event handlers to GlobalEventHandlers

The spec defines these on GlobalEventHandlers, not on Window:
https://drafts.csswg.org/css-animations-1/#interface-globaleventhandlers-idl
https://drafts.csswg.org/css-transitions-1/#interface-globaleventhandlers-idl

Bug: 999894
Change-Id: Idf3d5f9ba44a5cc8045315baa8c204fdc326d5db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783058
Reviewed-by: Yi Gu <yigu@chromium.org>
Reviewed-by: Philip J├Ągenstedt <foolip@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696040}
diff --git a/third_party/blink/renderer/core/dom/global_event_handlers.h b/third_party/blink/renderer/core/dom/global_event_handlers.h
index 0d7d82f9..13c7cf669 100644
--- a/third_party/blink/renderer/core/dom/global_event_handlers.h
+++ b/third_party/blink/renderer/core/dom/global_event_handlers.h
@@ -40,6 +40,10 @@
 
  public:
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(abort, kAbort)
+  DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(animationend, kAnimationend)
+  DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(animationiteration,
+                                         kAnimationiteration)
+  DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(animationstart, kAnimationstart)
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(activateinvisible, kActivateinvisible)
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(auxclick, kAuxclick)
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(blur, kBlur)
@@ -113,6 +117,7 @@
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(stalled, kStalled)
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(submit, kSubmit)
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(suspend, kSuspend)
+  DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(transitionend, kTransitionend)
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(timeupdate, kTimeupdate)
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(toggle, kToggle)
   DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(touchcancel, kTouchcancel)
diff --git a/third_party/blink/renderer/core/dom/global_event_handlers.idl b/third_party/blink/renderer/core/dom/global_event_handlers.idl
index a060458..05630ca8 100644
--- a/third_party/blink/renderer/core/dom/global_event_handlers.idl
+++ b/third_party/blink/renderer/core/dom/global_event_handlers.idl
@@ -129,4 +129,14 @@
     // https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers
     attribute EventHandler onselectstart;
     attribute EventHandler onselectionchange;
+
+    // CSS Animations
+    // https://drafts.csswg.org/css-animations/#interface-globaleventhandlers-idl
+    attribute EventHandler onanimationend;
+    attribute EventHandler onanimationiteration;
+    attribute EventHandler onanimationstart;
+
+    // CSS Transitions
+    // https://drafts.csswg.org/css-transitions/#interface-globaleventhandlers-idl
+    attribute EventHandler ontransitionend;
 };
diff --git a/third_party/blink/renderer/core/frame/local_dom_window.h b/third_party/blink/renderer/core/frame/local_dom_window.h
index b93579c..96a0092 100644
--- a/third_party/blink/renderer/core/frame/local_dom_window.h
+++ b/third_party/blink/renderer/core/frame/local_dom_window.h
@@ -247,11 +247,7 @@
 
   bool isSecureContext() const;
 
-  DEFINE_ATTRIBUTE_EVENT_LISTENER(animationend, kAnimationend)
-  DEFINE_ATTRIBUTE_EVENT_LISTENER(animationiteration, kAnimationiteration)
-  DEFINE_ATTRIBUTE_EVENT_LISTENER(animationstart, kAnimationstart)
   DEFINE_ATTRIBUTE_EVENT_LISTENER(search, kSearch)
-  DEFINE_ATTRIBUTE_EVENT_LISTENER(transitionend, kTransitionend)
 
   DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitanimationstart, kWebkitAnimationStart)
   DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitanimationiteration,
diff --git a/third_party/blink/renderer/core/frame/window.idl b/third_party/blink/renderer/core/frame/window.idl
index b5c9a7b6..bdc7ae96 100644
--- a/third_party/blink/renderer/core/frame/window.idl
+++ b/third_party/blink/renderer/core/frame/window.idl
@@ -199,11 +199,9 @@
     [MeasureAs=PrefixedMutationObserverConstructor] attribute MutationObserverConstructor WebKitMutationObserver;
 
     // Event handler attributes
-    attribute EventHandler onanimationend;
-    attribute EventHandler onanimationiteration;
-    attribute EventHandler onanimationstart;
     attribute EventHandler onsearch;
-    attribute EventHandler ontransitionend;
+
+    // TODO(crbug.com/999895): Move to global_event_handlers.idl
     attribute EventHandler onwebkitanimationend;
     attribute EventHandler onwebkitanimationiteration;
     attribute EventHandler onwebkitanimationstart;
diff --git a/third_party/blink/web_tests/external/wpt/css/css-animations/event-order.tentative-expected.txt b/third_party/blink/web_tests/external/wpt/css/css-animations/event-order.tentative-expected.txt
index 8aee80ee..dd5957c 100644
--- a/third_party/blink/web_tests/external/wpt/css/css-animations/event-order.tentative-expected.txt
+++ b/third_party/blink/web_tests/external/wpt/css/css-animations/event-order.tentative-expected.txt
@@ -1,8 +1,8 @@
 This is a testharness.js-based test.
-FAIL Same events are ordered by elements assert_equals: Number of events received (0) should match expected number (2) (expected: animationstart, animationstart, actual: ) expected 2 but got 0
-FAIL Same events on pseudo-elements follow the prescribed order assert_equals: Number of events received (0) should match expected number (4) (expected: animationstart, animationstart, animationstart, animationstart, actual: ) expected 4 but got 0
-FAIL Start and iteration events are ordered by time assert_equals: Number of events received (0) should match expected number (2) (expected: animationiteration, animationstart, actual: ) expected 2 but got 0
-FAIL Iteration and end events are ordered by time assert_equals: Number of events received (0) should match expected number (2) (expected: animationiteration, animationend, actual: ) expected 2 but got 0
-FAIL Start and end events are sorted correctly when fired simultaneously assert_equals: Number of events received (0) should match expected number (4) (expected: animationstart, animationstart, animationend, animationend, actual: ) expected 4 but got 0
+PASS Same events are ordered by elements
+FAIL Same events on pseudo-elements follow the prescribed order assert_equals: Event #3 targets should match expected Element node <div style="animation: anim 100s" id="parent-div"><div st... but got Element node <div style="animation: anim 100s"></div>
+FAIL Start and iteration events are ordered by time assert_equals: Event #1 types should match (expected: animationiteration, animationstart, actual: animationstart, animationiteration) expected "animationiteration" but got "animationstart"
+FAIL Iteration and end events are ordered by time assert_equals: Event #1 types should match (expected: animationiteration, animationend, actual: animationend, animationiteration) expected "animationiteration" but got "animationend"
+FAIL Start and end events are sorted correctly when fired simultaneously assert_equals: Event #1 targets should match expected Element node <div style="animation: anim 100s 2"></div> but got Element node <div style="animation: anim 100s 100s"></div>
 Harness: the test ran to completion.
 
diff --git a/third_party/blink/web_tests/external/wpt/css/css-animations/idlharness-expected.txt b/third_party/blink/web_tests/external/wpt/css/css-animations/idlharness-expected.txt
index 58a11c5..87e4433 100644
--- a/third_party/blink/web_tests/external/wpt/css/css-animations/idlharness-expected.txt
+++ b/third_party/blink/web_tests/external/wpt/css/css-animations/idlharness-expected.txt
@@ -1,5 +1,5 @@
 This is a testharness.js-based test.
-Found 70 tests; 61 PASS, 9 FAIL, 0 TIMEOUT, 0 NOTRUN.
+Found 70 tests; 67 PASS, 3 FAIL, 0 TIMEOUT, 0 NOTRUN.
 PASS idl_test setup
 PASS Partial interface CSSRule: original interface defined
 PASS Partial interface mixin GlobalEventHandlers: original interface mixin defined
@@ -54,17 +54,17 @@
 PASS CSSKeyframesRule interface: calling findRule(CSSOMString) on keyframes with too few arguments must throw TypeError
 PASS CSSRule interface: keyframes must inherit property "KEYFRAMES_RULE" with the proper type
 PASS CSSRule interface: keyframes must inherit property "KEYFRAME_RULE" with the proper type
-FAIL HTMLElement interface: attribute onanimationstart assert_true: The prototype object must have a property "onanimationstart" expected true got false
-FAIL HTMLElement interface: attribute onanimationiteration assert_true: The prototype object must have a property "onanimationiteration" expected true got false
-FAIL HTMLElement interface: attribute onanimationend assert_true: The prototype object must have a property "onanimationend" expected true got false
+PASS HTMLElement interface: attribute onanimationstart
+PASS HTMLElement interface: attribute onanimationiteration
+PASS HTMLElement interface: attribute onanimationend
 FAIL HTMLElement interface: attribute onanimationcancel assert_true: The prototype object must have a property "onanimationcancel" expected true got false
 PASS Window interface: attribute onanimationstart
 PASS Window interface: attribute onanimationiteration
 PASS Window interface: attribute onanimationend
 FAIL Window interface: attribute onanimationcancel assert_own_property: The global object must have a property "onanimationcancel" expected property "onanimationcancel" missing
-FAIL Document interface: attribute onanimationstart assert_true: The prototype object must have a property "onanimationstart" expected true got false
-FAIL Document interface: attribute onanimationiteration assert_true: The prototype object must have a property "onanimationiteration" expected true got false
-FAIL Document interface: attribute onanimationend assert_true: The prototype object must have a property "onanimationend" expected true got false
+PASS Document interface: attribute onanimationstart
+PASS Document interface: attribute onanimationiteration
+PASS Document interface: attribute onanimationend
 FAIL Document interface: attribute onanimationcancel assert_true: The prototype object must have a property "onanimationcancel" expected true got false
 PASS CSSRule interface: constant KEYFRAMES_RULE on interface object
 PASS CSSRule interface: constant KEYFRAMES_RULE on interface prototype object
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transitions/idlharness-expected.txt b/third_party/blink/web_tests/external/wpt/css/css-transitions/idlharness-expected.txt
index 24f1f45..3c9dbb02 100644
--- a/third_party/blink/web_tests/external/wpt/css/css-transitions/idlharness-expected.txt
+++ b/third_party/blink/web_tests/external/wpt/css/css-transitions/idlharness-expected.txt
@@ -17,11 +17,11 @@
 PASS TransitionEvent interface: new TransitionEvent("transitionend") must inherit property "pseudoElement" with the proper type
 FAIL HTMLElement interface: attribute ontransitionrun assert_true: The prototype object must have a property "ontransitionrun" expected true got false
 FAIL HTMLElement interface: attribute ontransitionstart assert_true: The prototype object must have a property "ontransitionstart" expected true got false
-FAIL HTMLElement interface: attribute ontransitionend assert_true: The prototype object must have a property "ontransitionend" expected true got false
+PASS HTMLElement interface: attribute ontransitionend
 FAIL HTMLElement interface: attribute ontransitioncancel assert_true: The prototype object must have a property "ontransitioncancel" expected true got false
 FAIL HTMLElement interface: document must inherit property "ontransitionrun" with the proper type assert_inherits: property "ontransitionrun" not found in prototype chain
 FAIL HTMLElement interface: document must inherit property "ontransitionstart" with the proper type assert_inherits: property "ontransitionstart" not found in prototype chain
-FAIL HTMLElement interface: document must inherit property "ontransitionend" with the proper type assert_inherits: property "ontransitionend" not found in prototype chain
+PASS HTMLElement interface: document must inherit property "ontransitionend" with the proper type
 FAIL HTMLElement interface: document must inherit property "ontransitioncancel" with the proper type assert_inherits: property "ontransitioncancel" not found in prototype chain
 FAIL Window interface: attribute ontransitionrun assert_own_property: The global object must have a property "ontransitionrun" expected property "ontransitionrun" missing
 FAIL Window interface: attribute ontransitionstart assert_own_property: The global object must have a property "ontransitionstart" expected property "ontransitionstart" missing
@@ -33,11 +33,11 @@
 FAIL Window interface: window must inherit property "ontransitioncancel" with the proper type assert_own_property: expected property "ontransitioncancel" missing
 FAIL Document interface: attribute ontransitionrun assert_true: The prototype object must have a property "ontransitionrun" expected true got false
 FAIL Document interface: attribute ontransitionstart assert_true: The prototype object must have a property "ontransitionstart" expected true got false
-FAIL Document interface: attribute ontransitionend assert_true: The prototype object must have a property "ontransitionend" expected true got false
+PASS Document interface: attribute ontransitionend
 FAIL Document interface: attribute ontransitioncancel assert_true: The prototype object must have a property "ontransitioncancel" expected true got false
 FAIL Document interface: document must inherit property "ontransitionrun" with the proper type assert_inherits: property "ontransitionrun" not found in prototype chain
 FAIL Document interface: document must inherit property "ontransitionstart" with the proper type assert_inherits: property "ontransitionstart" not found in prototype chain
-FAIL Document interface: document must inherit property "ontransitionend" with the proper type assert_inherits: property "ontransitionend" not found in prototype chain
+PASS Document interface: document must inherit property "ontransitionend" with the proper type
 FAIL Document interface: document must inherit property "ontransitioncancel" with the proper type assert_inherits: property "ontransitioncancel" not found in prototype chain
 Harness: the test ran to completion.
 
diff --git a/third_party/blink/web_tests/virtual/stable/webexposed/element-instance-property-listing-expected.txt b/third_party/blink/web_tests/virtual/stable/webexposed/element-instance-property-listing-expected.txt
index 6739654..b93e810 100644
--- a/third_party/blink/web_tests/virtual/stable/webexposed/element-instance-property-listing-expected.txt
+++ b/third_party/blink/web_tests/virtual/stable/webexposed/element-instance-property-listing-expected.txt
@@ -116,6 +116,9 @@
     property offsetTop
     property offsetWidth
     property onabort
+    property onanimationend
+    property onanimationiteration
+    property onanimationstart
     property onauxclick
     property onbeforecopy
     property onbeforecut
@@ -199,6 +202,7 @@
     property ontouchend
     property ontouchmove
     property ontouchstart
+    property ontransitionend
     property onvolumechange
     property onwaiting
     property onwebkitfullscreenchange
@@ -1214,6 +1218,9 @@
     property nonce
     property normalize
     property onabort
+    property onanimationend
+    property onanimationiteration
+    property onanimationstart
     property onauxclick
     property onbeforecopy
     property onbeforecut
@@ -1297,6 +1304,7 @@
     property ontouchend
     property ontouchmove
     property ontouchstart
+    property ontransitionend
     property onvolumechange
     property onwaiting
     property onwebkitfullscreenchange
diff --git a/third_party/blink/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt
index 8f04cab..aa48460 100644
--- a/third_party/blink/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt
+++ b/third_party/blink/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt
@@ -1279,6 +1279,9 @@
     getter linkColor
     getter links
     getter onabort
+    getter onanimationend
+    getter onanimationiteration
+    getter onanimationstart
     getter onauxclick
     getter onbeforecopy
     getter onbeforecut
@@ -1368,6 +1371,7 @@
     getter ontouchend
     getter ontouchmove
     getter ontouchstart
+    getter ontransitionend
     getter onvisibilitychange
     getter onvolumechange
     getter onwaiting
@@ -1463,6 +1467,9 @@
     setter fullscreenEnabled
     setter linkColor
     setter onabort
+    setter onanimationend
+    setter onanimationiteration
+    setter onanimationstart
     setter onauxclick
     setter onbeforecopy
     setter onbeforecut
@@ -1552,6 +1559,7 @@
     setter ontouchend
     setter ontouchmove
     setter ontouchstart
+    setter ontransitionend
     setter onvisibilitychange
     setter onvolumechange
     setter onwaiting
@@ -2247,6 +2255,9 @@
     getter offsetTop
     getter offsetWidth
     getter onabort
+    getter onanimationend
+    getter onanimationiteration
+    getter onanimationstart
     getter onauxclick
     getter onblur
     getter oncancel
@@ -2324,6 +2335,7 @@
     getter ontouchend
     getter ontouchmove
     getter ontouchstart
+    getter ontransitionend
     getter onvolumechange
     getter onwaiting
     getter onwheel
@@ -2350,6 +2362,9 @@
     setter lang
     setter nonce
     setter onabort
+    setter onanimationend
+    setter onanimationiteration
+    setter onanimationstart
     setter onauxclick
     setter onblur
     setter oncancel
@@ -2427,6 +2442,7 @@
     setter ontouchend
     setter ontouchmove
     setter ontouchstart
+    setter ontransitionend
     setter onvolumechange
     setter onwaiting
     setter onwheel
@@ -5560,6 +5576,9 @@
     getter dataset
     getter nonce
     getter onabort
+    getter onanimationend
+    getter onanimationiteration
+    getter onanimationstart
     getter onauxclick
     getter onblur
     getter oncancel
@@ -5637,6 +5656,7 @@
     getter ontouchend
     getter ontouchmove
     getter ontouchstart
+    getter ontransitionend
     getter onvolumechange
     getter onwaiting
     getter onwheel
@@ -5649,6 +5669,9 @@
     method focus
     setter nonce
     setter onabort
+    setter onanimationend
+    setter onanimationiteration
+    setter onanimationstart
     setter onauxclick
     setter onblur
     setter oncancel
@@ -5726,6 +5749,7 @@
     setter ontouchend
     setter ontouchmove
     setter ontouchstart
+    setter ontransitionend
     setter onvolumechange
     setter onwaiting
     setter onwheel
diff --git a/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt b/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt
index c12ab26..eab13a8 100644
--- a/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt
+++ b/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt
@@ -171,6 +171,9 @@
     property offsetWidth
     property onabort
     property onactivateinvisible
+    property onanimationend
+    property onanimationiteration
+    property onanimationstart
     property onauxclick
     property onbeforeactivate
     property onbeforecopy
@@ -257,6 +260,7 @@
     property ontouchend
     property ontouchmove
     property ontouchstart
+    property ontransitionend
     property onvolumechange
     property onwaiting
     property onwebkitfullscreenchange
@@ -1349,6 +1353,9 @@
     property normalize
     property onabort
     property onactivateinvisible
+    property onanimationend
+    property onanimationiteration
+    property onanimationstart
     property onauxclick
     property onbeforeactivate
     property onbeforecopy
@@ -1435,6 +1442,7 @@
     property ontouchend
     property ontouchmove
     property ontouchstart
+    property ontransitionend
     property onvolumechange
     property onwaiting
     property onwebkitfullscreenchange
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
index f4e5061..38f7766 100644
--- a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
+++ b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
@@ -1603,6 +1603,9 @@
     getter links
     getter onabort
     getter onactivateinvisible
+    getter onanimationend
+    getter onanimationiteration
+    getter onanimationstart
     getter onauxclick
     getter onbeforeactivate
     getter onbeforecopy
@@ -1695,6 +1698,7 @@
     getter ontouchend
     getter ontouchmove
     getter ontouchstart
+    getter ontransitionend
     getter onvisibilitychange
     getter onvolumechange
     getter onwaiting
@@ -1794,6 +1798,9 @@
     setter linkColor
     setter onabort
     setter onactivateinvisible
+    setter onanimationend
+    setter onanimationiteration
+    setter onanimationstart
     setter onauxclick
     setter onbeforeactivate
     setter onbeforecopy
@@ -1886,6 +1893,7 @@
     setter ontouchend
     setter ontouchmove
     setter ontouchstart
+    setter ontransitionend
     setter onvisibilitychange
     setter onvolumechange
     setter onwaiting
@@ -2926,6 +2934,9 @@
     getter offsetWidth
     getter onabort
     getter onactivateinvisible
+    getter onanimationend
+    getter onanimationiteration
+    getter onanimationstart
     getter onauxclick
     getter onbeforeactivate
     getter onblur
@@ -3006,6 +3017,7 @@
     getter ontouchend
     getter ontouchmove
     getter ontouchstart
+    getter ontransitionend
     getter onvolumechange
     getter onwaiting
     getter onwheel
@@ -3034,6 +3046,9 @@
     setter nonce
     setter onabort
     setter onactivateinvisible
+    setter onanimationend
+    setter onanimationiteration
+    setter onanimationstart
     setter onauxclick
     setter onbeforeactivate
     setter onblur
@@ -3114,6 +3129,7 @@
     setter ontouchend
     setter ontouchmove
     setter ontouchstart
+    setter ontransitionend
     setter onvolumechange
     setter onwaiting
     setter onwheel
@@ -6527,6 +6543,9 @@
     getter nonce
     getter onabort
     getter onactivateinvisible
+    getter onanimationend
+    getter onanimationiteration
+    getter onanimationstart
     getter onauxclick
     getter onbeforeactivate
     getter onblur
@@ -6607,6 +6626,7 @@
     getter ontouchend
     getter ontouchmove
     getter ontouchstart
+    getter ontransitionend
     getter onvolumechange
     getter onwaiting
     getter onwheel
@@ -6620,6 +6640,9 @@
     setter nonce
     setter onabort
     setter onactivateinvisible
+    setter onanimationend
+    setter onanimationiteration
+    setter onanimationstart
     setter onauxclick
     setter onbeforeactivate
     setter onblur
@@ -6700,6 +6723,7 @@
     setter ontouchend
     setter ontouchmove
     setter ontouchstart
+    setter ontransitionend
     setter onvolumechange
     setter onwaiting
     setter onwheel