"Go to Line" with an out-of-range line number throws instead of showing "Line not found" when viewing HTML source
Categories
(Toolkit :: View Source, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr115 | --- | unaffected |
| firefox-esr153 | --- | wontfix |
| firefox158 | --- | wontfix |
| firefox159 | --- | wontfix |
| firefox160 | --- | fix-optional |
| firefox163 | --- | fixed |
People
(Reporter: flod, Assigned: asquaret, Mentored)
References
(Regression)
Details
(Keywords: good-first-bug, regression)
Attachments
(1 external file)
Found while working on bug 2080569 (would be nice to wait for what to land before touching this).
Steps to reproduce:
- Open view-source of any HTML page
- Right-click the page and choose "Go to Line…"
- Enter a line number larger than the number of lines in the source (e.g. 10000)
This should display a "Line not found" alert and the "Go to line" prompt is shown again. Instead, you get an error:
TypeError: can't access property "id", pre is null
(ViewSourcePageChild.sys.mjs, in findLocation)
ViewSourcePageChild.findLocation() first looks the line up by ID; when that fails, it falls back to walking the text of the first <pre> in the
document, which is only meant for the plain-text case.
Comment 1•1 month ago
|
||
Set release status flags based on info from the regressing bug 1927404
:emilio, since you are the author of the regressor, bug 1927404, could you take a look? Also, could you set the severity field?
For more information, please visit BugBot documentation.
| Reporter | ||
Comment 2•1 month ago
|
||
I marked it as a regression, but this might also be a good first bug (fix is trivial, but clearly needs a test).
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
| Assignee | ||
Comment 3•1 month ago
|
||
Hi! I'd like to work on this bug. I'm a newcomer to the Firefox codebase.
I was able to reproduce the issue by adding a test case in browser_gotoline.js requesting an out-of-range line number on a text/html document, which triggers the pre is null TypeError.
Since the blocker (bug 2080569) has landed, here is my proposed fix:
- Update
findLocation()so that it returnsnullif the<pre>element cannot be found. goToLine()already sendsViewSource:GoToLine:Failedonnull, so the parent shows the "Line not found" prompt.- Keep the new test case in
browser_gotoline.jsto prevent regressions.
:emilio: Does returning null from findLocation() align with what you'd expect here, or would you prefer a different approach?
Could someone please assign this bug to me? Thanks!
Comment 5•1 month ago
|
||
There's no need to explicitly assign. Once you submit the patch the bug will be auto-assigned.
| Assignee | ||
Comment 6•27 days ago
|
||
Hi :emilio, thanks for confirming! I made the fix (findLocation() now returns null when there's no <pre>) and the new check in browser_gotoline.js passes now: 54 passed, 0 failed, and before the fix it was failing with the pre is null error. ./mach lint is clean too.
But I'm stuck on submitting it. phabricator.services.mozilla.com gives me "406 Not Acceptable" on every network I tried (my university wifi, Jio mobile data and with a VPN, I'm in India), so I can't run moz-phab install-certificate or submit. Bugzilla works fine for me. Is there another way I can send you the patch, or should I report this somewhere? Thanks!
Comment 7•27 days ago
|
||
Yes, this is expected right now and temporary (Phabricator was patched and taken off the public internet due to the recent PHP vulnerabilities, and will be opened up on Monday if all goes well, currently it's only accessible via internal VPN).
Sorry for the hiccup. It should work just fine on Monday afaict :/
Hi Aaron Anish Thadathil, Are you still interested in working on this bug? Phabricator is back up now.
| Assignee | ||
Comment 9•2 days ago
|
||
Hi! Yes, I'm still interested in working on this.
I already have the fix and a test ready. findLocation() now returns null when there's no <pre>, and the test asks for a line past the end of the content.
Could I be assigned to this before I submit the patch? Thanks!
| Assignee | ||
Comment 10•2 days ago
|
||
Updated•2 days ago
|
Comment 11•1 day ago
|
||
Comment 12•22 hours ago
|
||
| bugherder | ||
Description
•