Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../http/tests/inspector/console-test.js"></script> | 4 <script src="../../http/tests/inspector/console-test.js"></script> |
| 5 <script src="../../http/tests/inspector/extensions-test.js"></script> | 5 <script src="../../http/tests/inspector/extensions-test.js"></script> |
| 6 <script src="../../http/tests/inspector/debugger-test.js"></script> | 6 <script src="../../http/tests/inspector/debugger-test.js"></script> |
| 7 <link rel="stylesheet" href="resources/audits-style1.css" type="text/css"> | |
| 8 <script type="text/javascript" src="resources/test-script.js"></script> | |
| 9 | 7 |
| 10 <script type="text/javascript"> | 8 <script type="text/javascript"> |
| 11 function logMessage() | 9 function loadResources(callback) |
| 12 { | 10 { |
| 13 console.log("don't panic!"); | 11 var pendingResourcesCount = 0; |
| 12 | |
| 13 function loadResource(element, hrefAttribute, hrefValue) | |
| 14 { | |
| 15 ++pendingResourcesCount; | |
| 16 element.addEventListener("load", onLoad); | |
| 17 element.setAttribute(hrefAttribute, hrefValue); | |
| 18 document.body.appendChild(element); | |
| 19 } | |
| 20 | |
| 21 function onLoad() | |
| 22 { | |
| 23 if (!--pendingResourcesCount) | |
| 24 callback(); | |
| 25 } | |
| 26 | |
| 27 var link = document.createElement("link"); | |
| 28 link.rel = "stylesheet"; | |
| 29 link.type = "text/css"; | |
| 30 loadResource(link, "href", "resources/audits-style1.css"); | |
| 31 loadResource(document.createElement("img"), "src", "resources/abe.png"); | |
| 32 loadResource(document.createElement("script"), "src", "resources/test-script .js"); | |
| 14 } | 33 } |
| 15 | 34 |
| 16 function initialize_ExtensionResourceTests() | 35 function initialize_ExtensionResourceTests() |
| 17 { | 36 { |
| 18 | 37 |
| 19 InspectorTest.clickOnURL = function() | 38 InspectorTest.clickOnURL = function() |
| 20 { | 39 { |
| 21 WebInspector.ConsolePanel.show(); | 40 WebInspector.ConsolePanel.show(); |
| 22 var xpathResult = document.evaluate("//a[starts-with(., 'extensions-resource s.html')]", | 41 var xpathResult = document.evaluate("//a[starts-with(., 'test-script.js')]", |
| 23 WebInspector.panels.console.element, nul l, XPathResult.ANY_UNORDERED_NODE_TYPE, null); | 42 WebInspector.panels.console.element, nul l, XPathResult.ANY_UNORDERED_NODE_TYPE, null); |
| 24 var click = document.createEvent("MouseEvent"); | 43 var click = document.createEvent("MouseEvent"); |
| 25 click.initMouseEvent("click", true, true); | 44 click.initMouseEvent("click", true, true); |
| 26 xpathResult.singleNodeValue.dispatchEvent(click); | 45 xpathResult.singleNodeValue.dispatchEvent(click); |
| 27 } | 46 } |
| 28 | 47 |
| 29 InspectorTest.waitForStyleSheetChangedEvent = function(reply) | 48 InspectorTest.waitForStyleSheetChangedEvent = function(reply) |
| 30 { | 49 { |
| 31 var originalSetTimeout = WebInspector.Throttler.prototype._setTimeout; | 50 var originalSetTimeout = WebInspector.Throttler.prototype._setTimeout; |
| 32 WebInspector.Throttler.prototype._setTimeout = innerSetTimeout; | 51 WebInspector.Throttler.prototype._setTimeout = innerSetTimeout; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 44 } | 63 } |
| 45 } | 64 } |
| 46 | 65 |
| 47 } | 66 } |
| 48 | 67 |
| 49 function extension_testGetAllResources(nextTest) | 68 function extension_testGetAllResources(nextTest) |
| 50 { | 69 { |
| 51 function callback(resources) | 70 function callback(resources) |
| 52 { | 71 { |
| 53 // For some reason scripts from tests previously run in the same test sh ell sometimes appear, so we need to filter them out. | 72 // For some reason scripts from tests previously run in the same test sh ell sometimes appear, so we need to filter them out. |
| 54 var resourceURLsWhiteList = ["abe.png", "audits-style1.css", "extensions -resources.html", "extensions-test.js", "inspector-test.js", "test-script.js"]; | 73 var resourceURLsWhiteList = ["abe.png", "audits-style1.css", "test-scrip t.js"]; |
|
dgozman
2015/06/11 15:50:52
Can we add iframe with html resource inside?
| |
| 55 function filter(resource) | 74 function filter(resource) |
| 56 { | 75 { |
| 57 for (var i = 0; i < resourceURLsWhiteList.length; ++i) { | 76 for (var i = 0; i < resourceURLsWhiteList.length; ++i) { |
| 58 if (resource.url.indexOf(resourceURLsWhiteList[i]) !== -1) { | 77 if (resource.url.indexOf(resourceURLsWhiteList[i]) !== -1) { |
| 59 resourceURLsWhiteList.splice(i, 1); | 78 resourceURLsWhiteList.splice(i, 1); |
| 60 return true; | 79 return true; |
| 61 } | 80 } |
| 62 } | 81 } |
| 63 return false; | 82 return false; |
| 64 } | 83 } |
| 65 | 84 |
| 66 function compareResources(a, b) | 85 function compareResources(a, b) |
| 67 { | 86 { |
| 68 return trimURL(a.url).localeCompare(trimURL(b.url)); | 87 return trimURL(a.url).localeCompare(trimURL(b.url)); |
| 69 } | 88 } |
| 70 resources = resources.filter(filter); | 89 resources = resources.filter(filter); |
| 71 resources.sort(compareResources); | 90 resources.sort(compareResources); |
| 72 output("page resources:"); | 91 output("page resources:"); |
| 73 dumpObject(Array.prototype.slice.call(arguments), { url: "url" }); | 92 dumpObject(Array.prototype.slice.call(arguments), { url: "url" }); |
| 74 } | 93 } |
| 75 webInspector.inspectedWindow.getResources(callbackAndNextTest(callback, next Test)); | 94 invokePageFunctionAsync("loadResources", function() { |
| 95 webInspector.inspectedWindow.getResources(callbackAndNextTest(callback, nextTest)); | |
| 96 }); | |
| 76 } | 97 } |
| 77 | 98 |
| 78 function extension_runWithResource(regexp, callback) | 99 function extension_runWithResource(regexp, callback) |
| 79 { | 100 { |
| 80 function onResources(resources) | 101 function onResources(resources) |
| 81 { | 102 { |
| 82 for (var i = 0; i < resources.length; ++i) { | 103 for (var i = 0; i < resources.length; ++i) { |
| 83 if (regexp.test(resources[i].url)) { | 104 if (regexp.test(resources[i].url)) { |
| 84 callback(resources[i]) | 105 callback(resources[i]) |
| 85 return; | 106 return; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 { | 212 { |
| 192 var script = document.createElement("script"); | 213 var script = document.createElement("script"); |
| 193 script.src = "data:application/javascript," + escape("function test_func(){} ;"); | 214 script.src = "data:application/javascript," + escape("function test_func(){} ;"); |
| 194 document.head.appendChild(script); | 215 document.head.appendChild(script); |
| 195 } | 216 } |
| 196 | 217 |
| 197 </script> | 218 </script> |
| 198 </head> | 219 </head> |
| 199 <body onload="runTest()"> | 220 <body onload="runTest()"> |
| 200 <p>Tests resource-related methods of WebInspector extension API</p> | 221 <p>Tests resource-related methods of WebInspector extension API</p> |
| 201 <img src="resources/abe.png"> | |
| 202 <div id="test-div" class="test"></div> | 222 <div id="test-div" class="test"></div> |
| 203 </body> | 223 </body> |
| 204 </html> | 224 </html> |
| OLD | NEW |