Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: third_party/WebKit/LayoutTests/inspector/elements/styles/original-content-provider.html

Issue 1954423002: DevTools: introduce CSSStyleSheetHeader.originalContentProvider() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify-network-project
Patch Set: address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector/elements/styles/original-content-provider.html
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/styles/original-content-provider.html b/third_party/WebKit/LayoutTests/inspector/elements/styles/original-content-provider.html
new file mode 100644
index 0000000000000000000000000000000000000000..91a84b70a65e8cf008785ad2f6542be0da4bd36f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector/elements/styles/original-content-provider.html
@@ -0,0 +1,123 @@
+<html>
+<head>
+<script src="../../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../../http/tests/inspector/elements-test.js"></script>
+<style>
+div { color: red; }
+/*# sourceURL=set-style.css */
+</style>
+
+<style>
+div {}
+/*# sourceURL=set-selector.css */
+</style>
+
+<style>
+@media (all) { }
+/*# sourceURL=set-media.css */
+</style>
+
+<style>
+@keyframes animation { 100% { color: red; } }
+/*# sourceURL=set-keyframe-key.css */
+</style>
+
+<style>
+div {}
+/*# sourceURL=add-rule.css */
+</style>
+
+<style>
+div {}
+/*# sourceURL=set-text.css */
+</style>
+
+<script>
+
+function test()
+{
+ var headers = InspectorTest.cssModel.styleSheetHeaders();
+ InspectorTest.runTestSuite([
+ function testSetStyle(next)
+ {
+ var header = headers.find(header => header.sourceURL.endsWith("set-style.css"));
+ InspectorTest.cssModel.setStyleText(header.id, new WebInspector.TextRange(1, 5, 1, 18), "EDITED: EDITED", true)
+ .then(success => onEdit(header, success))
+ .then(next);
+ },
+
+ function testSetSelector(next)
+ {
+ var header = headers.find(header => header.sourceURL.endsWith("set-selector.css"));
+ InspectorTest.cssModel.setSelectorText(header.id, new WebInspector.TextRange(1, 0, 1, 3), "EDITED")
+ .then(success => onEdit(header, success))
+ .then(next);
+ },
+
+ function testSetMedia(next)
+ {
+ var header = headers.find(header => header.sourceURL.endsWith("set-media.css"));
+ InspectorTest.cssModel.setMediaText(header.id, new WebInspector.TextRange(1, 7, 1, 12), "EDITED")
+ .then(success => onEdit(header, success))
+ .then(next);
+ },
+
+ function testSetKeyframeKey(next)
+ {
+ var header = headers.find(header => header.sourceURL.endsWith("set-keyframe-key.css"));
+ InspectorTest.cssModel.setKeyframeKey(header.id, new WebInspector.TextRange(1, 23, 1, 27), "from")
+ .then(success => onEdit(header, success))
+ .then(next);
+ },
+
+ function testAddRule(next)
+ {
+ var header = headers.find(header => header.sourceURL.endsWith("add-rule.css"));
+ InspectorTest.cssModel.addRule(header.id, "EDITED {}\n", new WebInspector.TextRange(1, 0, 1, 0))
+ .then(success => onEdit(header, success))
+ .then(next);
+ },
+
+ function testSetStyleSheetText(next)
+ {
+ var header = headers.find(header => header.sourceURL.endsWith("set-text.css"));
+ InspectorTest.cssModel.setStyleSheetText(header.id, "EDITED {}", true)
+ .then(success => onEdit(header, success))
+ .then(next);
+ },
+ ]);
+
+ function onEdit(header, success)
+ {
+ if (success !== null && !success) {
+ InspectorTest.addResult("Failed to run edit operation.");
+ InspectorTest.completeTest();
+ return;
+ }
+ var contents = [
+ header.originalContentProvider().requestContent(),
+ header.requestContent(),
+ ];
+ return Promise.all(contents)
+ .then(onContents);
+ }
+
+ function onContents(contents)
+ {
+ InspectorTest.addResult("== Original ==");
+ InspectorTest.addResult(contents[0].trim());
+ InspectorTest.addResult("== Current ==");
+ InspectorTest.addResult(contents[1].trim());
+ }
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>Verifies that CSSStyleSheetHeader.originalContentProvider() indeed returns original content.</p>
+
+<div id="inspected"></div>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698