| 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..c03bce912e91e2f307c4142d10ca281724445626
|
| --- /dev/null
|
| +++ b/LayoutTests/inspector-protocol/stylesheet-tracking-restart.html
|
| @@ -0,0 +1,111 @@
|
| +<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.head.appendChild(styleElement);
|
| + return styleElement;
|
| +}
|
| +
|
| +function reopenWebInspector()
|
| +{
|
| + setTimeout(deferredReopening, 0);
|
| +
|
| + function deferredReopening()
|
| + {
|
| + log("Closing inspector.\n");
|
| + closeInspector();
|
| + window.didReopen = 1;
|
| + log("Removing style sheet.\n");
|
| + document.head.removeChild(styleElement1);
|
| + log("Reopening inspector.");
|
| + openInspector();
|
| + }
|
| +}
|
| +
|
| +function openWebInspector()
|
| +{
|
| + delete window.didReopen;
|
| + styleElement1 = createStyleSheet("body.class1 { color: red; } \n /*# sourceURL=foo.css */");
|
| + styleElement2 = createStyleSheet("body.class2 { color: green; } \n /*# sourceURL=bar.css */");
|
| + 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)
|
| + {
|
| + setTimeout(callback, 1000);
|
| + InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
|
| + InspectorTest.eventHandler["CSS.styleSheetRemoved"] = styleSheetRemoved;
|
| + var headersAdded = [];
|
| + var headersRemoved = [];
|
| +
|
| + function styleSheetAdded(response)
|
| + {
|
| + headersAdded.push(response.params.header);
|
| + }
|
| +
|
| + function styleSheetRemoved(response)
|
| + {
|
| + headersRemoved.push(response.params.styleSheetId);
|
| + }
|
| +
|
| + InspectorTest.log("Enabling CSS domain.");
|
| + InspectorTest.sendCommand("CSS.enable", {}, wasEnabled);
|
| +
|
| + function wasEnabled()
|
| + {
|
| + function compareFunction(a, b)
|
| + {
|
| + return a.styleSheetId - b.styleSheetId;
|
| + }
|
| +
|
| + var headers = {};
|
| + headersAdded.sort(compareFunction);
|
| + for (var i = 0; i < headersAdded.length; ++i) {
|
| + var header = headersAdded[i];
|
| + headers[header.styleSheetId] = header.sourceURL;
|
| + InspectorTest.log(" - style sheet added: " + header.sourceURL);
|
| + }
|
| +
|
| + headersRemoved.sort();
|
| + for (var i = 0; i < headersRemoved.length; ++i)
|
| + InspectorTest.log(" - style sheet removed: " + headers[headersRemoved[i]]);
|
| +
|
| + 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>
|
|
|