Closed Bug 479408 Opened 15 years ago Closed 15 years ago

search engine discovery code doesn't properly handle frames ("browser is null" in BrowserSearch::addEngine)

Categories

(Firefox :: Search, defect)

3.0 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 3.6a1

People

(Reporter: matt, Assigned: zeniko)

References

()

Details

(Keywords: fixed1.9.1)

Attachments

(1 file, 1 obsolete file)

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8pre) Gecko/2009021904 GranParadiso/3.0.8pre ID:2009021904

When loading a Japanese Wikipedia page automatically translated to English by Google Translate, I get the following JS error:

Error: browser is null
Source file: chrome://browser/content/browser.js
Line: 2583

It happes at the line:

    if (browser.engines) {

In BrowserSearch::addEngine()

Doesn't happen when viewing the Japanese page without tranlsation, or with  translated Japanese Wikipedia pages other than this bug reports URL.
This happens because the page is in a frame, apparently. The search engine discovery code only looks for top-level documents (via getBrowserForDocument()).
Summary: "browser is null" in BrowserSearch::addEngine() in chrome://browser/content/browser.js → search engine discovery code doesn't properly handle frames ("browser is null" in BrowserSearch::addEngine)
The same issue also exists in the Feed handler, except that we've got a null check there with the comment // ??? this really shouldn't happen..

What to fix: Both handlers or getBrowserForDocument?
Assignee: nobody → zeniko
OS: Linux → All
Hardware: x86 → All
If you plan on making discovery of feeds in frames work, I think that'll be the fourth change in our behavior for that without having ever made an explicit decision about how-and-whether (though on the upside, it would be the first *intentional* change) - there's a bug, possibly currently WFM, where Jesse and I had a desultory conversation about the implications.
(In reply to comment #3)
That's bug 305472, thanks for the note. Considering the discussion in that bug, I'll stick to updating the comment.
Attached patch fix and test (obsolete) — Splinter Review
Attachment #363406 - Flags: review?(gavin.sharp)
Don't the arguments in bug 305472 comment 4 equally apply to search engines? Not sure why they should differ from feeds in this respect.
The main difference is that search engines are not as intimately tied to the address bar as the feed icon is.
What's that do for data:text/html,<iframe src="http://developer.mozilla.org/"></iframe> when you follow one of the external links to somewhere without a search engine? (And even if it does happen to do the right thing and remove the discovered engine, given our penchant for breaking that, a test would be a good thing).

Do we support discovering multiple engines at once? What happens if the framing document (or even a frameset document) has a search engine and a framed document does too (or multiple framed documents do)? Whoever loads slowest wins?
Right, let's just fix the error, then.

(In reply to comment #8)
> What's that do for data:text/html,<iframe
> src="http://developer.mozilla.org/"></iframe> when you follow one of the
> external links to somewhere without a search engine?

The wrong thing. :-(

> Do we support discovering multiple engines at once?

We do, as long as they've got different titles.

> Whoever loads slowest wins?

First come, first serve.
Attachment #363406 - Attachment is obsolete: true
Attachment #363422 - Flags: review?(gavin.sharp)
Attachment #363406 - Flags: review?(gavin.sharp)
Comment on attachment 363422 [details] [diff] [review]
fix error and add comments

thanks!
Attachment #363422 - Flags: review?(gavin.sharp) → review+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/410bc15d198b
Status: NEW → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3.2a1
Attachment #363422 - Flags: approval1.9.1?
Comment on attachment 363422 [details] [diff] [review]
fix error and add comments

a191=beltzner
Attachment #363422 - Flags: approval1.9.1? → approval1.9.1+
Keywords: checkin-needed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: