| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 function test() | 6 function test() |
| 7 { | 7 { |
| 8 var TestWidget = class extends WebInspector.Widget { | 8 var TestWidget = class extends UI.Widget { |
| 9 constructor(widgetName) | 9 constructor(widgetName) |
| 10 { | 10 { |
| 11 super(); | 11 super(); |
| 12 this._widgetName = widgetName; | 12 this._widgetName = widgetName; |
| 13 this._processWillShowCount = 0; | 13 this._processWillShowCount = 0; |
| 14 this._processWasHiddenCount = 0; | 14 this._processWasHiddenCount = 0; |
| 15 InspectorTest.addResult(this._widgetName + "()"); | 15 InspectorTest.addResult(this._widgetName + "()"); |
| 16 } | 16 } |
| 17 | 17 |
| 18 _processWillShow() | 18 _processWillShow() |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 onResize() | 70 onResize() |
| 71 { | 71 { |
| 72 InspectorTest.addResult(" " + this._widgetName + ".onResize()"); | 72 InspectorTest.addResult(" " + this._widgetName + ".onResize()"); |
| 73 } | 73 } |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 InspectorTest.runTestSuite([ | 76 InspectorTest.runTestSuite([ |
| 77 function testShowWidget(next) | 77 function testShowWidget(next) |
| 78 { | 78 { |
| 79 var widget = new TestWidget("Widget"); | 79 var widget = new TestWidget("Widget"); |
| 80 widget.show(WebInspector.inspectorView.element); | 80 widget.show(UI.inspectorView.element); |
| 81 widget.detach(); | 81 widget.detach(); |
| 82 next(); | 82 next(); |
| 83 }, | 83 }, |
| 84 | 84 |
| 85 function testAppendViaDOM(next) | 85 function testAppendViaDOM(next) |
| 86 { | 86 { |
| 87 try { | 87 try { |
| 88 var widget = new TestWidget("Widget"); | 88 var widget = new TestWidget("Widget"); |
| 89 document.body.appendChild(widget.element); | 89 document.body.appendChild(widget.element); |
| 90 } catch (e) { | 90 } catch (e) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 childWidget.detach(); | 158 childWidget.detach(); |
| 159 parentWidget.detach(); | 159 parentWidget.detach(); |
| 160 next(); | 160 next(); |
| 161 }, | 161 }, |
| 162 | 162 |
| 163 function testEventsHideOnDetach(next) | 163 function testEventsHideOnDetach(next) |
| 164 { | 164 { |
| 165 var parentWidget = new TestWidget("Parent"); | 165 var parentWidget = new TestWidget("Parent"); |
| 166 var childWidget = new TestWidget("Child"); | 166 var childWidget = new TestWidget("Child"); |
| 167 childWidget.setHideOnDetach(); | 167 childWidget.setHideOnDetach(); |
| 168 parentWidget.show(WebInspector.inspectorView.element); | 168 parentWidget.show(UI.inspectorView.element); |
| 169 | 169 |
| 170 parentWidget.doResize(); | 170 parentWidget.doResize(); |
| 171 childWidget.show(parentWidget.element); | 171 childWidget.show(parentWidget.element); |
| 172 parentWidget.doResize(); | 172 parentWidget.doResize(); |
| 173 parentWidget.detach(); | 173 parentWidget.detach(); |
| 174 parentWidget.show(WebInspector.inspectorView.element); | 174 parentWidget.show(UI.inspectorView.element); |
| 175 childWidget.detach(); | 175 childWidget.detach(); |
| 176 parentWidget.detach(); | 176 parentWidget.detach(); |
| 177 next(); | 177 next(); |
| 178 }, | 178 }, |
| 179 | 179 |
| 180 function testWidgetCounter(next) | 180 function testWidgetCounter(next) |
| 181 { | 181 { |
| 182 var parentWidget = new TestWidget("Parent"); | 182 var parentWidget = new TestWidget("Parent"); |
| 183 parentWidget.show(WebInspector.inspectorView.element); | 183 parentWidget.show(UI.inspectorView.element); |
| 184 | 184 |
| 185 var childWidget = new TestWidget("Child"); | 185 var childWidget = new TestWidget("Child"); |
| 186 childWidget.show(parentWidget.element); | 186 childWidget.show(parentWidget.element); |
| 187 InspectorTest.addResult(" widget counter: " + parentWidget.element.
__widgetCounter); | 187 InspectorTest.addResult(" widget counter: " + parentWidget.element.
__widgetCounter); |
| 188 | 188 |
| 189 var childWidget2 = new TestWidget("Child 2"); | 189 var childWidget2 = new TestWidget("Child 2"); |
| 190 childWidget2.show(parentWidget.element); | 190 childWidget2.show(parentWidget.element); |
| 191 InspectorTest.addResult(" widget counter: " + parentWidget.element.
__widgetCounter); | 191 InspectorTest.addResult(" widget counter: " + parentWidget.element.
__widgetCounter); |
| 192 | 192 |
| 193 childWidget.detach(); | 193 childWidget.detach(); |
| 194 InspectorTest.addResult(" widget counter: " + parentWidget.element.
__widgetCounter); | 194 InspectorTest.addResult(" widget counter: " + parentWidget.element.
__widgetCounter); |
| 195 | 195 |
| 196 childWidget2.detach(); | 196 childWidget2.detach(); |
| 197 InspectorTest.addResult(" widget counter: " + parentWidget.element.
__widgetCounter); | 197 InspectorTest.addResult(" widget counter: " + parentWidget.element.
__widgetCounter); |
| 198 | 198 |
| 199 next(); | 199 next(); |
| 200 }, | 200 }, |
| 201 | 201 |
| 202 function testRemoveChild(next) | 202 function testRemoveChild(next) |
| 203 { | 203 { |
| 204 var parentWidget = new TestWidget("Parent"); | 204 var parentWidget = new TestWidget("Parent"); |
| 205 parentWidget.show(WebInspector.inspectorView.element); | 205 parentWidget.show(UI.inspectorView.element); |
| 206 | 206 |
| 207 var childWidget = new TestWidget("Child"); | 207 var childWidget = new TestWidget("Child"); |
| 208 childWidget.show(parentWidget.element); | 208 childWidget.show(parentWidget.element); |
| 209 try { | 209 try { |
| 210 parentWidget.element.removeChild(childWidget.element); | 210 parentWidget.element.removeChild(childWidget.element); |
| 211 } catch (e) { | 211 } catch (e) { |
| 212 InspectorTest.addResult(e); | 212 InspectorTest.addResult(e); |
| 213 } | 213 } |
| 214 next(); | 214 next(); |
| 215 }, | 215 }, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } catch (e) { | 259 } catch (e) { |
| 260 InspectorTest.addResult(e); | 260 InspectorTest.addResult(e); |
| 261 } | 261 } |
| 262 next(); | 262 next(); |
| 263 }, | 263 }, |
| 264 | 264 |
| 265 function testShowOnWasShown(next) | 265 function testShowOnWasShown(next) |
| 266 { | 266 { |
| 267 var parentWidget = new TestWidget("Parent"); | 267 var parentWidget = new TestWidget("Parent"); |
| 268 parentWidget.showOnWasShown = new TestWidget("Child"); | 268 parentWidget.showOnWasShown = new TestWidget("Child"); |
| 269 parentWidget.show(WebInspector.inspectorView.element); | 269 parentWidget.show(UI.inspectorView.element); |
| 270 parentWidget.detach(); | 270 parentWidget.detach(); |
| 271 next(); | 271 next(); |
| 272 }, | 272 }, |
| 273 | 273 |
| 274 function testShowNestedOnWasShown(next) | 274 function testShowNestedOnWasShown(next) |
| 275 { | 275 { |
| 276 var topWidget = new TestWidget("Top"); | 276 var topWidget = new TestWidget("Top"); |
| 277 var middleWidget = new TestWidget("Middle"); | 277 var middleWidget = new TestWidget("Middle"); |
| 278 var bottomWidget = new TestWidget("Bottom"); | 278 var bottomWidget = new TestWidget("Bottom"); |
| 279 middleWidget.show(topWidget.element); | 279 middleWidget.show(topWidget.element); |
| 280 topWidget.showOnWasShown = bottomWidget; | 280 topWidget.showOnWasShown = bottomWidget; |
| 281 topWidget.showRoot = middleWidget.element; | 281 topWidget.showRoot = middleWidget.element; |
| 282 topWidget.show(WebInspector.inspectorView.element); | 282 topWidget.show(UI.inspectorView.element); |
| 283 topWidget.detach(); | 283 topWidget.detach(); |
| 284 next(); | 284 next(); |
| 285 }, | 285 }, |
| 286 | 286 |
| 287 function testDetachOnWasShown(next) | 287 function testDetachOnWasShown(next) |
| 288 { | 288 { |
| 289 var parentWidget = new TestWidget("Parent"); | 289 var parentWidget = new TestWidget("Parent"); |
| 290 var childWidget = new TestWidget("Child"); | 290 var childWidget = new TestWidget("Child"); |
| 291 childWidget.show(parentWidget.element); | 291 childWidget.show(parentWidget.element); |
| 292 parentWidget.detachOnWasShown = childWidget; | 292 parentWidget.detachOnWasShown = childWidget; |
| 293 parentWidget.show(WebInspector.inspectorView.element); | 293 parentWidget.show(UI.inspectorView.element); |
| 294 parentWidget.detach(); | 294 parentWidget.detach(); |
| 295 next(); | 295 next(); |
| 296 }, | 296 }, |
| 297 | 297 |
| 298 function testShowOnWillHide(next) | 298 function testShowOnWillHide(next) |
| 299 { | 299 { |
| 300 var parentWidget = new TestWidget("Parent"); | 300 var parentWidget = new TestWidget("Parent"); |
| 301 var childWidget = new TestWidget("Child"); | 301 var childWidget = new TestWidget("Child"); |
| 302 parentWidget.show(WebInspector.inspectorView.element); | 302 parentWidget.show(UI.inspectorView.element); |
| 303 childWidget.show(parentWidget.element); | 303 childWidget.show(parentWidget.element); |
| 304 parentWidget.showOnWillHide = childWidget; | 304 parentWidget.showOnWillHide = childWidget; |
| 305 parentWidget.detach(); | 305 parentWidget.detach(); |
| 306 next(); | 306 next(); |
| 307 }, | 307 }, |
| 308 | 308 |
| 309 function testDetachOnWillHide(next) | 309 function testDetachOnWillHide(next) |
| 310 { | 310 { |
| 311 var parentWidget = new TestWidget("Parent"); | 311 var parentWidget = new TestWidget("Parent"); |
| 312 var childWidget = new TestWidget("Child"); | 312 var childWidget = new TestWidget("Child"); |
| 313 parentWidget.show(WebInspector.inspectorView.element); | 313 parentWidget.show(UI.inspectorView.element); |
| 314 childWidget.show(parentWidget.element); | 314 childWidget.show(parentWidget.element); |
| 315 parentWidget.detachOnWillHide = childWidget; | 315 parentWidget.detachOnWillHide = childWidget; |
| 316 parentWidget.detach(); | 316 parentWidget.detach(); |
| 317 next(); | 317 next(); |
| 318 }, | 318 }, |
| 319 | 319 |
| 320 function testShowDetachesFromPrevious(next) | 320 function testShowDetachesFromPrevious(next) |
| 321 { | 321 { |
| 322 var parentWidget1 = new TestWidget("Parent1"); | 322 var parentWidget1 = new TestWidget("Parent1"); |
| 323 var parentWidget2 = new TestWidget("Parent2"); | 323 var parentWidget2 = new TestWidget("Parent2"); |
| 324 var childWidget = new TestWidget("Child"); | 324 var childWidget = new TestWidget("Child"); |
| 325 parentWidget1.show(WebInspector.inspectorView.element); | 325 parentWidget1.show(UI.inspectorView.element); |
| 326 parentWidget2.show(WebInspector.inspectorView.element); | 326 parentWidget2.show(UI.inspectorView.element); |
| 327 childWidget.show(parentWidget1.element); | 327 childWidget.show(parentWidget1.element); |
| 328 childWidget.show(parentWidget2.element); | 328 childWidget.show(parentWidget2.element); |
| 329 next(); | 329 next(); |
| 330 }, | 330 }, |
| 331 | 331 |
| 332 function testResizeOnWasShown(next) | 332 function testResizeOnWasShown(next) |
| 333 { | 333 { |
| 334 var parentWidget = new TestWidget("Parent"); | 334 var parentWidget = new TestWidget("Parent"); |
| 335 var childWidget = new TestWidget("Child"); | 335 var childWidget = new TestWidget("Child"); |
| 336 childWidget.show(parentWidget.element); | 336 childWidget.show(parentWidget.element); |
| 337 parentWidget.resizeOnWasShown = childWidget; | 337 parentWidget.resizeOnWasShown = childWidget; |
| 338 parentWidget.show(WebInspector.inspectorView.element); | 338 parentWidget.show(UI.inspectorView.element); |
| 339 parentWidget.detach(); | 339 parentWidget.detach(); |
| 340 next(); | 340 next(); |
| 341 }, | 341 }, |
| 342 | 342 |
| 343 function testAlienParent(next) | 343 function testAlienParent(next) |
| 344 { | 344 { |
| 345 var parentWidget1 = new TestWidget("Parent"); | 345 var parentWidget1 = new TestWidget("Parent"); |
| 346 var parentWidget2 = new TestWidget("Parent"); | 346 var parentWidget2 = new TestWidget("Parent"); |
| 347 var childWidget = new TestWidget("Child"); | 347 var childWidget = new TestWidget("Child"); |
| 348 childWidget.attach(parentWidget1); | 348 childWidget.attach(parentWidget1); |
| 349 try { | 349 try { |
| 350 childWidget.showWidget(parentWidget2.element); | 350 childWidget.showWidget(parentWidget2.element); |
| 351 } catch (e) { | 351 } catch (e) { |
| 352 InspectorTest.addResult(e); | 352 InspectorTest.addResult(e); |
| 353 } | 353 } |
| 354 next(); | 354 next(); |
| 355 }, | 355 }, |
| 356 | 356 |
| 357 function testReparentWithinWidget(next) | 357 function testReparentWithinWidget(next) |
| 358 { | 358 { |
| 359 var parentWidget = new TestWidget("Parent"); | 359 var parentWidget = new TestWidget("Parent"); |
| 360 parentWidget.show(WebInspector.inspectorView.element); | 360 parentWidget.show(UI.inspectorView.element); |
| 361 var childWidget = new TestWidget("Child"); | 361 var childWidget = new TestWidget("Child"); |
| 362 var container1 = parentWidget.element.createChild("div"); | 362 var container1 = parentWidget.element.createChild("div"); |
| 363 var container2 = parentWidget.element.createChild("div"); | 363 var container2 = parentWidget.element.createChild("div"); |
| 364 childWidget.show(container1); | 364 childWidget.show(container1); |
| 365 childWidget.show(container2); | 365 childWidget.show(container2); |
| 366 next(); | 366 next(); |
| 367 } | 367 } |
| 368 ]); | 368 ]); |
| 369 } | 369 } |
| 370 | 370 |
| 371 </script> | 371 </script> |
| 372 </head> | 372 </head> |
| 373 | 373 |
| 374 <body onload="runTest()"> | 374 <body onload="runTest()"> |
| 375 <p> | 375 <p> |
| 376 This tests that events are properly propagated through Widget hierarchy. | 376 This tests that events are properly propagated through Widget hierarchy. |
| 377 </p> | 377 </p> |
| 378 | 378 |
| 379 </body> | 379 </body> |
| 380 </html> | 380 </html> |
| OLD | NEW |