| 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/network-test.js"></script> | 5 <script src="../../http/tests/inspector/network-test.js"></script> |
| 6 <script src="../../http/tests/inspector/sources-test.js"></script> | 6 <script src="../../http/tests/inspector/sources-test.js"></script> |
| 7 <script src="../../http/tests/inspector/resources-test.js"></script> | 7 <script src="../../http/tests/inspector/resources-test.js"></script> |
| 8 <script src="../../http/tests/inspector/extensions-test.js"></script> | 8 <script src="../../http/tests/inspector/extensions-test.js"></script> |
| 9 <script type="text/javascript"> | 9 <script type="text/javascript"> |
| 10 function logMessage() | 10 function logMessage() |
| 11 { | 11 { |
| 12 console.log("hello"); | 12 console.log("hello"); |
| 13 } | 13 } |
| 14 | 14 |
| 15 function initialize_extensionsPanelTest() | 15 function initialize_extensionsPanelTest() |
| 16 { | 16 { |
| 17 InspectorTest.getPanelSize = function() | 17 InspectorTest.getPanelSize = function() |
| 18 { | 18 { |
| 19 var boundingRect = WebInspector.inspectorView._tabbedPane._contentElemen
t.getBoundingClientRect(); | 19 var boundingRect = UI.inspectorView._tabbedPane._contentElement.getBound
ingClientRect(); |
| 20 return { | 20 return { |
| 21 width: boundingRect.width, | 21 width: boundingRect.width, |
| 22 height: boundingRect.height | 22 height: boundingRect.height |
| 23 }; | 23 }; |
| 24 } | 24 } |
| 25 | 25 |
| 26 InspectorTest.dumpStatusBarButtons = function() | 26 InspectorTest.dumpStatusBarButtons = function() |
| 27 { | 27 { |
| 28 var panel = WebInspector.inspectorView.currentPanelDeprecated(); | 28 var panel = UI.inspectorView.currentPanelDeprecated(); |
| 29 var items = panel._panelToolbar._contentElement.children; | 29 var items = panel._panelToolbar._contentElement.children; |
| 30 InspectorTest.addResult("Status bar buttons state:"); | 30 InspectorTest.addResult("Status bar buttons state:"); |
| 31 for (var i = 0; i < items.length; ++i) { | 31 for (var i = 0; i < items.length; ++i) { |
| 32 var item = items[i]; | 32 var item = items[i]; |
| 33 if (item instanceof HTMLContentElement) | 33 if (item instanceof HTMLContentElement) |
| 34 continue; | 34 continue; |
| 35 if (!(item instanceof HTMLButtonElement)) { | 35 if (!(item instanceof HTMLButtonElement)) { |
| 36 InspectorTest.addResult("status bar item " + i + " is not a butt
on: " + item); | 36 InspectorTest.addResult("status bar item " + i + " is not a butt
on: " + item); |
| 37 continue; | 37 continue; |
| 38 } | 38 } |
| 39 // Strip url(...) and prefix of the URL within, leave just last 3 co
mponents. | 39 // Strip url(...) and prefix of the URL within, leave just last 3 co
mponents. |
| 40 var url = item.style.backgroundImage.replace(/^url\(.*(([/][^/]*){3}
[^/)]*)\)$/, "...$1"); | 40 var url = item.style.backgroundImage.replace(/^url\(.*(([/][^/]*){3}
[^/)]*)\)$/, "...$1"); |
| 41 InspectorTest.addResult("status bar item " + i + ", icon: \"" + url
+ ", tooltip: '" + item[WebInspector.Tooltip._symbol].content + "', disabled: "
+ item.disabled); | 41 InspectorTest.addResult("status bar item " + i + ", icon: \"" + url
+ ", tooltip: '" + item[UI.Tooltip._symbol].content + "', disabled: " + item.dis
abled); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 InspectorTest.clickButton = function(index) | 45 InspectorTest.clickButton = function(index) |
| 46 { | 46 { |
| 47 var panel = WebInspector.inspectorView.currentPanelDeprecated(); | 47 var panel = UI.inspectorView.currentPanelDeprecated(); |
| 48 var items = panel._panelToolbar._contentElement.children; | 48 var items = panel._panelToolbar._contentElement.children; |
| 49 for (var i = 0, buttonIndex = 0; i < items.length; ++i) { | 49 for (var i = 0, buttonIndex = 0; i < items.length; ++i) { |
| 50 if (items[i] instanceof HTMLButtonElement) { | 50 if (items[i] instanceof HTMLButtonElement) { |
| 51 if (buttonIndex === index) { | 51 if (buttonIndex === index) { |
| 52 items[i].click(); | 52 items[i].click(); |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 buttonIndex++; | 55 buttonIndex++; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 InspectorTest.addResult("No button with index " + index); | 58 InspectorTest.addResult("No button with index " + index); |
| 59 items[index].click(); | 59 items[index].click(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 InspectorTest.logMessageAndClickOnURL = function() | 62 InspectorTest.logMessageAndClickOnURL = function() |
| 63 { | 63 { |
| 64 InspectorTest.disableConsoleViewport(); | 64 InspectorTest.disableConsoleViewport(); |
| 65 InspectorTest.evaluateInPage("logMessage()"); | 65 InspectorTest.evaluateInPage("logMessage()"); |
| 66 var wrappedConsoleMessageAdded = InspectorTest.safeWrap(consoleMessageAd
ded); | 66 var wrappedConsoleMessageAdded = InspectorTest.safeWrap(consoleMessageAd
ded); |
| 67 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.MessageAdded, wrappedConsoleMessageAdded); | 67 SDK.multitargetConsoleModel.addEventListener(SDK.ConsoleModel.Events.Mes
sageAdded, wrappedConsoleMessageAdded); |
| 68 | 68 |
| 69 function consoleMessageAdded() | 69 function consoleMessageAdded() |
| 70 { | 70 { |
| 71 WebInspector.multitargetConsoleModel.removeEventListener(WebInspecto
r.ConsoleModel.Events.MessageAdded, wrappedConsoleMessageAdded); | 71 SDK.multitargetConsoleModel.removeEventListener(SDK.ConsoleModel.Eve
nts.MessageAdded, wrappedConsoleMessageAdded); |
| 72 WebInspector.ConsoleView.instance()._viewportThrottler.flush(); | 72 Console.ConsoleView.instance()._viewportThrottler.flush(); |
| 73 InspectorTest.deprecatedRunAfterPendingDispatches(clickOnMessage) | 73 InspectorTest.deprecatedRunAfterPendingDispatches(clickOnMessage) |
| 74 } | 74 } |
| 75 | 75 |
| 76 function clickOnMessage() | 76 function clickOnMessage() |
| 77 { | 77 { |
| 78 var xpathResult = document.evaluate("//a[starts-with(., 'extensions-
panel.html')]", WebInspector.ConsoleView.instance()._viewport.element, null, XPa
thResult.ANY_UNORDERED_NODE_TYPE, null); | 78 var xpathResult = document.evaluate("//a[starts-with(., 'extensions-
panel.html')]", Console.ConsoleView.instance()._viewport.element, null, XPathRes
ult.ANY_UNORDERED_NODE_TYPE, null); |
| 79 | 79 |
| 80 var click = document.createEvent("MouseEvent"); | 80 var click = document.createEvent("MouseEvent"); |
| 81 click.initMouseEvent("click", true, true); | 81 click.initMouseEvent("click", true, true); |
| 82 xpathResult.singleNodeValue.dispatchEvent(click); | 82 xpathResult.singleNodeValue.dispatchEvent(click); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 InspectorTest.installShowResourceLocationHooks = function() | 86 InspectorTest.installShowResourceLocationHooks = function() |
| 87 { | 87 { |
| 88 function showURL(panelName, url, lineNumber) | 88 function showURL(panelName, url, lineNumber) |
| 89 { | 89 { |
| 90 var url = url.replace(/^.*(([/][^/]*){3}[^/)]*)$/, "...$1"); | 90 var url = url.replace(/^.*(([/][^/]*){3}[^/)]*)$/, "...$1"); |
| 91 InspectorTest.addResult("Showing resource " + url + " in panel " + p
anelName + "), line: " + lineNumber); | 91 InspectorTest.addResult("Showing resource " + url + " in panel " + p
anelName + "), line: " + lineNumber); |
| 92 } | 92 } |
| 93 InspectorTest.recordNetwork(); | 93 InspectorTest.recordNetwork(); |
| 94 InspectorTest.addSniffer(WebInspector.panels.sources, "showUILocation",
showUILocationHook, true); | 94 InspectorTest.addSniffer(UI.panels.sources, "showUILocation", showUILoca
tionHook, true); |
| 95 InspectorTest.addSniffer(WebInspector.panels.resources, "showResource",
showResourceHook, true); | 95 InspectorTest.addSniffer(UI.panels.resources, "showResource", showResour
ceHook, true); |
| 96 InspectorTest.addSniffer(WebInspector.panels.network, "revealAndHighligh
tRequest", showRequestHook, true); | 96 InspectorTest.addSniffer(UI.panels.network, "revealAndHighlightRequest",
showRequestHook, true); |
| 97 | 97 |
| 98 function showUILocationHook(uiLocation) | 98 function showUILocationHook(uiLocation) |
| 99 { | 99 { |
| 100 showURL("sources", uiLocation.uiSourceCode.url(), uiLocation.lineNum
ber); | 100 showURL("sources", uiLocation.uiSourceCode.url(), uiLocation.lineNum
ber); |
| 101 } | 101 } |
| 102 | 102 |
| 103 function showResourceHook(resource, lineNumber) | 103 function showResourceHook(resource, lineNumber) |
| 104 { | 104 { |
| 105 showURL("resources", resource.url, lineNumber); | 105 showURL("resources", resource.url, lineNumber); |
| 106 } | 106 } |
| 107 | 107 |
| 108 function showRequestHook(request) | 108 function showRequestHook(request) |
| 109 { | 109 { |
| 110 showURL("network", request.url); | 110 showURL("network", request.url); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 InspectorTest.switchToLastPanel = function() | 114 InspectorTest.switchToLastPanel = function() |
| 115 { | 115 { |
| 116 var lastPanelName = WebInspector.inspectorView._tabbedPane._tabs.peekLas
t().id; | 116 var lastPanelName = UI.inspectorView._tabbedPane._tabs.peekLast().id; |
| 117 return WebInspector.inspectorView.showPanel(lastPanelName); | 117 return UI.inspectorView.showPanel(lastPanelName); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 function extension_testThemeName(nextTest) | 121 function extension_testThemeName(nextTest) |
| 122 { | 122 { |
| 123 output("Theme name: " + webInspector.panels.themeName); | 123 output("Theme name: " + webInspector.panels.themeName); |
| 124 nextTest(); | 124 nextTest(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 function extension_testCreatePanel(nextTest) | 127 function extension_testCreatePanel(nextTest) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // This is not authorized and therefore should not produce any output | 185 // This is not authorized and therefore should not produce any output |
| 186 panel.show(); | 186 panel.show(); |
| 187 extension_showPanel("console"); | 187 extension_showPanel("console"); |
| 188 | 188 |
| 189 function handleOpenResource(resource, lineNumber) | 189 function handleOpenResource(resource, lineNumber) |
| 190 { | 190 { |
| 191 // This will force extension iframe to be really loaded. | 191 // This will force extension iframe to be really loaded. |
| 192 panel.show(); | 192 panel.show(); |
| 193 } | 193 } |
| 194 webInspector.panels.setOpenResourceHandler(handleOpenResource); | 194 webInspector.panels.setOpenResourceHandler(handleOpenResource); |
| 195 evaluateOnFrontend("WebInspector.openAnchorLocationRegistry._activeHandl
er = 'test extension'"); | 195 evaluateOnFrontend("Components.openAnchorLocationRegistry._activeHandler
= 'test extension'"); |
| 196 evaluateOnFrontend("InspectorTest.logMessageAndClickOnURL();"); | 196 evaluateOnFrontend("InspectorTest.logMessageAndClickOnURL();"); |
| 197 expectOnShown = true; | 197 expectOnShown = true; |
| 198 } | 198 } |
| 199 var basePath = location.pathname.replace(/\/[^/]*$/, "/"); | 199 var basePath = location.pathname.replace(/\/[^/]*$/, "/"); |
| 200 webInspector.panels.create("Test Panel", basePath + "extension-panel.png", b
asePath + "extension-panel.html", onPanelCreated); | 200 webInspector.panels.create("Test Panel", basePath + "extension-panel.png", b
asePath + "extension-panel.html", onPanelCreated); |
| 201 } | 201 } |
| 202 | 202 |
| 203 function extension_testSearch(nextTest) | 203 function extension_testSearch(nextTest) |
| 204 { | 204 { |
| 205 var callbackCount = 0; | 205 var callbackCount = 0; |
| 206 | 206 |
| 207 function onPanelCreated(panel) | 207 function onPanelCreated(panel) |
| 208 { | 208 { |
| 209 var callback = function(action, queryString) | 209 var callback = function(action, queryString) |
| 210 { | 210 { |
| 211 output("Panel searched:"); | 211 output("Panel searched:"); |
| 212 dumpObject(Array.prototype.slice.call(arguments)); | 212 dumpObject(Array.prototype.slice.call(arguments)); |
| 213 callbackCount++; | 213 callbackCount++; |
| 214 if (callbackCount === 2) { | 214 if (callbackCount === 2) { |
| 215 nextTest(); | 215 nextTest(); |
| 216 panel.onSearch.removeListener(callback); | 216 panel.onSearch.removeListener(callback); |
| 217 } | 217 } |
| 218 }; | 218 }; |
| 219 panel.onSearch.addListener(callback); | 219 panel.onSearch.addListener(callback); |
| 220 | 220 |
| 221 extension_showPanel("extension"); | 221 extension_showPanel("extension"); |
| 222 | 222 |
| 223 function performSearch(query) | 223 function performSearch(query) |
| 224 { | 224 { |
| 225 WebInspector.inspectorView.panel("file://TestPanelforsearch").then(p
anel => { | 225 UI.inspectorView.panel("file://TestPanelforsearch").then(panel => { |
| 226 panel.searchableView().showSearchField(); | 226 panel.searchableView().showSearchField(); |
| 227 panel.searchableView()._searchInputElement.value = query; | 227 panel.searchableView()._searchInputElement.value = query; |
| 228 panel.searchableView()._performSearch(true, true); | 228 panel.searchableView()._performSearch(true, true); |
| 229 panel.searchableView().cancelSearch(); | 229 panel.searchableView().cancelSearch(); |
| 230 }); | 230 }); |
| 231 } | 231 } |
| 232 | 232 |
| 233 evaluateOnFrontend(performSearch.toString() + " performSearch(\"hello\")
;"); | 233 evaluateOnFrontend(performSearch.toString() + " performSearch(\"hello\")
;"); |
| 234 } | 234 } |
| 235 var basePath = location.pathname.replace(/\/[^/]*$/, "/"); | 235 var basePath = location.pathname.replace(/\/[^/]*$/, "/"); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 var url = urls[urlIndex++]; | 290 var url = urls[urlIndex++]; |
| 291 output("Showing " + trimURL(url)); | 291 output("Showing " + trimURL(url)); |
| 292 webInspector.panels.openResource(url, 1000 + urlIndex, showNextURL); | 292 webInspector.panels.openResource(url, 1000 + urlIndex, showNextURL); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 function extension_testGlobalShortcuts(nextTest) | 296 function extension_testGlobalShortcuts(nextTest) |
| 297 { | 297 { |
| 298 var platform; | 298 var platform; |
| 299 var testPanel; | 299 var testPanel; |
| 300 evaluateOnFrontend("reply(WebInspector.platform())", function(result) { | 300 evaluateOnFrontend("reply(Host.platform())", function(result) { |
| 301 platform = result; | 301 platform = result; |
| 302 var basePath = location.pathname.replace(/\/[^/]*$/, "/"); | 302 var basePath = location.pathname.replace(/\/[^/]*$/, "/"); |
| 303 webInspector.panels.create("Shortcuts Test Panel", basePath + "extension
-panel.png", basePath + "extension-panel.html", onPanelCreated); | 303 webInspector.panels.create("Shortcuts Test Panel", basePath + "extension
-panel.png", basePath + "extension-panel.html", onPanelCreated); |
| 304 }); | 304 }); |
| 305 function dispatchKeydownEvent(attributes) | 305 function dispatchKeydownEvent(attributes) |
| 306 { | 306 { |
| 307 var event = new KeyboardEvent("keydown", attributes); | 307 var event = new KeyboardEvent("keydown", attributes); |
| 308 document.dispatchEvent(event); | 308 document.dispatchEvent(event); |
| 309 } | 309 } |
| 310 function onPanelCreated(panel) | 310 function onPanelCreated(panel) |
| 311 { | 311 { |
| 312 testPanel = panel; | 312 testPanel = panel; |
| 313 testPanel.onShown.addListener(onPanelShown); | 313 testPanel.onShown.addListener(onPanelShown); |
| 314 evaluateOnFrontend("InspectorTest.switchToLastPanel();"); | 314 evaluateOnFrontend("InspectorTest.switchToLastPanel();"); |
| 315 } | 315 } |
| 316 var panelWindow; | 316 var panelWindow; |
| 317 function onPanelShown(win) | 317 function onPanelShown(win) |
| 318 { | 318 { |
| 319 panelWindow = win; | 319 panelWindow = win; |
| 320 testPanel.onShown.removeListener(onPanelShown); | 320 testPanel.onShown.removeListener(onPanelShown); |
| 321 output("Panel shown, now toggling console..."); | 321 output("Panel shown, now toggling console..."); |
| 322 panelWindow.addEventListener("resize", onPanelResized); | 322 panelWindow.addEventListener("resize", onPanelResized); |
| 323 dispatchKeydownEvent({ key: "Escape" }); | 323 dispatchKeydownEvent({ key: "Escape" }); |
| 324 } | 324 } |
| 325 function onPanelResized() | 325 function onPanelResized() |
| 326 { | 326 { |
| 327 panelWindow.removeEventListener("resize", onPanelResized); | 327 panelWindow.removeEventListener("resize", onPanelResized); |
| 328 output("Panel resized, test passed."); | 328 output("Panel resized, test passed."); |
| 329 evaluateOnFrontend("reply(WebInspector.inspectorView._closeDrawer())", n
extTest); | 329 evaluateOnFrontend("reply(UI.inspectorView._closeDrawer())", nextTest); |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 function loadResources() | 333 function loadResources() |
| 334 { | 334 { |
| 335 var xhr = new XMLHttpRequest(); | 335 var xhr = new XMLHttpRequest(); |
| 336 xhr.open("GET", "resources/missing.txt", false); | 336 xhr.open("GET", "resources/missing.txt", false); |
| 337 xhr.send(); | 337 xhr.send(); |
| 338 var img = document.createElement("img"); | 338 var img = document.createElement("img"); |
| 339 img.src = "resources/abe.png"; | 339 img.src = "resources/abe.png"; |
| 340 document.body.appendChild(img); | 340 document.body.appendChild(img); |
| 341 } | 341 } |
| 342 </script> | 342 </script> |
| 343 </head> | 343 </head> |
| 344 <body onload="runTest()"> | 344 <body onload="runTest()"> |
| 345 <p>Tests WebInspector extension API</p> | 345 <p>Tests WebInspector extension API</p> |
| 346 </body> | 346 </body> |
| 347 </html> | 347 </html> |
| OLD | NEW |