Closed Bug 2080691 Opened 1 month ago Closed 22 hours ago

"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)

defect

Tracking

()

RESOLVED FIXED
163 Branch
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:

  1. Open view-source of any HTML page
  2. Right-click the page and choose "Go to Line…"
  3. 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.

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.

I marked it as a regression, but this might also be a good first bug (fix is trivial, but clearly needs a test).

Mentor: emilio
Flags: needinfo?(emilio)
Keywords: good-first-bug
Severity: -- → S3
Priority: -- → P1
Priority: P1 → P3
Severity: S3 → S4

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 returns null if the <pre> element cannot be found.
  • goToLine() already sends ViewSource:GoToLine:Failed on null, so the parent shows the "Line not found" prompt.
  • Keep the new test case in browser_gotoline.js to 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!

Flags: needinfo?(emilio)

That seems reasonable, yes. Thanks!

Flags: needinfo?(emilio)

There's no need to explicitly assign. Once you submit the patch the bug will be auto-assigned.

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!

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.

Flags: needinfo?(asquaret)

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!

Flags: needinfo?(asquaret)
Assignee: nobody → asquaret
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/74d3247ce8f9 https://hg.mozilla.org/integration/autoland/rev/b15e48f4b6e8 Return null from findLocation() when the view-source document has no <pre>. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 22 hours ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: