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

Unified Diff: LayoutTests/inspector-protocol/css/css-set-style-text.html

Issue 1181213007: DevTools: introduce CSS.setStyleText, we'll migrate setPropertyText to it later. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: win fixed Created 5 years, 6 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: LayoutTests/inspector-protocol/css/css-set-style-text.html
diff --git a/LayoutTests/inspector-protocol/css/css-set-style-text.html b/LayoutTests/inspector-protocol/css/css-set-style-text.html
new file mode 100644
index 0000000000000000000000000000000000000000..eecd5592f63d5d77ed5414f8e93a90fa305d8286
--- /dev/null
+++ b/LayoutTests/inspector-protocol/css/css-set-style-text.html
@@ -0,0 +1,109 @@
+<html>
+<head>
+<link rel="stylesheet" href="resources/set-style-text.css"/>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/css-protocol-test.js"></script>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/dom-protocol-test.js"></script>
+<script type="text/javascript">
+function test()
+{
+ var setStyleText;
+ var verifyProtocolError;
+ var dumpStyleSheet;
+ var documentNodeId;
+ var styleSheetId;
+
+ InspectorTest.requestDocumentNodeId(onDocumentNodeId);
+
+ function onDocumentNodeId(nodeId)
+ {
+ documentNodeId = nodeId;
+ InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
+ InspectorTest.sendCommandOrDie("CSS.enable", {});
+ }
+
+ function styleSheetAdded(result)
+ {
+ styleSheetId = result.params.header.styleSheetId;
+ setStyleText = InspectorTest.setStyleText.bind(InspectorTest, styleSheetId, false);
+ verifyProtocolError = InspectorTest.setStyleText.bind(InspectorTest, styleSheetId, true);
+ dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
+ InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
+ }
+
+ function dumpAndNext(next)
+ {
+ return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, documentNodeId, "#test", InspectorTest.undoAndNext(next));
+ }
+
+ function onInitialStyleSheetText(result)
+ {
+ InspectorTest.log("==== Initial style sheet text ====");
+ InspectorTest.log(result.text);
+ InspectorTest.runTestSuite(testSuite);
+ }
+
+ var testSuite = [
+ function testBasicSetStyle(next)
+ {
+ setStyleText({
+ styleSheetId: styleSheetId,
+ range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
+ text: "\n content: 'EDITED';\n",
+ }, dumpAndNext(next));
+ },
+
+ function testSetStylePoorContent(next)
+ {
+ verifyProtocolError({
+ styleSheetId: styleSheetId,
+ range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
+ text: "}",
+ }, dumpAndNext(next));
+ },
+
+ function testSetStyleInMedia(next)
+ {
+ setStyleText({
+ styleSheetId: styleSheetId,
+ range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
+ text: "\n content: 'EDITED';\n color: red;\n /** foo */\n ",
+ }, dumpAndNext(next));
+ },
+
+ function testDeleteStyleBody(next)
+ {
+ setStyleText({
+ styleSheetId: styleSheetId,
+ range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
+ text: "",
+ }, dumpAndNext(next));
+ },
+
+ function testSetStylePoorRange(next)
+ {
+ verifyProtocolError({
+ styleSheetId: styleSheetId,
+ range: { startLine: 11, startColumn: 11, endLine: 15, endColumn: 4 },
+ text: "\n content: 'EDITED';\n",
+ }, dumpAndNext(next));
+ },
+
+ function testSetStyleOpenComment(next)
+ {
+ verifyProtocolError({
+ styleSheetId: styleSheetId,
+ range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
+ text: "\n content: 'EDITED'/* ;\n",
+ }, dumpAndNext(next));
+ }
+ ];
+}
+
+</script>
+</head>
+<body onload="runTest();">
+<p>The test verifies functionality of protocol method CSS.setStyleText.</p>
+<article id="test"></article>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698