OLD | NEW |
1 window.testIsAsync = true; | 1 window.testIsAsync = true; |
2 description("Tests whether SVG event bubbling works across shadow trees."); | 2 description("Tests whether SVG event bubbling works across shadow trees."); |
3 | 3 |
4 var svgNS = "http://www.w3.org/2000/svg"; | 4 var svgNS = "http://www.w3.org/2000/svg"; |
5 var xhtmlNS = "http://www.w3.org/1999/xhtml"; | 5 var xhtmlNS = "http://www.w3.org/1999/xhtml"; |
6 var expected = new Array(4); | 6 var expected = new Array(4); |
7 var tests = 4; | 7 var tests = 4; |
8 var counter = 0; | 8 var counter = 0; |
9 var eventCounter = 0; | 9 var eventCounter = 0; |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 ++eventCounter; | 34 ++eventCounter; |
35 | 35 |
36 if (label == counter) | 36 if (label == counter) |
37 setTimeout(label == tests ? finishTest : nextTest, 0); | 37 setTimeout(label == tests ? finishTest : nextTest, 0); |
38 } | 38 } |
39 | 39 |
40 function finishTest() | 40 function finishTest() |
41 { | 41 { |
42 successfullyParsed = true; | 42 successfullyParsed = true; |
43 | 43 |
44 use.instanceRoot.correspondingElement.setAttribute("fill", "green"); | 44 rectContainer.setAttribute("fill", "green"); |
45 shouldBeTrue("successfullyParsed"); | 45 shouldBeTrue("successfullyParsed"); |
46 debug('<br /><span class="pass">TEST COMPLETE</span>'); | 46 debug('<br /><span class="pass">TEST COMPLETE</span>'); |
47 | 47 |
48 finishRepaintTest(); | 48 finishRepaintTest(); |
49 } | 49 } |
50 | 50 |
51 function nextTest() | 51 function nextTest() |
52 { | 52 { |
53 eventCounter = 0; | 53 eventCounter = 0; |
54 ++counter; | 54 ++counter; |
55 | 55 |
56 switch (counter) { | 56 switch (counter) { |
57 case 1: | 57 case 1: |
58 rect.onclick = function(evt) { eventHandler(evt, 1); }; | 58 rect.onclick = function(evt) { eventHandler(evt, 1); }; |
59 expected[0] = "[EventHandler 1] type: click phase: AT_TARGET target: [ob
ject SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (
id: rect)"; | 59 expected[0] = "[EventHandler 1] type: click phase: AT_TARGET target: [ob
ject SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"; |
60 testListeners(); | 60 testListeners(); |
61 break; | 61 break; |
62 case 2: | 62 case 2: |
63 rectContainer.addEventListener("click", function(evt) { eventHandler(evt
, 2) }, false); | 63 rectContainer.addEventListener("click", function(evt) { eventHandler(evt
, 2) }, false); |
64 expected[1] = "[EventHandler 2] type: click phase: BUBBLING target: [obj
ect SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (i
d: rectParent)"; | 64 expected[1] = "[EventHandler 2] type: click phase: AT_TARGET target: [ob
ject SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"; |
65 testListeners(); | 65 testListeners(); |
66 break; | 66 break; |
67 case 3: | 67 case 3: |
68 use.setAttribute("onclick", "eventHandler(evt, 3)"); | 68 use.setAttribute("onclick", "eventHandler(evt, 3)"); |
69 expected[2] = "[EventHandler 3] type: click phase: BUBBLING target: [obj
ect SVGElementInstance] (id: rect) currentTarget: [object SVGUseElement] (id: us
e)"; | 69 expected[2] = "[EventHandler 3] type: click phase: AT_TARGET target: [ob
ject SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"; |
70 testListeners(); | 70 testListeners(); |
71 break; | 71 break; |
72 case 4: | 72 case 4: |
73 useContainer.onclick = function(evt) { eventHandler(evt, 4) }; | 73 useContainer.onclick = function(evt) { eventHandler(evt, 4) }; |
74 expected[3] = "[EventHandler 4] type: click phase: BUBBLING target: [obj
ect SVGElementInstance] (id: rect) currentTarget: [object SVGGElement] (id: useP
arent)"; | 74 expected[3] = "[EventHandler 4] type: click phase: BUBBLING target: [obj
ect SVGUseElement] (id: use) currentTarget: [object SVGGElement] (id: useParent)
"; |
75 testListeners(); | 75 testListeners(); |
76 break; | 76 break; |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 function testListeners() | 80 function testListeners() |
81 { | 81 { |
82 if (window.eventSender) { | 82 if (window.eventSender) { |
83 eventSender.mouseMoveTo(50, 50); | 83 eventSender.mouseMoveTo(50, 50); |
84 eventSender.mouseDown(); | 84 eventSender.mouseDown(); |
(...skipping 29 matching lines...) Expand all Loading... |
114 svg.appendChild(useContainer); | 114 svg.appendChild(useContainer); |
115 | 115 |
116 var use = document.createElementNS(svgNS, "use"); | 116 var use = document.createElementNS(svgNS, "use"); |
117 use.id = "use"; | 117 use.id = "use"; |
118 use.href.baseVal = "#rectParent"; | 118 use.href.baseVal = "#rectParent"; |
119 useContainer.appendChild(use); | 119 useContainer.appendChild(use); |
120 | 120 |
121 function repaintTest() { | 121 function repaintTest() { |
122 nextTest(); | 122 nextTest(); |
123 } | 123 } |
OLD | NEW |