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>
9 <script src="styles-test.js"></script>
14 InspectorTest.runAfterCachedResourcesProcessed(runTestSuite);
18 function runTestSuite()
20 InspectorTest.runTestSuite([
21 function testSetUp(next)
23 function visitUISourceCodes(currentUISourceCode)
25 if (currentUISourceCode.originURL().indexOf("styles-history.css") === -1)
27 uiSourceCode = currentUISourceCode;
30 WebInspector.workspace.uiSourceCodes().forEach(visitUISourceCodes);
33 function testSetResourceContentMinor(next)
35 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "_styleContentSet", styleUpdatedMinor);
36 uiSourceCode.setWorkingCopy("body {\n margin: 15px;\n padding: 10px;\n}");
38 function styleUpdatedMinor()
44 function testSetResourceContentMajor(next)
46 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "_styleContentSet", styleUpdatedMinor);
47 uiSourceCode.setWorkingCopy("body {\n margin: 20px;\n padding: 10px;\n}");
49 function styleUpdatedMinor()
51 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "_styleContentSet", styleUpdatedMajor);
52 uiSourceCode.commitWorkingCopy(function() { });
54 function styleUpdatedMajor()
61 function testSetContentViaModelMinor(next)
63 styleSheetForResource(step1);
67 var property = style.getLiveProperty("margin");
68 property.setText("margin:25px;", false, true, dumpHistory(next));
72 function testSetContentViaModelMajor(next)
74 styleSheetForResource(step1);
78 var property = style.getLiveProperty("margin");
79 property.setText("margin:30px;", true, true);
80 InspectorTest.runAfterPendingDispatches(dumpHistory(next));
86 function styleSheetForResource(callback)
88 InspectorTest.nodeWithId("mainBody", onNodeSelected);
90 function onNodeSelected(node)
92 CSSAgent.getMatchedStylesForNode(node.id, false, false, onMatchedStylesForNode);
95 function onMatchedStylesForNode(error, matchedStyles)
98 InspectorTest.addResult("error: " + error);
99 InspectorTest.completeTest();
102 for (var i = 0; i < matchedStyles.length; ++i) {
103 var rule = matchedStyles[i].rule;
104 if (rule.origin !== "regular")
106 callback(WebInspector.CSSStyleDeclaration.parsePayload(WebInspector.cssModel, rule.style));
109 InspectorTest.addResult("error: did not find any regular rule");
110 InspectorTest.completeTest();
114 function dumpHistory(next)
118 InspectorTest.addResult("History length: " + uiSourceCode.history.length);
119 for (var i = 0; i < uiSourceCode.history.length; ++i) {
120 InspectorTest.addResult("Item " + i + ":");
121 InspectorTest.addResult(uiSourceCode.history[i].content);
132 <body id="mainBody" onload="runTest()">
134 Tests resources panel history.