| 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 = WebInspector.inspectorView._tabbedPane._contentElemen
t.getBoundingClientRect(); |
| 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.currentPanel(); | 28 var panel = WebInspector.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[WebInspector.Tooltip._symbol].content + "', disabled: "
+ item.disabled); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 InspectorTest.clickButton = function(index) | 45 InspectorTest.clickButton = function(index) |
| 46 { | 46 { |
| 47 var panel = WebInspector.inspectorView.currentPanel(); | 47 var panel = WebInspector.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 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 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 + " (" + WebInspector.inspectorView.currentPanel().name + "), line: " +
lineNumber); | 91 InspectorTest.addResult("Showing resource " + url + " in panel " + p
anelName + "), line: " + lineNumber); |
| 92 } | 92 } |
| 93 InspectorTest.recordNetwork(); | 93 InspectorTest.recordNetwork(); |
| 94 | |
| 95 InspectorTest.addSniffer(WebInspector.panels.sources, "showUILocation",
showUILocationHook, true); | 94 InspectorTest.addSniffer(WebInspector.panels.sources, "showUILocation",
showUILocationHook, true); |
| 96 InspectorTest.addSniffer(WebInspector.panels.resources, "showResource",
showResourceHook, true); | 95 InspectorTest.addSniffer(WebInspector.panels.resources, "showResource",
showResourceHook, true); |
| 97 InspectorTest.addSniffer(WebInspector.panels.network, "revealAndHighligh
tRequest", showRequestHook, true); | 96 InspectorTest.addSniffer(WebInspector.panels.network, "revealAndHighligh
tRequest", showRequestHook, true); |
| 98 | 97 |
| 99 function showUILocationHook(uiLocation) | 98 function showUILocationHook(uiLocation) |
| 100 { | 99 { |
| 101 showURL("sources", uiLocation.uiSourceCode.url(), uiLocation.lineNum
ber); | 100 showURL("sources", uiLocation.uiSourceCode.url(), uiLocation.lineNum
ber); |
| 102 } | 101 } |
| 103 | 102 |
| 104 function showResourceHook(resource, lineNumber) | 103 function showResourceHook(resource, lineNumber) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 nextTest(); | 215 nextTest(); |
| 217 panel.onSearch.removeListener(callback); | 216 panel.onSearch.removeListener(callback); |
| 218 } | 217 } |
| 219 }; | 218 }; |
| 220 panel.onSearch.addListener(callback); | 219 panel.onSearch.addListener(callback); |
| 221 | 220 |
| 222 extension_showPanel("extension"); | 221 extension_showPanel("extension"); |
| 223 | 222 |
| 224 function performSearch(query) | 223 function performSearch(query) |
| 225 { | 224 { |
| 226 var panel = WebInspector.inspectorView.currentPanel(); | 225 WebInspector.inspectorView.panel("file://TestPanelforsearch").then(p
anel => { |
| 227 panel.searchableView().showSearchField(); | 226 panel.searchableView().showSearchField(); |
| 228 panel.searchableView()._searchInputElement.value = query; | 227 panel.searchableView()._searchInputElement.value = query; |
| 229 panel.searchableView()._performSearch(true, true); | 228 panel.searchableView()._performSearch(true, true); |
| 230 panel.searchableView().cancelSearch(); | 229 panel.searchableView().cancelSearch(); |
| 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(/\/[^/]*$/, "/"); |
| 236 webInspector.panels.create("Test Panel", basePath + "extension-panel.png", b
asePath + "non-existent.html", onPanelCreated); | 236 webInspector.panels.create("Test Panel for search", basePath + "extension-pa
nel.png", basePath + "non-existent.html", onPanelCreated); |
| 237 } | 237 } |
| 238 | 238 |
| 239 function extension_testStatusBarButtons(nextTest) | 239 function extension_testStatusBarButtons(nextTest) |
| 240 { | 240 { |
| 241 var basePath = location.pathname.replace(/\/[^/]*$/, "/"); | 241 var basePath = location.pathname.replace(/\/[^/]*$/, "/"); |
| 242 | 242 |
| 243 function onPanelCreated(panel) | 243 function onPanelCreated(panel) |
| 244 { | 244 { |
| 245 var button1 = panel.createStatusBarButton(basePath + "button1.png", "But
ton One tooltip"); | 245 var button1 = panel.createStatusBarButton(basePath + "button1.png", "But
ton One tooltip"); |
| 246 var button2 = panel.createStatusBarButton(basePath + "button2.png", "But
ton Two tooltip", true); | 246 var button2 = panel.createStatusBarButton(basePath + "button2.png", "But
ton Two tooltip", true); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 testPanel.onHidden.addListener(onPanelHidden); | |
| 315 evaluateOnFrontend("InspectorTest.switchToLastPanel();"); | 314 evaluateOnFrontend("InspectorTest.switchToLastPanel();"); |
| 316 } | 315 } |
| 317 var panelWindow; | 316 var panelWindow; |
| 318 function onPanelShown(win) | 317 function onPanelShown(win) |
| 319 { | 318 { |
| 320 panelWindow = win; | 319 panelWindow = win; |
| 321 testPanel.onShown.removeListener(onPanelShown); | 320 testPanel.onShown.removeListener(onPanelShown); |
| 322 output("Panel shown, now toggling console..."); | 321 output("Panel shown, now toggling console..."); |
| 323 panelWindow.addEventListener("resize", onPanelResized); | 322 panelWindow.addEventListener("resize", onPanelResized); |
| 324 dispatchKeydownEvent({ key: "Escape" }); | 323 dispatchKeydownEvent({ key: "Escape" }); |
| 325 } | 324 } |
| 326 function onPanelResized() | 325 function onPanelResized() |
| 327 { | 326 { |
| 328 panelWindow.removeEventListener("resize", onPanelResized); | 327 panelWindow.removeEventListener("resize", onPanelResized); |
| 329 output("Panel resized, switching away..."); | 328 output("Panel resized, test passed."); |
| 330 var isMac = platform === "mac"; | |
| 331 dispatchKeydownEvent({ ctrlKey: !isMac, metaKey: isMac, key: "]" }); | |
| 332 } | |
| 333 function onPanelHidden() | |
| 334 { | |
| 335 output("Panel hidden, test passed."); | |
| 336 testPanel.onShown.removeListener(onPanelHidden); | |
| 337 evaluateOnFrontend("reply(WebInspector.inspectorView._closeDrawer())", n
extTest); | 329 evaluateOnFrontend("reply(WebInspector.inspectorView._closeDrawer())", n
extTest); |
| 338 } | 330 } |
| 339 } | 331 } |
| 340 | 332 |
| 341 function loadResources() | 333 function loadResources() |
| 342 { | 334 { |
| 343 var xhr = new XMLHttpRequest(); | 335 var xhr = new XMLHttpRequest(); |
| 344 xhr.open("GET", "resources/missing.txt", false); | 336 xhr.open("GET", "resources/missing.txt", false); |
| 345 xhr.send(); | 337 xhr.send(); |
| 346 var img = document.createElement("img"); | 338 var img = document.createElement("img"); |
| 347 img.src = "resources/abe.png"; | 339 img.src = "resources/abe.png"; |
| 348 document.body.appendChild(img); | 340 document.body.appendChild(img); |
| 349 } | 341 } |
| 350 </script> | 342 </script> |
| 351 </head> | 343 </head> |
| 352 <body onload="runTest()"> | 344 <body onload="runTest()"> |
| 353 <p>Tests WebInspector extension API</p> | 345 <p>Tests WebInspector extension API</p> |
| 354 </body> | 346 </body> |
| 355 </html> | 347 </html> |
| OLD | NEW |