4 <link rel="stylesheet" href="resources/styles-history.css">
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>
13 InspectorTest.runAfterCachedResourcesProcessed(runTestSuite);
17 function runTestSuite()
19 InspectorTest.runTestSuite([
20 function testSetUp(next)
22 function visitUISourceCodes(currentUISourceCode)
24 if (currentUISourceCode.originURL().indexOf("styles-history.css") === -1)
26 uiSourceCode = currentUISourceCode;
29 WebInspector.workspace.uiSourceCodes().forEach(visitUISourceCodes);
32 function testSetResourceContentMinor(next)
34 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "_styleContentSet", styleUpdatedMinor);
35 uiSourceCode.setWorkingCopy("body {\n margin: 15px;\n padding: 10px;\n}");
37 function styleUpdatedMinor()
43 function testSetResourceContentMajor(next)
45 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "_styleContentSet", styleUpdatedMinor);
46 uiSourceCode.setWorkingCopy("body {\n margin: 20px;\n padding: 10px;\n}");
48 function styleUpdatedMinor()
50 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "_styleContentSet", styleUpdatedMajor);
51 uiSourceCode.commitWorkingCopy(function() { });
53 function styleUpdatedMajor()
60 function testSetContentViaModelMinor(next)
62 styleSheetForResource(step1);
64 function step1(styleSheet)
66 var style = styleSheet.rules[0].style;
67 var property = style.getLiveProperty("margin");
68 property.setText("margin:25px;", false, true, dumpHistory(next));
72 function testSetContentViaModelMajor(next)
74 styleSheetForResource(step1);
76 function step1(styleSheet)
78 var style = styleSheet.rules[0].style;
79 var property = style.getLiveProperty("margin");
80 property.setText("margin:30px;", true, true);
81 InspectorTest.runAfterPendingDispatches(dumpHistory(next));
87 function styleSheetForResource(callback)
89 CSSAgent.getAllStyleSheets(didGetAllStyleSheets.bind(this));
91 function didGetAllStyleSheets(error, infos)
94 InspectorTest.addResult("Error:" + error);
99 for (var i = 0; i < infos.length; ++i) {
101 if (info.sourceURL.indexOf("styles-history.css") === -1)
103 WebInspector.CSSStyleSheet.createForId(info.styleSheetId, callback);
110 function dumpHistory(next)
114 InspectorTest.addResult("History length: " + uiSourceCode.history.length);
115 for (var i = 0; i < uiSourceCode.history.length; ++i) {
116 InspectorTest.addResult("Item " + i + ":");
117 InspectorTest.addResult(uiSourceCode.history[i].content);
128 <body onload="runTest()">
130 Tests resources panel history.