Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / styles-4 / styles-history.html
blobc59ab0650e9823dab62b0e6ed72f53c286796870
1 <html>
2 <head>
4 <link rel="stylesheet" href="../styles/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/styles-test.js"></script>
10 <script>
12 function test()
14 InspectorTest.runAfterCachedResourcesProcessed(runTestSuite);
16 var uiSourceCode;
18 function runTestSuite()
20 InspectorTest.runTestSuite([
21 function testSetUp(next)
23 function visitUISourceCodes(currentUISourceCode)
25 if (currentUISourceCode.originURL().indexOf("styles-history.css") === -1)
26 return;
27 uiSourceCode = currentUISourceCode;
28 next();
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()
40 dumpHistory(next)();
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()
56 dumpHistory(next)();
61 function testSetContentViaModelMinor(next)
63 styleSheetForResource(step1);
65 function step1(style)
67 var property = getLiveProperty(style, "margin");
68 property.setText("margin:25px;", false, true).then(dumpHistory(next));
72 function testSetContentViaModelMajor(next)
74 styleSheetForResource(step1);
76 function step1(style)
78 var property = getLiveProperty(style, "margin");
79 InspectorTest.addSniffer(WebInspector.UISourceCode.prototype, "addRevision", dumpHistory(next));
80 property.setText("margin:30px;", true, true);
83 ]);
86 function styleSheetForResource(callback)
88 InspectorTest.nodeWithId("mainBody", onNodeSelected);
90 function onNodeSelected(node)
92 InspectorTest.CSSAgent.getMatchedStylesForNode(node.id, onMatchedStylesForNode);
95 function onMatchedStylesForNode(error, inlineStyle, attributeStyle, matchedStyles)
97 if (error) {
98 InspectorTest.addResult("error: " + error);
99 InspectorTest.completeTest();
100 return;
102 for (var i = 0; i < matchedStyles.length; ++i) {
103 var rule = matchedStyles[i].rule;
104 if (rule.origin !== "regular")
105 continue;
106 callback(new WebInspector.CSSStyleDeclaration(InspectorTest.cssModel, null, rule.style));
107 return;
109 InspectorTest.addResult("error: did not find any regular rule");
110 InspectorTest.completeTest();
114 function dumpHistory(next)
116 function result()
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);
123 next();
125 return result;
128 function getLiveProperty(style, name)
130 for (var property of style.allProperties) {
131 if (!property.activeInStyle())
132 continue;
133 if (property.name === name)
134 return property;
136 return null;
140 </script>
141 </head>
143 <body id="mainBody" onload="runTest()">
145 Tests resources panel history.
146 </p>
147 </body>
148 </html>