diff options
author | ed@opera.com <ed@opera.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2014-03-24 18:06:19 +0000 |
---|---|---|
committer | ed@opera.com <ed@opera.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2014-03-24 18:06:19 +0000 |
commit | 94d5a8d90c0f15e0232a178c1e472ffc5980a7ef (patch) | |
tree | 0a5e611c68c22d1f8f57dfcea12283899d6f74dc /third_party/WebKit/LayoutTests/fast/svg/script-tests/animation-events.js | |
parent | 06f0b6be08ba75d26cc04ee35ae854961d1cb068 (diff) | |
download | chromium_src-94d5a8d90c0f15e0232a178c1e472ffc5980a7ef.zip chromium_src-94d5a8d90c0f15e0232a178c1e472ffc5980a7ef.tar.gz chromium_src-94d5a8d90c0f15e0232a178c1e472ffc5980a7ef.tar.bz2 |
[SVG2] Add onbegin, onend and onrepeat EventHandlers on SVGAnimationElement
These map to the eventnames 'beginEvent', 'endEvent' and 'repeatEvent'
respectively.
Spec:
https://svgwg.org/svg2-draft/animate.html#InterfaceSVGAnimationElement
BUG=338288
NOTRY=true
Review URL: https://codereview.chromium.org/201673003
git-svn-id: svn://svn.chromium.org/blink/trunk@169871 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/svg/script-tests/animation-events.js')
-rw-r--r-- | third_party/WebKit/LayoutTests/fast/svg/script-tests/animation-events.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/svg/script-tests/animation-events.js b/third_party/WebKit/LayoutTests/fast/svg/script-tests/animation-events.js new file mode 100644 index 0000000..35a859f --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/svg/script-tests/animation-events.js @@ -0,0 +1,73 @@ +function getObject(interface) { + switch(interface) { + case "SVGAnimateElement": + var e = document.createElementNS("http://www.w3.org/2000/svg", "animate"); + assert_true(e instanceof SVGAnimateElement); + return e; + case "SVGAnimateMotionElement": + var e = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion"); + assert_true(e instanceof SVGAnimateMotionElement); + return e; + case "SVGAnimateTransformElement": + var e = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform"); + assert_true(e instanceof SVGAnimateTransformElement); + return e; + case "SVGSetElement": + var e = document.createElementNS("http://www.w3.org/2000/svg", "set"); + assert_true(e instanceof SVGSetElement); + return e; + } + assert_unreached(); +} +function testSet(interface, attribute) { + test(function() { + var object = getObject(interface); + function nop() {} + assert_equals(object[attribute], null, "Initially null"); + object[attribute] = nop; + assert_equals(object[attribute], nop, "Return same function"); + object[attribute] = ""; + assert_equals(object[attribute], null, "Return null after setting string"); + object[attribute] = null; + assert_equals(object[attribute], null, "Finally null"); + }, "Set " + interface + "." + attribute); +} +function testReflect(interface, attribute) { + test(function() { + var element = getObject(interface); + assert_false(element.hasAttribute(attribute), "Initially missing"); + element.setAttribute(attribute, "return"); + assert_equals(element.getAttribute(attribute), "return", "Return same string"); + assert_equals(typeof element[attribute], "function", "Convert to function"); + element.removeAttribute(attribute); + }, "Reflect " + interface + "." + attribute); +} +// Object.propertyIsEnumerable cannot be used because it doesn't +// work with properties inherited through the prototype chain. +function getEnumerable(interface) { + var enumerable = {}; + for (var attribute in getObject(interface)) { + enumerable[attribute] = true; + } + return enumerable; +} +function testEventHandlerMapping(attribute, eventname) { + async_test(function(t) { + var element = getObject("SVGAnimateElement"); + assert_false(element.hasAttribute(attribute), "Initially missing"); + element[attribute] = function() { + t.step(function (){assert_true(true); t.done();}); + }; + var event = new CustomEvent(eventname); + element.dispatchEvent(event); + }, "Event " + eventname + " maps to " + attribute); +} +var enumerableCache = {}; +function testEnumerate(interface, attribute) { + if (!(interface in enumerableCache)) { + enumerableCache[interface] = getEnumerable(interface); + } + test(function() { + assert_true(enumerableCache[interface][attribute]); + }, "Enumerate " + interface + "." + attribute); +} |