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

Unified Diff: LayoutTests/inspector/styles/stylesheet-tracking.html

Issue 14916006: Merge 149874 "DevTools: Do not unbind stylesheets in multiframe ..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1500/
Patch Set: Created 7 years, 7 months 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/styles/stylesheet-tracking.html
===================================================================
--- LayoutTests/inspector/styles/stylesheet-tracking.html (revision 150193)
+++ LayoutTests/inspector/styles/stylesheet-tracking.html (working copy)
@@ -1,179 +0,0 @@
-<html>
-<head>
-<script src="../../http/tests/inspector/inspector-test.js"></script>
-<script src="../../http/tests/inspector/elements-test.js"></script>
-<script src="../../http/tests/inspector/debugger-test.js"></script>
-<link rel="stylesheet" href="resources/stylesheet-tracking.css" />
-
-<style>
-html {
- font-size: 12px;
-}
-</style>
-
-<script>
-
-function addStyleSheet()
-{
- var styleElement = document.createElement("style");
- styleElement.id = "style";
- styleElement.type = "text/css";
- styleElement.textContent = "@import url(\"resources/styles-new-API.css\");\na { color: green; }"
- document.head.appendChild(styleElement);
-}
-
-function removeImport()
-{
- document.getElementById("style").sheet.deleteRule(0);
-}
-
-function removeStyleSheet()
-{
- document.head.removeChild(document.getElementById("style"));
-}
-
-function test()
-{
- var inspectorResource;
-
- WebInspector.showPanel("elements");
- WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAdded, styleSheetAdded, null);
- WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRemoved, styleSheetRemoved, null);
- var headers = WebInspector.cssModel.styleSheetHeaders();
- InspectorTest.addResult(headers.length + " headers known:");
- sortAndDumpData(headers);
-
- InspectorTest.selectNodeAndWaitForStyles("inspected", step1);
-
- var inspectedNode;
- function step1(node)
- {
- inspectedNode = node;
- InspectorTest.addResult("=== Adding stylesheet... ===");
- waitStyleSheetAdded(4, step2);
- InspectorTest.evaluateInPage("addStyleSheet()");
- }
-
- function step2()
- {
- InspectorTest.addResult("=== Removing @import... ===");
- waitStyleSheetRemoved(3, step3);
- InspectorTest.evaluateInPage("removeImport()");
- }
-
- function step3()
- {
- InspectorTest.addResult("=== Removing stylesheet... ===");
- waitStyleSheetRemoved(1, step4);
- InspectorTest.evaluateInPage("removeStyleSheet()");
- }
-
- function step4()
- {
- InspectorTest.addResult("=== Adding rule... ===");
- WebInspector.cssModel.addRule(inspectedNode.id, "#inspected", successCallback, failureCallback);
-
- function successCallback()
- {
- InspectorTest.addResult("Rule added");
- InspectorTest.completeTest();
- }
- function failureCallback()
- {
- InspectorTest.addResult("Failed to add rule.");
- InspectorTest.completeTest();
- }
- }
-
- var addedCallback;
- var addedSheetCount;
- var addedSheets = [];
-
- function waitStyleSheetAdded(count, next)
- {
- addedSheetCount = count;
- addedCallback = next;
- }
-
- function styleSheetAdded(event)
- {
- var header = event.data;
- addedSheets.push(header);
- --addedSheetCount;
- if (addedSheetCount > 0)
- return;
- InspectorTest.addResult("Stylesheets added:");
- sortAndDumpData(addedSheets);
- addedSheets = [];
- if (addedCallback) {
- var callback = addedCallback;
- addedCallback = null;
- callback();
- }
- }
-
- var removedCallback;
- var removedSheetCount;
- var removedSheets = [];
-
- function waitStyleSheetRemoved(count, next)
- {
- removedSheetCount = count;
- removedCallback = next;
- }
-
- function styleSheetRemoved(event)
- {
- var header = event.data;
- removedSheets.push(header);
- --removedSheetCount;
- if (removedSheetCount > 0)
- return;
- InspectorTest.addResult("Stylesheets removed:");
- sortAndDumpData(removedSheets);
- removedSheets = [];
- if (removedCallback) {
- var callback = removedCallback;
- removedCallback = null;
- callback();
- }
- }
-
- function sortAndDumpData(sheets)
- {
- function sorter(a, b)
- {
- return a.sourceURL.localeCompare(b.sourceURL);
- }
- sheets = sheets.sort(sorter);
- for (var i = 0; i < sheets.length; ++i)
- InspectorTest.addResult(headerData(sheets[i]));
- }
-
- function headerData(header)
- {
- return " URL=" + trimURL(header.sourceURL) + "\n origin=" + header.origin;
- }
-
- function trimURL(url)
- {
- if (!url)
- return url;
- var lastIndex = url.lastIndexOf("inspector/");
- if (lastIndex < 0)
- return url;
- return ".../" + url.substr(lastIndex);
- }
-}
-</script>
-</head>
-
-<body onload="runTest()">
-<p>
-Tests that the styleSheetAdded and styleSheetRemoved events are reported into the frontend. <a href="https://bugs.webkit.org/show_bug.cgi?id=105828">Bug 105828</a>.
-</p>
-
-<div id="inspected">Text</div>
-
-</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698