Closed Bug 521065 Opened 15 years ago Closed 15 years ago

Overriding gBrowser.addTab doesn't work properly

Categories

(Firefox :: Tabbed Browser, defect)

3.6 Branch
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: mkaply, Unassigned)

References

Details

(Keywords: regression)

Attachments

(1 file)

Many extensions (especially ones that modify tab behavior) override gBrowser.addTab in order change things after a new tab is opened.

This no longer works when a tab is opened using the middle mouse button or right click, open Link in new tab.

The tab opens, but never loads.

The error is:

Error: [Exception... "'JavaScript component does not have a method named: "clone"' when calling method: [nsIURI::clone]"  nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)"  location: "JS frame :: chrome://global/content/bindings/browser.xml :: loadURIWithFlags :: line 186"  data: no]
Source File: chrome://global/content/bindings/browser.xml
Line: 186

I've attached an extension that replaces AddTab.

You can check the behavior on Firefox 3.5 and Firefox 3.6.
Version: Trunk → 3.6 Branch
1. The proper way to change things after a new tab is opened is to listen to the TabOpen event.
2. The test extension calls gBrowser.origAddTab(a,b,c,d,e,f). Instead, it should do origAddTab.apply(gBrowser, arguments).
Blocks: 515932
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
Is there much of a benefit to the arguments.length check here? Perhaps we should just remove it...
Doh. Forgot about the apply. That's my mistake.

But I do know one large set of extensions that will be broken by this because they don't use the .apply - every BenefitBar.

That's where I saw this done originally.
The arguments.length check makes sense because it's cheaper than instanceof Ci.nsIURI.

gBrowser.origAddTab(a,b,c,d,e,f) also assumes that we never add a seventh argument. It's really a harmful pattern.
Actually it was Freecause and they seemed to have fixed it, so I'll take the INVALID.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: