Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / widget-events.html
blobfc694f715a7a95926be16b222f7ac32f6842acfa
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script>
6 function test()
8 function TestWidget(widgetName)
10 WebInspector.Widget.call(this);
12 this._widgetName = widgetName;
13 this._processWillShowCount = 0;
14 this._processWasHiddenCount = 0;
15 InspectorTest.addResult(this._widgetName + "()");
18 TestWidget.prototype = {
19 _processWillShow: function()
21 InspectorTest.assertEquals(this._processWillShowCount, this._processWasHiddenCount);
22 WebInspector.Widget.prototype._processWillShow.call(this);
23 ++this._processWillShowCount;
26 _processWasHidden: function()
28 WebInspector.Widget.prototype._processWasHidden.call(this);
29 ++this._processWasHiddenCount;
30 InspectorTest.assertEquals(this._processWillShowCount, this._processWasHiddenCount);
33 show: function(parentElement)
35 InspectorTest.addResult(this._widgetName + ".show()");
36 WebInspector.Widget.prototype.show.call(this, parentElement);
39 detach: function()
41 InspectorTest.addResult(this._widgetName + ".detach()");
42 WebInspector.Widget.prototype.detach.call(this);
45 doResize: function()
47 InspectorTest.addResult(this._widgetName + ".doResize()");
48 WebInspector.Widget.prototype.doResize.call(this);
51 wasShown: function()
53 InspectorTest.addResult(" " + this._widgetName + ".wasShown()");
54 if (this.showOnWasShown)
55 this.showOnWasShown.show(this.showRoot || this.element);
56 if (this.detachOnWasShown)
57 this.detachOnWasShown.detach();
58 if (this.resizeOnWasShown)
59 this.resizeOnWasShown.doResize();
62 willHide: function()
64 InspectorTest.addResult(" " + this._widgetName + ".willHide()");
65 if (this.showOnWillHide)
66 this.showOnWillHide.show(this.element);
67 if (this.detachOnWillHide)
68 this.detachOnWillHide.detach();
71 onResize: function()
73 InspectorTest.addResult(" " + this._widgetName + ".onResize()");
77 TestWidget.prototype.__proto__ = WebInspector.Widget.prototype;
79 InspectorTest.runTestSuite([
80 function testShowWidget(next)
82 var widget = new TestWidget("Widget");
83 widget.show(WebInspector.inspectorView.element);
84 widget.detach();
85 next();
88 function testAppendViaDOM(next)
90 try {
91 var widget = new TestWidget("Widget");
92 document.body.appendChild(widget.element);
93 } catch (e) {
94 InspectorTest.addResult(e);
96 next();
99 function testInsertViaDOM(next)
101 try {
102 var widget = new TestWidget("Widget");
103 document.body.insertBefore(widget.element, null);
104 } catch (e) {
105 InspectorTest.addResult(e);
107 next();
110 function testAttachToOrphanNode(next)
112 try {
113 var widget = new TestWidget("Widget");
114 var div = document.createElement("div");
115 widget.show(div);
116 } catch (e) {
117 InspectorTest.addResult(e);
119 next();
122 function testImmediateParent(next)
124 var parentWidget = new TestWidget("Parent");
125 var childWidget = new TestWidget("Child");
126 childWidget.show(parentWidget.element);
127 if (childWidget._parentWidget === parentWidget)
128 InspectorTest.addResult("OK");
129 else
130 InspectorTest.addResult("FAILED");
131 next();
134 function testDistantParent(next)
136 var parentWidget = new TestWidget("Parent");
137 var div = document.createElement("div");
138 parentWidget.element.appendChild(div);
139 var childWidget = new TestWidget("Child");
140 childWidget.show(div);
142 if (childWidget._parentWidget === parentWidget)
143 InspectorTest.addResult("OK");
144 else
145 InspectorTest.addResult("FAILED");
146 next();
149 function testEvents(next)
151 var parentWidget = new TestWidget("Parent");
152 parentWidget.markAsRoot();
153 var childWidget = new TestWidget("Child");
154 parentWidget.show(WebInspector.inspectorView.element);
156 parentWidget.doResize();
157 childWidget.show(parentWidget.element);
158 parentWidget.doResize();
159 parentWidget.detach();
160 parentWidget.show(WebInspector.inspectorView.element);
161 childWidget.detach();
162 parentWidget.detach();
163 next();
166 function testEventsHideOnDetach(next)
168 var parentWidget = new TestWidget("Parent");
169 var childWidget = new TestWidget("Child");
170 childWidget.setHideOnDetach();
171 parentWidget.show(WebInspector.inspectorView.element);
173 parentWidget.doResize();
174 childWidget.show(parentWidget.element);
175 parentWidget.doResize();
176 parentWidget.detach();
177 parentWidget.show(WebInspector.inspectorView.element);
178 childWidget.detach();
179 parentWidget.detach();
180 next();
183 function testWidgetCounter(next)
185 var parentWidget = new TestWidget("Parent");
186 parentWidget.show(WebInspector.inspectorView.element);
188 var childWidget = new TestWidget("Child");
189 childWidget.show(parentWidget.element);
190 InspectorTest.addResult(" widget counter: " + parentWidget.element.__widgetCounter);
192 var childWidget2 = new TestWidget("Child 2");
193 childWidget2.show(parentWidget.element);
194 InspectorTest.addResult(" widget counter: " + parentWidget.element.__widgetCounter);
196 childWidget.detach();
197 InspectorTest.addResult(" widget counter: " + parentWidget.element.__widgetCounter);
199 childWidget2.detach();
200 InspectorTest.addResult(" widget counter: " + parentWidget.element.__widgetCounter);
202 next();
205 function testRemoveChild(next)
207 var parentWidget = new TestWidget("Parent");
208 parentWidget.show(WebInspector.inspectorView.element);
210 var childWidget = new TestWidget("Child");
211 childWidget.show(parentWidget.element);
212 try {
213 parentWidget.element.removeChild(childWidget.element);
214 } catch (e) {
215 InspectorTest.addResult(e);
217 next();
220 function testImplicitRemoveChild(next)
222 var parentWidget = new TestWidget("Parent");
223 var div = document.createElement("div");
224 parentWidget.element.appendChild(div);
226 var childWidget = new TestWidget("Child");
227 childWidget.show(div);
229 try {
230 parentWidget.element.removeChild(div);
231 } catch (e) {
232 InspectorTest.addResult(e);
234 next();
237 function testRemoveChildren(next)
239 var parentWidget = new TestWidget("Parent");
240 var childWidget = new TestWidget("Child");
241 childWidget.show(parentWidget.element);
242 parentWidget.element.appendChild(document.createElement("div"));
243 try {
244 parentWidget.element.removeChildren();
245 } catch (e) {
246 InspectorTest.addResult(e);
248 next();
251 function testImplicitRemoveChildren(next)
253 var parentWidget = new TestWidget("Parent");
254 var div = document.createElement("div");
255 parentWidget.element.appendChild(div);
257 var childWidget = new TestWidget("Child");
258 childWidget.show(div);
260 try {
261 parentWidget.element.removeChildren();
262 } catch (e) {
263 InspectorTest.addResult(e);
265 next();
268 function testShowOnWasShown(next)
270 var parentWidget = new TestWidget("Parent");
271 parentWidget.showOnWasShown = new TestWidget("Child");
272 parentWidget.show(WebInspector.inspectorView.element);
273 parentWidget.detach();
274 next();
277 function testShowNestedOnWasShown(next)
279 var topWidget = new TestWidget("Top");
280 var middleWidget = new TestWidget("Middle");
281 var bottomWidget = new TestWidget("Bottom");
282 middleWidget.show(topWidget.element);
283 topWidget.showOnWasShown = bottomWidget;
284 topWidget.showRoot = middleWidget.element;
285 topWidget.show(WebInspector.inspectorView.element);
286 topWidget.detach();
287 next();
290 function testDetachOnWasShown(next)
292 var parentWidget = new TestWidget("Parent");
293 var childWidget = new TestWidget("Child");
294 childWidget.show(parentWidget.element);
295 parentWidget.detachOnWasShown = childWidget;
296 parentWidget.show(WebInspector.inspectorView.element);
297 parentWidget.detach();
298 next();
301 function testShowOnWillHide(next)
303 var parentWidget = new TestWidget("Parent");
304 var childWidget = new TestWidget("Child");
305 parentWidget.show(WebInspector.inspectorView.element);
306 childWidget.show(parentWidget.element);
307 parentWidget.showOnWillHide = childWidget;
308 parentWidget.detach();
309 next();
312 function testDetachOnWillHide(next)
314 var parentWidget = new TestWidget("Parent");
315 var childWidget = new TestWidget("Child");
316 parentWidget.show(WebInspector.inspectorView.element);
317 childWidget.show(parentWidget.element);
318 parentWidget.detachOnWillHide = childWidget;
319 parentWidget.detach();
320 next();
323 function testShowDetachesFromPrevious(next)
325 var parentWidget1 = new TestWidget("Parent1");
326 var parentWidget2 = new TestWidget("Parent2");
327 var childWidget = new TestWidget("Child");
328 parentWidget1.show(WebInspector.inspectorView.element);
329 parentWidget2.show(WebInspector.inspectorView.element);
330 childWidget.show(parentWidget1.element);
331 childWidget.show(parentWidget2.element);
332 next();
335 function testResizeOnWasShown(next)
337 var parentWidget = new TestWidget("Parent");
338 var childWidget = new TestWidget("Child");
339 childWidget.show(parentWidget.element);
340 parentWidget.resizeOnWasShown = childWidget;
341 parentWidget.show(WebInspector.inspectorView.element);
342 parentWidget.detach();
343 next();
348 </script>
349 </head>
351 <body onload="runTest()">
353 This tests that events are properly propagated through Widget hierarchy.
354 </p>
356 </body>
357 </html>