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>
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
= getLiveProperty(style
, "margin");
68 property
.setText("margin:25px;", false, true).then(dumpHistory(next
));
72 function testSetContentViaModelMajor(next
)
74 styleSheetForResource(step1
);
78 var property
= getLiveProperty(style
, "margin");
79 InspectorTest
.addSniffer(WebInspector
.UISourceCode
.prototype, "addRevision", dumpHistory(next
));
80 property
.setText("margin:30px;", true, true);
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
)
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(new WebInspector
.CSSStyleDeclaration(InspectorTest
.cssModel
, null, 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
);
128 function getLiveProperty(style
, name
)
130 for (var property
of style
.allProperties
) {
131 if (!property
.activeInStyle())
133 if (property
.name
=== name
)
143 <body id=
"mainBody" onload=
"runTest()">
145 Tests resources panel history.