Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: LayoutTests/fast/svg/script-tests/animation-events.js

Issue 201673003: [SVG2] Add onbegin, onend and onrepeat EventHandlers on SVGAnimationElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fs review Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/svg/animation-events.html ('k') | Source/core/svg/SVGAnimationElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function getObject(interface) { 1 function getObject(interface) {
2 switch(interface) { 2 switch(interface) {
3 case "Element": 3 case "SVGAnimateElement":
4 var e = document.createElementNS("http://example.com/", "example"); 4 var e = document.createElementNS("http://www.w3.org/2000/svg", "anim ate");
5 assert_true(e instanceof Element); 5 assert_true(e instanceof SVGAnimateElement);
6 assert_false(e instanceof HTMLElement);
7 assert_false(e instanceof SVGElement);
8 return e; 6 return e;
9 case "HTMLElement": 7 case "SVGAnimateMotionElement":
10 var e = document.createElement("html"); 8 var e = document.createElementNS("http://www.w3.org/2000/svg", "anim ateMotion");
11 assert_true(e instanceof HTMLElement); 9 assert_true(e instanceof SVGAnimateMotionElement);
12 return e; 10 return e;
13 case "HTMLBodyElement": 11 case "SVGAnimateTransformElement":
14 var e = document.createElement("body"); 12 var e = document.createElementNS("http://www.w3.org/2000/svg", "anim ateTransform");
15 assert_true(e instanceof HTMLBodyElement); 13 assert_true(e instanceof SVGAnimateTransformElement);
16 return e; 14 return e;
17 case "HTMLFormElement": 15 case "SVGSetElement":
18 var e = document.createElement("form"); 16 var e = document.createElementNS("http://www.w3.org/2000/svg", "set" );
19 assert_true(e instanceof HTMLFormElement); 17 assert_true(e instanceof SVGSetElement);
20 return e; 18 return e;
21 case "HTMLFrameSetElement":
22 var e = document.createElement("frameset");
23 assert_true(e instanceof HTMLFrameSetElement);
24 return e;
25 case "SVGElement":
26 var e = document.createElementNS("http://www.w3.org/2000/svg", "rect ");
27 assert_true(e instanceof SVGElement);
28 return e;
29 case "Document":
30 assert_true(document instanceof Document);
31 return document;
32 case "Window":
33 assert_true(window instanceof Window);
34 return window;
35 } 19 }
36 assert_unreached(); 20 assert_unreached();
37 } 21 }
38 function testSet(interface, attribute) { 22 function testSet(interface, attribute) {
39 test(function() { 23 test(function() {
40 var object = getObject(interface); 24 var object = getObject(interface);
41 function nop() {} 25 function nop() {}
42 assert_equals(object[attribute], null, "Initially null"); 26 assert_equals(object[attribute], null, "Initially null");
43 object[attribute] = nop; 27 object[attribute] = nop;
44 assert_equals(object[attribute], nop, "Return same function"); 28 assert_equals(object[attribute], nop, "Return same function");
45 object[attribute] = ""; 29 object[attribute] = "";
46 assert_equals(object[attribute], null, "Return null after setting string "); 30 assert_equals(object[attribute], null, "Return null after setting string ");
47 object[attribute] = null; 31 object[attribute] = null;
48 assert_equals(object[attribute], null, "Finally null"); 32 assert_equals(object[attribute], null, "Finally null");
49 }, "Set " + interface + "." + attribute); 33 }, "Set " + interface + "." + attribute);
50 } 34 }
51 function testReflect(interface, attribute) { 35 function testReflect(interface, attribute) {
52 test(function() { 36 test(function() {
53 var element = getObject(interface); 37 var element = getObject(interface);
54 assert_false(element.hasAttribute(attribute), "Initially missing"); 38 assert_false(element.hasAttribute(attribute), "Initially missing");
55 element.setAttribute(attribute, "return"); 39 element.setAttribute(attribute, "return");
56 assert_equals(element.getAttribute(attribute), "return", "Return same st ring"); 40 assert_equals(element.getAttribute(attribute), "return", "Return same st ring");
57 assert_equals(typeof element[attribute], "function", "Convert to functio n"); 41 assert_equals(typeof element[attribute], "function", "Convert to functio n");
58 element.removeAttribute(attribute); 42 element.removeAttribute(attribute);
59 }, "Reflect " + interface + "." + attribute); 43 }, "Reflect " + interface + "." + attribute);
60 } 44 }
61 function testForwardToWindow(interface, attribute) {
62 test(function() {
63 var element = getObject(interface);
64 window[attribute] = null;
65 element.setAttribute(attribute, "return");
66 assert_equals(typeof window[attribute], "function", "Convert to function ");
67 assert_equals(window[attribute], element[attribute], "Forward content at tribute");
68 function nop() {}
69 element[attribute] = nop;
70 assert_equals(window[attribute], nop, "Forward IDL attribute");
71 window[attribute] = null;
72 }, "Forward " + interface + "." + attribute + " to Window");
73 }
74 // Object.propertyIsEnumerable cannot be used because it doesn't 45 // Object.propertyIsEnumerable cannot be used because it doesn't
75 // work with properties inherited through the prototype chain. 46 // work with properties inherited through the prototype chain.
76 function getEnumerable(interface) { 47 function getEnumerable(interface) {
77 var enumerable = {}; 48 var enumerable = {};
78 for (var attribute in getObject(interface)) { 49 for (var attribute in getObject(interface)) {
79 enumerable[attribute] = true; 50 enumerable[attribute] = true;
80 } 51 }
81 return enumerable; 52 return enumerable;
82 } 53 }
54 function testEventHandlerMapping(attribute, eventname) {
55 async_test(function(t) {
56 var element = getObject("SVGAnimateElement");
57 assert_false(element.hasAttribute(attribute), "Initially missing");
58 element[attribute] = function() {
59 t.step(function (){assert_true(true); t.done();});
60 };
61 var event = new CustomEvent(eventname);
62 element.dispatchEvent(event);
63 }, "Event " + eventname + " maps to " + attribute);
64 }
83 var enumerableCache = {}; 65 var enumerableCache = {};
84 function testEnumerate(interface, attribute) { 66 function testEnumerate(interface, attribute) {
85 if (!(interface in enumerableCache)) { 67 if (!(interface in enumerableCache)) {
86 enumerableCache[interface] = getEnumerable(interface); 68 enumerableCache[interface] = getEnumerable(interface);
87 } 69 }
88 test(function() { 70 test(function() {
89 assert_true(enumerableCache[interface][attribute]); 71 assert_true(enumerableCache[interface][attribute]);
90 }, "Enumerate " + interface + "." + attribute); 72 }, "Enumerate " + interface + "." + attribute);
91 } 73 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/svg/animation-events.html ('k') | Source/core/svg/SVGAnimationElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698