| 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"> |
| 9 function loadFrame(callback) |
| 10 { |
| 11 var iframe = document.createElement("iframe"); |
| 12 iframe.src = "resources/subframe.html"; |
| 13 iframe.addEventListener("load", callback); |
| 14 document.body.appendChild(iframe); |
| 15 } |
| 16 |
| 11 function logMessage() | 17 function logMessage() |
| 12 { | 18 { |
| 13 console.log("don't panic!"); | 19 frames[0].logMessage(); |
| 14 } | 20 } |
| 15 | 21 |
| 16 function initialize_ExtensionResourceTests() | 22 function initialize_ExtensionResourceTests() |
| 17 { | 23 { |
| 18 | 24 |
| 19 InspectorTest.clickOnURL = function() | 25 InspectorTest.clickOnURL = function() |
| 20 { | 26 { |
| 21 WebInspector.ConsolePanel.show(); | 27 WebInspector.ConsolePanel.show(); |
| 22 var xpathResult = document.evaluate("//a[starts-with(., 'extensions-resource
s.html')]", | 28 var xpathResult = document.evaluate("//a[starts-with(., 'test-script.js')]", |
| 23 WebInspector.panels.console.element, nul
l, XPathResult.ANY_UNORDERED_NODE_TYPE, null); | 29 WebInspector.panels.console.element, nul
l, XPathResult.ANY_UNORDERED_NODE_TYPE, null); |
| 24 var click = document.createEvent("MouseEvent"); | 30 var click = document.createEvent("MouseEvent"); |
| 25 click.initMouseEvent("click", true, true); | 31 click.initMouseEvent("click", true, true); |
| 26 xpathResult.singleNodeValue.dispatchEvent(click); | 32 xpathResult.singleNodeValue.dispatchEvent(click); |
| 27 } | 33 } |
| 28 | 34 |
| 29 InspectorTest.waitForStyleSheetChangedEvent = function(reply) | 35 InspectorTest.waitForStyleSheetChangedEvent = function(reply) |
| 30 { | 36 { |
| 31 var originalSetTimeout = WebInspector.Throttler.prototype._setTimeout; | 37 var originalSetTimeout = WebInspector.Throttler.prototype._setTimeout; |
| 32 WebInspector.Throttler.prototype._setTimeout = innerSetTimeout; | 38 WebInspector.Throttler.prototype._setTimeout = innerSetTimeout; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 44 } | 50 } |
| 45 } | 51 } |
| 46 | 52 |
| 47 } | 53 } |
| 48 | 54 |
| 49 function extension_testGetAllResources(nextTest) | 55 function extension_testGetAllResources(nextTest) |
| 50 { | 56 { |
| 51 function callback(resources) | 57 function callback(resources) |
| 52 { | 58 { |
| 53 // For some reason scripts from tests previously run in the same test sh
ell sometimes appear, so we need to filter them out. | 59 // 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"]; | 60 var resourceURLsWhiteList = ["subframe.html", "abe.png", "audits-style1.
css", "test-script.js"]; |
| 55 function filter(resource) | 61 function filter(resource) |
| 56 { | 62 { |
| 57 for (var i = 0; i < resourceURLsWhiteList.length; ++i) { | 63 for (var i = 0; i < resourceURLsWhiteList.length; ++i) { |
| 58 if (resource.url.indexOf(resourceURLsWhiteList[i]) !== -1) { | 64 if (resource.url.indexOf(resourceURLsWhiteList[i]) !== -1) { |
| 59 resourceURLsWhiteList.splice(i, 1); | 65 resourceURLsWhiteList.splice(i, 1); |
| 60 return true; | 66 return true; |
| 61 } | 67 } |
| 62 } | 68 } |
| 63 return false; | 69 return false; |
| 64 } | 70 } |
| 65 | 71 |
| 66 function compareResources(a, b) | 72 function compareResources(a, b) |
| 67 { | 73 { |
| 68 return trimURL(a.url).localeCompare(trimURL(b.url)); | 74 return trimURL(a.url).localeCompare(trimURL(b.url)); |
| 69 } | 75 } |
| 70 resources = resources.filter(filter); | 76 resources = resources.filter(filter); |
| 71 resources.sort(compareResources); | 77 resources.sort(compareResources); |
| 72 output("page resources:"); | 78 output("page resources:"); |
| 73 dumpObject(Array.prototype.slice.call(arguments), { url: "url" }); | 79 dumpObject(Array.prototype.slice.call(arguments), { url: "url" }); |
| 74 } | 80 } |
| 75 webInspector.inspectedWindow.getResources(callbackAndNextTest(callback, next
Test)); | 81 invokePageFunctionAsync("loadFrame", function() { |
| 82 webInspector.inspectedWindow.getResources(callbackAndNextTest(callback,
nextTest)); |
| 83 }); |
| 76 } | 84 } |
| 77 | 85 |
| 78 function extension_runWithResource(regexp, callback) | 86 function extension_runWithResource(regexp, callback) |
| 79 { | 87 { |
| 80 function onResources(resources) | 88 function onResources(resources) |
| 81 { | 89 { |
| 82 for (var i = 0; i < resources.length; ++i) { | 90 for (var i = 0; i < resources.length; ++i) { |
| 83 if (regexp.test(resources[i].url)) { | 91 if (regexp.test(resources[i].url)) { |
| 84 callback(resources[i]) | 92 callback(resources[i]) |
| 85 return; | 93 return; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 104 function extension_testSetResourceContent(nextTest) | 112 function extension_testSetResourceContent(nextTest) |
| 105 { | 113 { |
| 106 evaluateOnFrontend("InspectorTest.waitForStyleSheetChangedEvent(reply);", st
ep2); | 114 evaluateOnFrontend("InspectorTest.waitForStyleSheetChangedEvent(reply);", st
ep2); |
| 107 | 115 |
| 108 extension_runWithResource(/audits-style1\.css$/, function(resource) { | 116 extension_runWithResource(/audits-style1\.css$/, function(resource) { |
| 109 resource.setContent("div.test { width: 126px; height: 42px; }", false, f
unction() {}); | 117 resource.setContent("div.test { width: 126px; height: 42px; }", false, f
unction() {}); |
| 110 }); | 118 }); |
| 111 | 119 |
| 112 function step2() | 120 function step2() |
| 113 { | 121 { |
| 114 webInspector.inspectedWindow.eval("document.getElementById('test-div').c
lientWidth", function(result) { | 122 webInspector.inspectedWindow.eval("frames[0].document.getElementById('te
st-div').clientWidth", function(result) { |
| 115 output("div.test width after stylesheet edited (should be 126): " +
result); | 123 output("div.test width after stylesheet edited (should be 126): " +
result); |
| 116 nextTest(); | 124 nextTest(); |
| 117 }); | 125 }); |
| 118 } | 126 } |
| 119 } | 127 } |
| 120 | 128 |
| 121 function extension_testOnContentCommitted(nextTest) | 129 function extension_testOnContentCommitted(nextTest) |
| 122 { | 130 { |
| 123 var expected_content = "div.test { width: 220px; height: 42px; }"; | 131 var expected_content = "div.test { width: 220px; height: 42px; }"; |
| 124 | 132 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 { | 199 { |
| 192 var script = document.createElement("script"); | 200 var script = document.createElement("script"); |
| 193 script.src = "data:application/javascript," + escape("function test_func(){}
;"); | 201 script.src = "data:application/javascript," + escape("function test_func(){}
;"); |
| 194 document.head.appendChild(script); | 202 document.head.appendChild(script); |
| 195 } | 203 } |
| 196 | 204 |
| 197 </script> | 205 </script> |
| 198 </head> | 206 </head> |
| 199 <body onload="runTest()"> | 207 <body onload="runTest()"> |
| 200 <p>Tests resource-related methods of WebInspector extension API</p> | 208 <p>Tests resource-related methods of WebInspector extension API</p> |
| 201 <img src="resources/abe.png"> | |
| 202 <div id="test-div" class="test"></div> | |
| 203 </body> | 209 </body> |
| 204 </html> | 210 </html> |
| OLD | NEW |