Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / css / css-set-media-text.html
blobff4a2c14f0f73f6f8691d1ee1f763b4219276fe4
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-protocol-test.js"></script>
5 <script type="text/javascript">
6 function test()
8 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
9 InspectorTest.sendCommandOrDie("DOM.enable", {});
10 InspectorTest.sendCommandOrDie("CSS.enable", {});
12 var setMediaText;
13 var verifyProtocolError;
14 var dumpStyleSheet;
16 var firstMediaRange = {
17 startLine: 0,
18 startColumn: 7,
19 endLine: 0,
20 endColumn: 67
22 var secondMediaRange = {
23 startLine: 6,
24 startColumn: 8,
25 endLine: 8,
26 endColumn: 23
29 function styleSheetAdded(result)
31 var styleSheetId = result.params.header.styleSheetId;
32 setMediaText = InspectorTest.setMediaText.bind(InspectorTest, styleSheetId, false);
33 verifyProtocolError = InspectorTest.setMediaText.bind(InspectorTest, styleSheetId, true);
34 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
35 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
38 function onInitialStyleSheetText(result)
40 InspectorTest.log("==== Initial style sheet text ====");
41 InspectorTest.log(result.text);
42 InspectorTest.runTestSuite(testSuite);
45 var testSuite = [
46 function testSimpleEdit(next)
48 setMediaText({
49 range: firstMediaRange,
50 text: "all and (min-height: 20px)"
51 }, InspectorTest.undoAndNext(next));
54 function testComplexToSimpleEdit(next)
56 setMediaText({
57 range: secondMediaRange,
58 text: "all"
59 }, InspectorTest.undoAndNext(next));
62 function testSimpleToComplexEdit(next)
64 setMediaText({
65 range: firstMediaRange,
66 text: "all and (min-height: 20px), (max-width: 10px), handheld and (min-monochrome: 8)"
67 }, InspectorTest.undoAndNext(next));
70 function testInvalidParameters(next)
72 verifyProtocolError({
73 range: { startLine: "three", startColumn: 0, endLine: 4, endColumn: 0 },
74 text: "no matter what is here"
75 }, next);
78 function testInvalidText(next)
80 verifyProtocolError({
81 range: firstMediaRange,
82 text: "something /* is wrong here"
83 }, next);
86 function testEditSequentially(next)
88 var newText = "screen";
89 var oldLength = firstMediaRange.endColumn - firstMediaRange.startColumn;
90 var lengthDelta = newText.length - oldLength;
91 setMediaText({
92 range: firstMediaRange,
93 text: newText
94 }, step2);
96 function step2()
98 var range = {
99 startLine: firstMediaRange.startLine,
100 startColumn: firstMediaRange.startColumn,
101 endLine: firstMediaRange.endLine,
102 endColumn: firstMediaRange.endColumn + lengthDelta
104 setMediaText({
105 range: range,
106 text: "all,\nhandheld and (min-height: 20px),\n(min-width: 100px) and (max-width: 200px)"
107 }, InspectorTest.undoAndNext(InspectorTest.undoAndNext(next)));
111 function testSimpleAfterSequentially(next)
113 setMediaText({
114 range: firstMediaRange,
115 text: "all and (min-height: 20px)"
116 }, InspectorTest.undoAndNext(next));
121 </script>
122 <link rel="stylesheet" href="resources/set-media-text.css"/>
123 </head>
124 <body onload="runTest();">
125 </body>
126 </html>