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

Unified Diff: LayoutTests/inspector-protocol/stylesheet-tracking-restart.html

Issue 121263002: DevTools: Do not force style sheets update on inspector start. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test Created 7 years 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/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>

Powered by Google App Engine
This is Rietveld 408576698