Network monitor opens files in last tab
Categories
(DevTools :: General, defect, P3)
Tracking
(firefox158 fixed)
| Tracking | Status | |
|---|---|---|
| firefox158 | --- | fixed |
People
(Reporter: vopros4, Assigned: blessedonekobo, Mentored)
Details
(Whiteboard: [lang=js])
Attachments
(1 file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:153.0) Gecko/20100101 Firefox/153.0
Steps to reproduce:
- Open developer tools (F12), switch to the network monitor.
- Load any page that loads multiple files, e.g. https://bugzilla.mozilla.org/home
- Open several more tabs.
- In the tab with open monitor, right-click any file in the monitor, e.g. https://bugzilla.mozilla.org/extensions/BMO/web/images/favicon.svg, "Open in new tab"
Actual results:
A new tab appears on the far right, the link opens there.
The values of browser.tabs.insertAfterCurrent, browser.tabs.insertAfterCurrentExceptPinned and browser.tabs.insertRelatedAfterCurrent do not seem to affect this behaviour.
Expected results:
The expected default behaviour is to open the new tab next to the current one.
Comment 1•1 month ago
|
||
The Bugbug bot thinks this bug should belong to the 'Firefox::Tabbed Browser' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•1 month ago
|
Comment 2•1 month ago
•
|
||
For devtools triage: It looks like devtools may be calling gBrowser.addTrustedTab / addWebTab directly: https://searchfox.org/firefox-main/search?q=gBrowser.add&path=devtools&case=true®exp=false
Utilizing the higher-level URILoadingHelper instead should fix this bug, I think.
Comment 3•1 month ago
|
||
Other links (eg Learn More link in console) seem to handle that correctly. Would be nice to fix.
Comment 4•1 month ago
|
||
This is the code for the context menu entry: https://searchfox.org/firefox-main/rev/28b5e86da948982342836c3cca50049659f0dc70/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js#463-468
id: "request-list-context-newtab",
label: L10N.getStr("netmonitor.context.newTab"),
accesskey: L10N.getStr("netmonitor.context.newTab.accesskey"),
visible: !!clickedRequest,
click: () =>
this.openRequestInTab(id, url, requestHeaders, requestPostData),
/**
* Opens selected item in a new tab.
*/
async openRequestInTab(id, url, requestHeaders, requestPostData) {
requestHeaders =
requestHeaders ||
(await this.props.connector.requestData(id, "requestHeaders"));
requestPostData =
requestPostData ||
(await this.props.connector.requestData(id, "requestPostData"));
openRequestInTab(url, requestHeaders, requestPostData);
}
which in turn calls https://searchfox.org/firefox-main/rev/28b5e86da948982342836c3cca50049659f0dc70/devtools/client/netmonitor/src/utils/firefox/open-request-in-tab.js#11-46
/**
* Opens given request in a new tab.
*/
function openRequestInTab(url, requestHeaders, requestPostData) {
const win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
const rawData = requestPostData ? requestPostData.postData : null;
let postData;
if (rawData?.text) {
const stringStream = getInputStreamFromString(rawData.text);
postData = Cc["@mozilla.org/network/mime-input-stream;1"].createInstance(
Ci.nsIMIMEInputStream
);
const contentTypeHeader = requestHeaders.headers.find(e => {
return e.name.toLowerCase() === "content-type";
});
postData.addHeader(
"Content-Type",
contentTypeHeader
? contentTypeHeader.value
: "application/x-www-form-urlencoded"
);
postData.setData(stringStream);
}
const { userContextId } = win.gBrowser.contentPrincipal;
win.gBrowser.selectedTab = win.gBrowser.addWebTab(url, {
// TODO this should be using the original request principal
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({
userContextId,
}),
userContextId,
postData,
});
}
Other places in DevTools are calling https://searchfox.org/firefox-main/rev/28b5e86da948982342836c3cca50049659f0dc70/devtools/client/shared/link.js#45-70 instead. We should be able ton use this as well, passing the right options
Updated•17 days ago
|
Comment 8•17 days ago
|
||
Backed out for causing lint failures
Backout Link
Push with failures
Failure Log
Failure line TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/devtools/client/netmonitor/test/browser_net_open_request_in_tab.js:276:3 | Use dedicated assertion methods (Assert.strictEqual) rather than ok(a === b). (mozilla/no-comparison-or-assignment-inside-ok)
Sincere apologies. It should be fine now. I didn't get a lint error in my editor. I'll run ./mach lint -w before committing in the future
Comment 10•14 days ago
|
||
Comment 11•14 days ago
|
||
| bugherder | ||
Updated•19 hours ago
|
Description
•