Closed Bug 867567 Opened 7 years ago Closed 7 years ago

JavaScript Error: "TypeError: focused is null" {file: "chrome://browser/content/browser.js" line: 1205}


(Firefox for Android :: General, defect)

Not set



Firefox 24


(Reporter: kats, Assigned: marcosadp)


(Blocks 1 open bug)


(Whiteboard: [lang=js][mentor=kats])


(1 file)

This line of code in browser.js:

if  (focused instanceof HTMLTextAreaElement || focused.isContentEditable) {

causes the script error noted in the summary when focused is null. Should be an easy fix for somebody looking for a good first bug.
This was reported in bug 864926, although the description in that bug points to the wrong line of code. Setting this bug to block that one, since there was another error reported in there as well.
Blocks: 864926
Hi there,

I've been speaking to people on the IRC channel and this bug was suggested as a good first bug to tackle. I've had a look into it but am unable to reproduce the error. It's clear to me what is going wrong here, just I don't see it going wrong on my device. I do get the "Only internal code is allowed..." error described in bug 864926 when I open a new private tab, though. How do I go about reproducing this script error?

Is the intention here to work out why focused is null or simply do a 
if (!focused) return null 
catch either before or after the HTMLFrameElement search/traveral?

Hi Jamie, thanks for showing interest in this bug.

It sounds to me like we just need a null check. kats is on vacation right now, but maybe wesj can help you out with this bug, since he has also worked on this code.
Flags: needinfo?(wjohnston)
Yeah. Glancing at the code, it looks like we DO expect getFocusedInput to return null sometimes. I'm also having trouble reproducing it, but the null check seems like a good idea.
Flags: needinfo?(wjohnston)
Hi Jamie, sorry for the delayed response; I was on vacation. But yeah as wesj said getFocusedInput can return null, and so we just need to modify the if condition I posted above to include a null check.
Kartikaya, I would like to work on this. Could you please assign me the bug?
Assignee: nobody → marcosadp
Attached patch Patch v1Splinter Review
Attachment #759778 - Flags: review?(bugmail.mozilla)
Comment on attachment 759778 [details] [diff] [review]
Patch v1

Review of attachment 759778 [details] [diff] [review]:

Looks good, thanks!
Attachment #759778 - Flags: review?(bugmail.mozilla) → review+
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 24
You need to log in before you can comment on or make changes to this bug.