I develop Open in Editor extension for Google Chrome DevTools that allows to open source file in external editor using context menu.
It works perfectly in most of cases (Network panel, Performance panel, Style inspector, and so on) when file location in UI contains a line number (like jquery.js:2191
).
The only exception is Sources panel. A chrome.devtools.panels.setOpenResourceHandler callback function doesn't receive a line number.
Does DevTools has some API to get a position of cursor in source editor from setOpenResourceHandler()
callback?
I develop Open in Editor extension for Google Chrome DevTools that allows to open source file in external editor using context menu.
It works perfectly in most of cases (Network panel, Performance panel, Style inspector, and so on) when file location in UI contains a line number (like jquery.js:2191
).
The only exception is Sources panel. A chrome.devtools.panels.setOpenResourceHandler callback function doesn't receive a line number.
Does DevTools has some API to get a position of cursor in source editor from setOpenResourceHandler()
callback?
- 6 Maybe you could check this developers.google./web/tools/chrome-devtools/inspect-styles and this developers.google./web/updates/2015/05/… but there is still no method mention like it. Maybe this is not supported yet as of now. – Mr.Rebot Commented Jul 21, 2017 at 9:58
- @Mr.Rebot, thank you for an advice. I've raised the issue bugs.chromium/p/chromium/issues/detail?id=747888 . – Evgeniy Generalov Commented Jul 24, 2017 at 11:09
- Please edit the question to be on-topic: include a minimal reproducible example that duplicates the problem. For Chrome extensions or Firefox WebExtensions you almost always need to include your manifest.json and some of the background, content, and/or popup scripts/HTML, and often webpage HTML/scripts. Questions seeking debugging help ("why isn't my code working the way I want?") must include: (1) the desired behavior, (2) a specific problem or error and (3) the shortest code necessary to reproduce it in the question itself. Please also see: What topics can I ask about here?, and How to Ask. – Makyen ♦ Commented Oct 6, 2017 at 21:24
1 Answer
Reset to default 2This has been explained as per reported Chrome Issue 747888:
So first of all,
setOpenResourceHandle()
is for the cases when users click a link (e.g. alinkified
location in console) that normally results in opening a source tab in DevTools, it's not meant to be fired when a file is explicitly opened in the source panel. For changes of the file/position within the sources tab, we've gotchrome.devtools.panels.sources.onSelectionChanged
(see a layout test for example usage) that was recently brought back by @jacobr).
Here is the mentioned code example:
function extension_testElementsOnSelectionChanged(nextTest)
{
function onSelectionChanged()
{
webInspector.panels.elements.onSelectionChanged.removeListener(onSelectionChanged);
output("onSelectionChanged fired");
nextTest();
}
webInspector.panels.elements.onSelectionChanged.addListener(onSelectionChanged);
webInspector.inspectedWindow.eval("inspect(document.body.children[0]), 0");
}
function extension_testSourcesOnSelectionChangedShowFile(nextTest)
{
function onSelectionChanged(selectionInfo)
{
webInspector.panels.sources.onSelectionChanged.removeListener(onSelectionChanged);
output("sources onSelectionChanged fired, selectionInfo:");
dumpObject(selectionInfo, {url: "url"});
nextTest();
}
webInspector.panels.sources.onSelectionChanged.addListener(onSelectionChanged);
evaluateOnFrontend("InspectorTest.showScriptSource(\"test-script.js\")");
}
function extension_testSourcesOnSelectionChangedShowFileAndLine(nextTest)
{
webInspector.inspectedWindow.eval("location.href", function(inspectedPageURL) {
function onSelectionChanged(selectionInfo)
{
webInspector.panels.sources.onSelectionChanged.removeListener(onSelectionChanged);
output("sources onSelectionChanged fired, selectionInfo:");
dumpObject(selectionInfo, {url: "url"});
nextTest();
}
webInspector.panels.sources.onSelectionChanged.addListener(onSelectionChanged);
var basePath = inspectedPageURL.replace(/\/[^/]*$/, "/");
webInspector.panels.openResource(basePath + "resources/test-script.js", 2);
});
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745285464a4620531.html
评论列表(0条)