Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / view-css.html
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script>
5
6 function test()
7 {
8     function TestView(viewName, requiredCSS, requiredCSS2)
9     {
10         WebInspector.View.call(this);
11
12         this.registerRequiredCSS(requiredCSS);
13         if (requiredCSS2)
14             this.registerRequiredCSS(requiredCSS2);
15         this._viewName = viewName;
16     }
17
18     TestView.prototype = {
19         show: function(parentElement)
20         {
21             InspectorTest.addResult(this._viewName + ".show()");
22             WebInspector.View.prototype.show.call(this, parentElement);
23         },
24
25         detach: function()
26         {
27             InspectorTest.addResult(this._viewName + ".detach()");
28             WebInspector.View.prototype.detach.call(this);
29         },
30     };
31
32     TestView.prototype.__proto__ = WebInspector.View.prototype;
33
34     var cssToLoad = {
35         "parent.css": true,
36         "child.css": true,
37         "child1.css": true,
38         "child2.css": true
39     };
40
41     function dumpCssChanges()
42     {
43         for (var file in WebInspector.View._cssFileToStyleElement)
44             if (cssToLoad.hasOwnProperty(file)) {
45                 if ((!WebInspector.View._cssFileToStyleElement[file] && !cssToLoad[file]) ||
46                     (WebInspector.View._cssFileToStyleElement[file].disabled !== cssToLoad[file])) {
47                     InspectorTest.addResult((WebInspector.View._cssFileToStyleElement[file].disabled ? "  UNLOAD " : "  LOAD ") + file);
48                     cssToLoad[file] = WebInspector.View._cssFileToStyleElement[file].disabled;
49                 }
50             }
51     }
52
53     WebInspector.View._cssUnloadTimeout = 0;
54
55     var parentView = new TestView("Parent", "parent.css");
56     var childView1 = new TestView("Child 1", "child.css", "child1.css");
57     var childView2 = new TestView("Child 2", "child.css", "child2.css");
58
59     InspectorTest.runTestSuite([
60         function testEvents(next)
61         {
62             parentView.show(WebInspector.inspectorView.element);
63             dumpCssChanges();
64
65             childView1.show(parentView.element);
66             dumpCssChanges();
67
68             childView2.show(parentView.element);
69             dumpCssChanges();
70
71             childView2.detach(parentView.element);
72             dumpCssChanges();
73
74             setTimeout(next, WebInspector.View._cssUnloadTimeout);
75         },
76
77         function childDetachTimeout(next)
78         {
79             dumpCssChanges();
80
81             parentView.detach();
82             dumpCssChanges();
83
84             setTimeout(next, WebInspector.View._cssUnloadTimeout);
85         },
86
87         function parentDetachTimeout(next)
88         {
89             dumpCssChanges();
90
91             parentView.show(WebInspector.inspectorView.element);
92             dumpCssChanges();
93
94             next();
95         },
96
97         function quickDetachAttach(next) {
98             childView1.detach();
99             dumpCssChanges();
100
101             childView1.show(parentView.element);
102             dumpCssChanges();
103
104             setTimeout(next, WebInspector.View._cssUnloadTimeout);
105         },
106
107         function checkThatNothingUnloaded(next) {
108             dumpCssChanges();
109             next();
110         }
111     ]);
112 }
113
114 </script>
115 </head>
116
117 <body onload="runTest()">
118 <p>
119 This tests that CSS files are properly loaded / unloaded upon view show / detach.
120 </p>
121
122 </body>
123 </html>