Chromium Code Reviews| Index: LayoutTests/inspector-protocol/stylesheet-tracking-restart.html |
| diff --git a/LayoutTests/inspector-protocol/stylesheet-tracking-restart.html b/LayoutTests/inspector-protocol/stylesheet-tracking-restart.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a10b28325f12d99081f663ed0f250ae10f7d0efd |
| --- /dev/null |
| +++ b/LayoutTests/inspector-protocol/stylesheet-tracking-restart.html |
| @@ -0,0 +1,91 @@ |
| +<html> |
| +<head> |
| +<script type="text/javascript" src="../http/tests/inspector-protocol/resources/protocol-test.js"></script> |
| +<script> |
| +var styleElement1; |
| +var styleElement2; |
| + |
| +function createStyleSheet(textContent) |
| +{ |
| + var styleElement = document.createElement("style"); |
| + styleElement.textContent = textContent; |
| + document.body.appendChild(styleElement); |
|
lushnikov
2013/12/27 08:20:17
let's add/remove stylesheets to document.head inst
|
| + return styleElement; |
| +} |
| + |
| +function reopenWebInspector() |
| +{ |
| + setTimeout(deferredReopening, 0); |
| + |
| + function deferredReopening() |
| + { |
| + log("Closing inspector.\n"); |
| + closeInspector(); |
| + window.didReopen = 1; |
| + log("Removing style sheet.\n"); |
| + document.body.removeChild(styleElement1); |
| + log("Reopening inspector."); |
| + openInspector(); |
| + } |
| +} |
| + |
| +function openWebInspector() |
| +{ |
| + delete window.didReopen; |
| + styleElement1 = createStyleSheet("body.class1 { color: red; } \n /*# sourceURL=foo.js */"); |
|
apavlov
2013/12/27 07:12:30
.css ?
|
| + styleElement2 = createStyleSheet("body.class2 { color: green; } \n /*# sourceURL=bar.js */"); |
|
apavlov
2013/12/27 07:12:30
ditto
|
| + runTest(); |
| +} |
| + |
| +function test() |
| +{ |
| + InspectorTest.log("Running test"); |
| + InspectorTest.sendCommand("Runtime.evaluate", {"expression": "window.didReopen"}, dispatch); |
| + |
| + function dispatch(response) |
| + { |
| + var result = response.result.result; |
| + if (result.type !== "number") { |
| + InspectorTest.log("Opening front-end for the first time"); |
| + runTests(reopenInspector); |
| + } else { |
| + InspectorTest.log("Opening front-end second time"); |
| + runTests(InspectorTest.completeTest.bind(InspectorTest)); |
| + } |
| + } |
| + |
| + function reopenInspector() |
| + { |
| + InspectorTest.sendCommand("Runtime.evaluate", {"expression": "reopenWebInspector()"}); |
| + } |
| + |
| + function runTests(callback) |
| + { |
| + InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
| + InspectorTest.eventHandler["CSS.styleSheetRemoved"] = styleSheetRemoved; |
| + |
| + function styleSheetAdded(response) |
| + { |
| + var header = response.params.header; |
| + InspectorTest.log(" - style sheet added: " + header.styleSheetId + " (sourceURL=" + header.sourceURL + ")"); |
| + } |
| + function styleSheetRemoved(response) |
| + { |
| + InspectorTest.log(" - style sheet removed: " + response.params.styleSheetId); |
| + } |
| + |
| + InspectorTest.log("Enabling CSS domain."); |
| + InspectorTest.sendCommand("CSS.enable", {}, wasEnabled); |
| + |
| + function wasEnabled() |
| + { |
| + callback(); |
| + } |
| + } |
| +} |
| +</script> |
| +</head> |
| +<body onload="openWebInspector()"> |
| +<p>This test checks that if style sheet is removed between two inspector launches it is not reported to frontend.</p> |
| +</body> |
| +</html> |