View source links from browser console sometimes don't scroll to line
Categories
(Toolkit :: View Source, defect, P3)
Tracking
()
People
(Reporter: Gijs, Assigned: nchevobbe)
References
Details
Attachments
(1 obsolete file)
What were you doing?
- set up local artifact build
- add
console.error("Hello")to e.g. the first line ofundoCloseWindowin SessionStore.sys.mjs. - run
./mach build faster && ./mach run - open browser console
- open new window, close it, then cmd-shift-n to reopen the same window
- click link to sessionstore.sys.mjs in the browser console
What happened?
SessionStore.sys.mjs loads in view-source, scrolled to the top of the file.
What should have happened?
The file should have loaded with the line in question (the console.error added in step 2) highlighted and scrolled into view
| Assignee | ||
Comment 1•2 years ago
|
||
this is where we handle the line number https://searchfox.org/mozilla-central/rev/f078cd02746b29652c134b144f0629d47e378166/toolkit/actors/ViewSourcePageChild.sys.mjs#141-144
it is properly set in https://searchfox.org/mozilla-central/rev/f078cd02746b29652c134b144f0629d47e378166/toolkit/actors/ViewSourcePageChild.sys.mjs#42-44, from https://searchfox.org/mozilla-central/rev/f078cd02746b29652c134b144f0629d47e378166/toolkit/actors/ViewSourceChild.sys.mjs#114, when clicking on the browser console link
But then, we re-execute the assignment (https://searchfox.org/mozilla-central/rev/f078cd02746b29652c134b144f0629d47e378166/toolkit/actors/ViewSourcePageChild.sys.mjs#27) and we lose track of the line number we wanted to set, I guess because this is a JSWindowActor and it gets spawned again when we load the view-source tab.
I wonder if we couldn't simplify this by passing the line number in the view-source url (e.g. like in searchfox, view-source:path/to/file.js#42) so we don't have to handle such wannabee global variable
| Reporter | ||
Comment 2•2 years ago
|
||
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #1)
But then, we re-execute the assignment (https://searchfox.org/mozilla-central/rev/f078cd02746b29652c134b144f0629d47e378166/toolkit/actors/ViewSourcePageChild.sys.mjs#27) and we lose track of the line number we wanted to set, I guess because this is a JSWindowActor and it gets spawned again when we load the
view-sourcetab.
Huh, fascinating. Why does it work some of the time, then (e.g. links to tabbrowser.js seem to have worked for me)? Is it just a race? Or does it have to do with the URL / protocol used?
I wonder if we couldn't simplify this by passing the line number in the view-source url (e.g. like in searchfox,
view-source:path/to/file.js#42) so we don't have to handle such wannabee global variable
Either that or keep it in the parent or another more persistent bit of storage...
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 3•2 years ago
|
||
When a line number is passed, we append it at the end of the view-source URL
so we can then consume it from ViewSourcePageChild.
Having this directly in the URL also opens up the "opens at line" feature to new
consumers (e.g. clicking on JS traces in stdout when devtools are not open could
open a view-source tab at the right location).
Updated•2 years ago
|
Comment 4•2 years ago
|
||
A patch has been attached on this bug, which was already closed. Filing a separate bug will ensure better tracking. If this was not by mistake and further action is needed, please alert the appropriate party. (Or: if the patch doesn't change behavior -- e.g. landing a test case, or fixing a typo -- then feel free to disregard this message)
| Assignee | ||
Comment 5•2 years ago
|
||
sorry, I didn't mean to close the bug last week, but let's set it as duplicate
Comment 6•2 years ago
|
||
Comment on attachment 9328086 [details]
Bug 1823373 - Pass line number to view-source URL. r=#devtools-reviewers.
Revision D175212 was moved to bug 1808153. Setting attachment 9328086 [details] to obsolete.
Description
•