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

Side by Side Diff: LayoutTests/svg/custom/resources/use-instanceRoot-event-listeners.js

Issue 257033002: Do not implement EventTarget on SVGElementInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Try to fix TestExpectations Created 6 years, 6 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
OLDNEW
1 var counter = 0; 1 var counter = 0;
2 var tests = 8; 2 var tests = 8;
3 var expected = ""; 3 var expected = "";
4 var logEvent = false; 4 var logEvent = false;
5 var rectElement = document.getElementById("target"); 5 var rectElement = document.getElementById("target");
6 var useElement = document.getElementById("test"); 6 var useElement = document.getElementById("test");
7 window.testIsAsync = true; 7 window.testIsAsync = true;
8 description("Test attaching event listeners on SVG use elements in different way s: "); 8 description("Test attaching event listeners on SVG use elements in different way s: ");
9 9
10 function eventHandler(evt) 10 function eventHandler(evt)
11 { 11 {
12 if (logEvent) { 12 if (logEvent) {
13 if (expected == evt.type) 13 if (expected == evt.type)
14 debug("Test " + counter + " / " + tests + " PASSED"); 14 debug("Test " + counter + " / " + tests + " PASSED");
15 else 15 else
16 debug("Test " + counter + " / " + tests + " FAILED (expected: '" + e xpected + "' actual: '" + evt.type + "')"); 16 debug("Test " + counter + " / " + tests + " FAILED (expected: '" + e xpected + "' actual: '" + evt.type + "')");
17 } 17 }
18 18
19 setTimeout(counter < tests ? driveTests : finishTest, 0); 19 setTimeout(counter < tests ? driveTests : finishTest, 0);
20 } 20 }
21 21
22 function finishTest() 22 function finishTest()
23 { 23 {
24 successfullyParsed = true; 24 successfullyParsed = true;
25 25
26 useElement.instanceRoot.correspondingElement.setAttribute("fill", "green"); 26 rectElement.setAttribute("fill", "green");
27 shouldBeTrue("successfullyParsed"); 27 shouldBeTrue("successfullyParsed");
28 debug('<br /><span class="pass">TEST COMPLETE</span>'); 28 debug('<br /><span class="pass">TEST COMPLETE</span>');
29 29
30 finishRepaintTest(); 30 finishRepaintTest();
31 } 31 }
32 32
33 function recordMouseEvent(type) 33 function recordMouseEvent(type)
34 { 34 {
35 expected = type; 35 expected = type;
36 logEvent = true; 36 logEvent = true;
(...skipping 22 matching lines...) Expand all
59 } else if (expected == "mousedown") { 59 } else if (expected == "mousedown") {
60 eventSender.mouseMoveTo(50, 50); 60 eventSender.mouseMoveTo(50, 50);
61 eventSender.mouseDown(); 61 eventSender.mouseDown();
62 eventSender.mouseUp(); 62 eventSender.mouseUp();
63 } 63 }
64 } 64 }
65 65
66 function testOne() 66 function testOne()
67 { 67 {
68 // Install event listener on correspondingElement via setAttribute 68 // Install event listener on correspondingElement via setAttribute
69 useElement.instanceRoot.correspondingElement.setAttribute("onmouseover", "ev entHandler(evt)"); 69 shadowRoot.firstChild.setAttribute("onmouseover", "eventHandler(evt)");
70 recordMouseEvent("mouseover"); 70 recordMouseEvent("mouseover");
71 } 71 }
72 72
73 function testTwo() 73 function testTwo()
74 { 74 {
75 // Install event listener on correspondingElement via onmouseout JS magic 75 // Install event listener on correspondingElement via onmouseout JS magic
76 useElement.instanceRoot.correspondingElement.onmouseout = eventHandler; 76 shadowRoot.firstChild.onmouseout = eventHandler;
77 recordMouseEvent("mouseout"); 77 recordMouseEvent("mouseout");
78 } 78 }
79 79
80 function testThree() 80 function testThree()
81 { 81 {
82 // Clean event listeners on different ways 82 // Clean event listeners on different ways
83 useElement.instanceRoot.correspondingElement.removeAttribute("onmouseover"); 83 shadowRoot.firstChild.removeAttribute("onmouseover");
84 useElement.instanceRoot.correspondingElement.onmouseout = 0; 84 shadowRoot.firstChild.onmouseout = 0;
85 85
86 // Verify they really got removed 86 // Verify they really got removed
87 sendMouseEvent("mouseover"); 87 sendMouseEvent("mouseover");
88 sendMouseEvent("mouseout"); 88 sendMouseEvent("mouseout");
89 89
90 // Verify the original listener still works 90 // Verify the original listener still works
91 recordMouseEvent("mousedown"); 91 recordMouseEvent("mousedown");
92 } 92 }
93 93
94 function testFour() 94 function testFour()
95 { 95 {
96 useElement.instanceRoot.correspondingElement.removeAttribute("onmousedown"); 96 shadowRoot.firstChild.removeAttribute("onmousedown");
97 97
98 // Install event listener on the referenced element, without using the SVGEl ementInstance interface 98 // Install event listener on the referenced element, without using the SVGEl ementInstance interface
99 rectElement.setAttribute("onmouseup", "eventHandler(evt)"); 99 rectElement.setAttribute("onmouseup", "eventHandler(evt)");
100 recordMouseEvent("mouseup"); 100 recordMouseEvent("mouseup");
101 } 101 }
102 102
103 function testFive() 103 function testFive()
104 { 104 {
105 rectElement.onmouseout = eventHandler; 105 rectElement.onmouseout = eventHandler;
106 recordMouseEvent("mouseout"); 106 recordMouseEvent("mouseout");
107 } 107 }
108 108
109 function testSix() 109 function testSix()
110 { 110 {
111 useElement.instanceRoot.correspondingElement.onmouseout = null; 111 shadowRoot.firstChild.onmouseout = null;
112 sendMouseEvent("mouseout"); 112 sendMouseEvent("mouseout");
113 113
114 useElement.instanceRoot.correspondingElement.removeAttribute('onmouseup'); 114 shadowRoot.firstChild.removeAttribute('onmouseup');
115 sendMouseEvent("mouseup"); 115 sendMouseEvent("mouseup");
116 116
117 useElement.instanceRoot.correspondingElement.onmouseup = eventHandler; 117 shadowRoot.firstChild.onmouseup = eventHandler;
118 recordMouseEvent("mouseup"); 118 recordMouseEvent("mouseup");
119 } 119 }
120 120
121 function testSeven() 121 function testSeven()
122 { 122 {
123 useElement.instanceRoot.addEventListener("mouseout", eventHandler, false); 123 shadowRoot.firstChild.addEventListener("mouseout", eventHandler, false);
124 recordMouseEvent("mouseout"); 124 recordMouseEvent("mouseout");
125 } 125 }
126 126
127 function testEight() 127 function testEight()
128 { 128 {
129 useElement.instanceRoot.correspondingElement.addEventListener("mouseover", e ventHandler, false); 129 shadowRoot.firstChild.addEventListener("mouseover", eventHandler, false);
130 recordMouseEvent("mouseover"); 130 recordMouseEvent("mouseover");
131 } 131 }
132 132
133 function testNine() 133 function testNine()
134 { 134 {
135 rectElement.addEventListener("mousedown", eventHandler, false); 135 rectElement.addEventListener("mousedown", eventHandler, false);
136 recordMouseEvent("mousedown"); 136 recordMouseEvent("mousedown");
137 } 137 }
138 138
139 function driveTests() 139 function driveTests()
(...skipping 25 matching lines...) Expand all
165 break; 165 break;
166 } 166 }
167 } 167 }
168 168
169 function repaintTest() { 169 function repaintTest() {
170 if (window.eventSender) 170 if (window.eventSender)
171 driveTests(); 171 driveTests();
172 else 172 else
173 alert("This test must be run via DRT!"); 173 alert("This test must be run via DRT!");
174 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698