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">
8 InspectorTest
.eventHandler
["CSS.styleSheetAdded"] = styleSheetAdded
;
9 InspectorTest
.sendCommandOrDie("DOM.enable", {});
10 InspectorTest
.sendCommandOrDie("CSS.enable", {});
13 var verifyProtocolError
;
16 var firstMediaRange
= {
22 var secondMediaRange
= {
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
);
46 function testSimpleEdit(next
)
49 range
: firstMediaRange
,
50 text
: "all and (min-height: 20px)"
51 }, InspectorTest
.undoAndNext(next
));
54 function testComplexToSimpleEdit(next
)
57 range
: secondMediaRange
,
59 }, InspectorTest
.undoAndNext(next
));
62 function testSimpleToComplexEdit(next
)
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
)
73 range
: { startLine
: "three", startColumn
: 0, endLine
: 4, endColumn
: 0 },
74 text
: "no matter what is here"
78 function testInvalidText(next
)
81 range
: firstMediaRange
,
82 text
: "something /* is wrong here"
86 function testEditSequentially(next
)
88 var newText
= "screen";
89 var oldLength
= firstMediaRange
.endColumn
- firstMediaRange
.startColumn
;
90 var lengthDelta
= newText
.length
- oldLength
;
92 range
: firstMediaRange
,
99 startLine
: firstMediaRange
.startLine
,
100 startColumn
: firstMediaRange
.startColumn
,
101 endLine
: firstMediaRange
.endLine
,
102 endColumn
: firstMediaRange
.endColumn
+ lengthDelta
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
)
114 range
: firstMediaRange
,
115 text
: "all and (min-height: 20px)"
116 }, InspectorTest
.undoAndNext(next
));
122 <link rel=
"stylesheet" href=
"resources/set-media-text.css"/>
124 <body onload=
"runTest();">