| <html> |
| <head> |
| <script src="../http/tests/inspector/inspector-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| function TestView(viewName, requiredCSS, requiredCSS2) |
| { |
| WebInspector.View.call(this); |
| |
| this.registerRequiredCSS(requiredCSS); |
| if (requiredCSS2) |
| this.registerRequiredCSS(requiredCSS2); |
| this._viewName = viewName; |
| } |
| |
| TestView.prototype = { |
| show: function(parentElement) |
| { |
| InspectorTest.addResult(this._viewName + ".show()"); |
| WebInspector.View.prototype.show.call(this, parentElement); |
| }, |
| |
| detach: function() |
| { |
| InspectorTest.addResult(this._viewName + ".detach()"); |
| WebInspector.View.prototype.detach.call(this); |
| }, |
| }; |
| |
| TestView.prototype.__proto__ = WebInspector.View.prototype; |
| |
| var cssToLoad = { |
| "parent.css": true, |
| "child.css": true, |
| "child1.css": true, |
| "child2.css": true |
| }; |
| |
| function dumpCssChanges() |
| { |
| for (var file in WebInspector.View._cssFileToStyleElement) |
| if (cssToLoad.hasOwnProperty(file)) { |
| if ((!WebInspector.View._cssFileToStyleElement[file] && !cssToLoad[file]) || |
| (WebInspector.View._cssFileToStyleElement[file].disabled !== cssToLoad[file])) { |
| InspectorTest.addResult((WebInspector.View._cssFileToStyleElement[file].disabled ? " UNLOAD " : " LOAD ") + file); |
| cssToLoad[file] = WebInspector.View._cssFileToStyleElement[file].disabled; |
| } |
| } |
| } |
| |
| WebInspector.View._cssUnloadTimeout = 0; |
| |
| var parentView = new TestView("Parent", "parent.css"); |
| var childView1 = new TestView("Child 1", "child.css", "child1.css"); |
| var childView2 = new TestView("Child 2", "child.css", "child2.css"); |
| |
| InspectorTest.runTestSuite([ |
| function testEvents(next) |
| { |
| parentView.show(WebInspector.inspectorView.element); |
| dumpCssChanges(); |
| |
| childView1.show(parentView.element); |
| dumpCssChanges(); |
| |
| childView2.show(parentView.element); |
| dumpCssChanges(); |
| |
| childView2.detach(parentView.element); |
| dumpCssChanges(); |
| |
| setTimeout(next, WebInspector.View._cssUnloadTimeout); |
| }, |
| |
| function childDetachTimeout(next) |
| { |
| dumpCssChanges(); |
| |
| parentView.detach(); |
| dumpCssChanges(); |
| |
| setTimeout(next, WebInspector.View._cssUnloadTimeout); |
| }, |
| |
| function parentDetachTimeout(next) |
| { |
| dumpCssChanges(); |
| |
| parentView.show(WebInspector.inspectorView.element); |
| dumpCssChanges(); |
| |
| next(); |
| }, |
| |
| function quickDetachAttach(next) { |
| childView1.detach(); |
| dumpCssChanges(); |
| |
| childView1.show(parentView.element); |
| dumpCssChanges(); |
| |
| setTimeout(next, WebInspector.View._cssUnloadTimeout); |
| }, |
| |
| function checkThatNothingUnloaded(next) { |
| dumpCssChanges(); |
| next(); |
| } |
| ]); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| This tests that CSS files are properly loaded / unloaded upon view show / detach. |
| </p> |
| |
| </body> |
| </html> |