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

Unified Diff: LayoutTests/inspector/extensions/extensions-resources.html

Issue 1176133003: DevTools: deflake extensions-resources.html (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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/extensions/extensions-resources.html
diff --git a/LayoutTests/inspector/extensions/extensions-resources.html b/LayoutTests/inspector/extensions/extensions-resources.html
index 96dc46f718173bde7f6d1a99da92fbc3b02420f2..f5ffdf557e613ca9c616363f5fd41a8acbf7ca16 100644
--- a/LayoutTests/inspector/extensions/extensions-resources.html
+++ b/LayoutTests/inspector/extensions/extensions-resources.html
@@ -4,13 +4,32 @@
<script src="../../http/tests/inspector/console-test.js"></script>
<script src="../../http/tests/inspector/extensions-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
-<link rel="stylesheet" href="resources/audits-style1.css" type="text/css">
-<script type="text/javascript" src="resources/test-script.js"></script>
<script type="text/javascript">
-function logMessage()
+function loadResources(callback)
{
- console.log("don't panic!");
+ var pendingResourcesCount = 0;
+
+ function loadResource(element, hrefAttribute, hrefValue)
+ {
+ ++pendingResourcesCount;
+ element.addEventListener("load", onLoad);
+ element.setAttribute(hrefAttribute, hrefValue);
+ document.body.appendChild(element);
+ }
+
+ function onLoad()
+ {
+ if (!--pendingResourcesCount)
+ callback();
+ }
+
+ var link = document.createElement("link");
+ link.rel = "stylesheet";
+ link.type = "text/css";
+ loadResource(link, "href", "resources/audits-style1.css");
+ loadResource(document.createElement("img"), "src", "resources/abe.png");
+ loadResource(document.createElement("script"), "src", "resources/test-script.js");
}
function initialize_ExtensionResourceTests()
@@ -19,7 +38,7 @@ function initialize_ExtensionResourceTests()
InspectorTest.clickOnURL = function()
{
WebInspector.ConsolePanel.show();
- var xpathResult = document.evaluate("//a[starts-with(., 'extensions-resources.html')]",
+ var xpathResult = document.evaluate("//a[starts-with(., 'test-script.js')]",
WebInspector.panels.console.element, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null);
var click = document.createEvent("MouseEvent");
click.initMouseEvent("click", true, true);
@@ -51,7 +70,7 @@ function extension_testGetAllResources(nextTest)
function callback(resources)
{
// For some reason scripts from tests previously run in the same test shell sometimes appear, so we need to filter them out.
- var resourceURLsWhiteList = ["abe.png", "audits-style1.css", "extensions-resources.html", "extensions-test.js", "inspector-test.js", "test-script.js"];
+ var resourceURLsWhiteList = ["abe.png", "audits-style1.css", "test-script.js"];
dgozman 2015/06/11 15:50:52 Can we add iframe with html resource inside?
function filter(resource)
{
for (var i = 0; i < resourceURLsWhiteList.length; ++i) {
@@ -72,7 +91,9 @@ function extension_testGetAllResources(nextTest)
output("page resources:");
dumpObject(Array.prototype.slice.call(arguments), { url: "url" });
}
- webInspector.inspectedWindow.getResources(callbackAndNextTest(callback, nextTest));
+ invokePageFunctionAsync("loadResources", function() {
+ webInspector.inspectedWindow.getResources(callbackAndNextTest(callback, nextTest));
+ });
}
function extension_runWithResource(regexp, callback)
@@ -198,7 +219,6 @@ function addResource()
</head>
<body onload="runTest()">
<p>Tests resource-related methods of WebInspector extension API</p>
-<img src="resources/abe.png">
<div id="test-div" class="test"></div>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698