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 var pendingCallbacks = [];
14 InspectorTest.runAfterCachedResourcesProcessed(runTestSuite);
19 function runTestSuite()
21 InspectorTest.runTestSuite([
22 function testSetUp(next)
24 function visitResource(resource)
26 if (resource.url.indexOf("styles-history.css") === -1)
28 styleResource = resource;
31 WebInspector.resourceTreeModel.forAllResources(visitResource);
34 function testSetResourceContentMinor(next)
36 styleResource.setContent("body {\n margin: 15px;\n padding: 10px;\n}", false, dumpHistory(next));
39 function testSetResourceContentMajor(next)
41 styleResource.setContent("body {\n margin: 20px;\n padding: 10px;\n}", true, dumpHistory(next));
44 function testSetContentViaModelMinor(next)
46 styleSheetForResource(step1);
48 function step1(styleSheet)
50 var style = styleSheet.rules[0].style;
51 var property = style.getLiveProperty("margin");
52 property.setText("margin:25px;", false, true, dumpHistory(next));
56 function testSetContentViaModelMajor(next)
58 styleSheetForResource(step1);
60 function step1(styleSheet)
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));
71 function styleSheetForResource(callback)
73 CSSAgent.getAllStyleSheets(didGetAllStyleSheets.bind(this));
75 function didGetAllStyleSheets(error, infos)
78 InspectorTest.addResult("Error:" + error);
83 for (var i = 0; i < infos.length; ++i) {
85 if (info.sourceURL.indexOf("styles-history.css") === -1)
87 WebInspector.CSSStyleSheet.createForId(info.styleSheetId, callback);
94 function dumpHistory(next)
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);
112 <body onload="runTest()">
114 Tests resources panel history.