[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / inspector / styles / styles-history.html
1 <html>
2 <head>
3
4 <link rel="stylesheet" href="resources/styles-history.css">
5
6 <script src="../../http/tests/inspector/inspector-test.js"></script>
7 <script src="../../http/tests/inspector/elements-test.js"></script>
8 <script src="../../http/tests/inspector/resources-test.js"></script>
9 <script>
10
11 function test()
12 {
13     var pendingCallbacks = [];
14     InspectorTest.runAfterCachedResourcesProcessed(runTestSuite);
15
16     var styleResource;
17     var styleSheetId;
18
19     function runTestSuite()
20     {
21         InspectorTest.runTestSuite([
22             function testSetUp(next)
23             {
24                 function visitResource(resource)
25                 {
26                     if (resource.url.indexOf("styles-history.css") === -1)
27                         return;
28                     styleResource = resource;
29                     next();
30                 }
31                 WebInspector.resourceTreeModel.forAllResources(visitResource);
32             },
33
34             function testSetResourceContentMinor(next)
35             {
36                 styleResource.setContent("body {\n  margin: 15px;\n  padding: 10px;\n}", false, dumpHistory(next));
37             },
38
39             function testSetResourceContentMajor(next)
40             {
41                 styleResource.setContent("body {\n  margin: 20px;\n  padding: 10px;\n}", true, dumpHistory(next));
42             },
43
44             function testSetContentViaModelMinor(next)
45             {
46                 styleSheetForResource(step1);
47
48                 function step1(styleSheet)
49                 {
50                     var style = styleSheet.rules[0].style;
51                     var property = style.getLiveProperty("margin");
52                     property.setText("margin:25px;", false, true, dumpHistory(next));
53                 }
54             },
55
56             function testSetContentViaModelMajor(next)
57             {
58                 styleSheetForResource(step1);
59
60                 function step1(styleSheet)
61                 {
62                     var style = styleSheet.rules[0].style;
63                     var property = style.getLiveProperty("margin");
64                     property.setText("margin:30px;", true, true);
65                     InspectorTest.runAfterPendingDispatches(dumpHistory(next));
66                 }
67             }
68         ]);
69     }
70
71     function styleSheetForResource(callback)
72     {
73         CSSAgent.getAllStyleSheets(didGetAllStyleSheets.bind(this));
74         
75         function didGetAllStyleSheets(error, infos)
76         {
77             if (error) {
78                 InspectorTest.addResult("Error:" + error);
79                 callback(null);
80                 return;
81             }
82
83             for (var i = 0; i < infos.length; ++i) {
84                 var info = infos[i];
85                 if (info.sourceURL.indexOf("styles-history.css") === -1)
86                     continue;
87                 WebInspector.CSSStyleSheet.createForId(info.styleSheetId, callback);
88                 return;
89             }
90             callback(null);
91         }
92     }
93
94     function dumpHistory(next)
95     {
96         function result()
97         {
98             InspectorTest.addResult("History length: " + styleResource.history.length);
99             for (var i = 0; i < styleResource.history.length; ++i) {
100                 InspectorTest.addResult("Item " + i + ":");
101                 InspectorTest.addResult(styleResource.history[i].content);
102             }
103             next();
104         }
105         return result;
106     }
107 }
108
109 </script>
110 </head>
111
112 <body onload="runTest()">
113 <p>
114 Tests resources panel history.
115 </p>
116 </body>
117 </html>