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

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

Issue 211193006: DevTools: [CSS] use setStyleText as undo action for setPropertyText (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: do not crash renderer in case of invalid styleId Created 6 years, 9 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-property-text-inline.html
diff --git a/LayoutTests/inspector-protocol/css/css-set-property-text-inline.html b/LayoutTests/inspector-protocol/css/css-set-property-text-inline.html
new file mode 100644
index 0000000000000000000000000000000000000000..967ca69c927c4ce7e643e71aedbe0dcabaaa3072
--- /dev/null
+++ b/LayoutTests/inspector-protocol/css/css-set-property-text-inline.html
@@ -0,0 +1,100 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+<script type="text/javascript" src="css-protocol-test.js"></script>
+<script type="text/javascript">
+function test()
+{
+ var setPropertyText;
+ var verifyProtocolError;
+ var dumpStyleSheet;
+
+ InspectorTest.sendCommandOrDie("CSS.enable", {}, onCSSEnabled);
+
+ function onCSSEnabled()
+ {
+ InspectorTest.requestNodeId("#reddiv", onNodeRecieved);
+ }
+
+ function onNodeRecieved(nodeId)
+ {
+ InspectorTest.sendCommandOrDie("CSS.getInlineStylesForNode", {
+ nodeId: nodeId,
+ }, onInlineStyleRecieved);
+ }
+
+ function onInlineStyleRecieved(result)
+ {
+ var styleSheetId = result.inlineStyle.styleId.styleSheetId;
+ setPropertyText = InspectorTest.setPropertyText.bind(InspectorTest, styleSheetId, false);
+ verifyProtocolError = InspectorTest.setPropertyText.bind(InspectorTest, styleSheetId, true);
+ dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
+ InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
+ }
+
+ function onInitialStyleSheetText(result)
+ {
+ InspectorTest.log("==== Initial style sheet text ====");
+ InspectorTest.log(result.text);
+ InspectorTest.runTestSuite(testSuite);
+ }
+
+ var testSuite = [
+ function testEditProperty(next)
+ {
+ setPropertyText({
+ styleIndex: 0,
+ propertyIndex: 0,
+ overwrite: true,
+ text: "content: 'EDITED PROPERTY';"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testBreakingCommentEditProperty(next)
+ {
+ verifyProtocolError({
+ styleIndex: 0,
+ propertyIndex: 0,
+ overwrite: true,
+ text: "/*<--OPENED COMMENT"
+ }, next);
+ },
+
+ function testInsertFirstProperty(next)
+ {
+ setPropertyText({
+ styleIndex: 0,
+ propertyIndex: 0,
+ overwrite: false,
+ text: "content: 'INSERTED PROPERTY';"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testInsertMultipleProperties(next)
+ {
+ setPropertyText({
+ styleIndex: 0,
+ propertyIndex: 0,
+ overwrite: true,
+ text: "content: 'INSERTED #1';content: 'INSERTED #2';"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testInsertLastProperty(next)
+ {
+ setPropertyText({
+ styleIndex: 0,
+ propertyIndex: 2,
+ overwrite: false,
+ text: "content: 'INSERTED PROPERTY';"
+ }, InspectorTest.undoAndNext(next));
+ },
+ ];
+}
+
+</script>
+</head>
+<body onload="runTest();">
+ <div id="reddiv" style="color: red; border: 0px;">Some red text goes here</div>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698