Ticket #22 (new defect)

Opened 1 year ago

Last modified 5 months ago

GM_openInTab should obey Firefox tab option

Reported by: loucypher.m..@gmail.com Assigned to:
Priority: major Milestone:
Version: Keywords:
Cc:

Description

By default, GM_openInTab(url) command loads the url in a new background tab. It should obey Firefox tab option "When I open a link in a new tab, switch to it immediately", or "browser.tabs.loadInBackground" in prefs.

Attachments

GM_openInTab.patch (0.6 kB) - added by loucypher.m..@gmail.com on 06/03/07 21:56:02.
GM_openInTab-send_referrer.patch (1.0 kB) - added by anonymous on 06/04/07 08:40:34.
Send referrer header
ticket#22.patch (0.8 kB) - added by loucypher.m..@gmail.com on 07/31/07 23:00:54.
uses openNewTabWith()

Change History

06/03/07 21:56:02 changed by loucypher.m..@gmail.com

  • attachment GM_openInTab.patch added.

06/04/07 06:57:32 changed by aranti..@gmail.com

I'm thinking that openUILinkIn might be a good (better?) solution here also.

06/04/07 08:18:04 changed by LouCypher

We can use it

GM_BrowserUI.openInTab = function(domWindow, url) {
  if (this.isMyWindow(domWindow)) {
var loadInBackground = this.tabBrowser.mPrefs.getBoolPref("browser.tabs.loadInBackground");
openUILinkIn(url, loadInBackground ? "tab" : "tabshifted")
  }
}

While we're at it, GM_openInTab doesn't send the referrer header. Should it also send the referrer if it's enabled (network.http.sendRefererHeader in prefs)? We can't use openUILinkIn to send the referrer, but we can use tabbrowser.addTab or tabbrowser.loadOneTab.

06/04/07 08:40:34 changed by anonymous

  • attachment GM_openInTab-send_referrer.patch added.

Send referrer header

07/05/07 10:27:09 changed by anonymous

  • cc set to None.
  • keywords set to None.
  • summary changed from GM_openInTab should obey Firefox tab option to None.
  • priority changed from major to minor.

07/06/07 18:22:03 changed by anonymous

  • cc changed from None to painting.
  • keywords changed from None to painting.
  • summary changed from None to painting.
  • priority changed from minor to major.

07/07/07 09:40:44 changed by anonymous

  • keywords changed from painting to wine.
  • priority changed from major to minor.
  • type changed from defect to enhancement.
  • summary changed from painting to wine.

07/11/07 03:52:05 changed by anonymous

  • keywords changed from wine to game.
  • priority changed from minor to major.
  • type changed from enhancement to defect.
  • summary changed from wine to game.

07/12/07 11:45:55 changed by loucypher.m..@gmail.com

  • cc deleted.
  • keywords deleted.
  • summary changed from game to GM_openInTab should obey Firefox tab option.

(follow-up: ↓ 12 ) 07/24/07 19:07:39 changed by boo..@youngpup.net

Does open-in-tab usually send the referer header? If so, how does it work. Can we reuse the function that Firefox uses when you click open-in-tab in, for example, the context menu?

(in reply to: ↑ 11 ; follow-up: ↓ 13 ) 07/24/07 19:11:27 changed by aranti..@gmail.com

Replying to boo..@youngpup.net:

Does open-in-tab usually send the referer header?

Yep, does for me.

If so, how does it work. Can we reuse the function that Firefox uses when you click open-in-tab in, for example, the context menu?

I think you're looking for openUILinkIn. We should be able to. And, bonus: it's got an argument for populating the referer with!

(in reply to: ↑ 12 ; follow-up: ↓ 14 ) 07/24/07 19:26:52 changed by boo..@youngpup.net

Replying to aranti..@gmail.com:

I think you're looking for openUILinkIn. We should be able to. And, bonus: it's got an argument for populating the referer with!

There's also openNewTabWith(): http://lxr.mozilla.org/mozilla1.8/source/browser/base/content/browser.js#4812 http://lxr.mozilla.org/mozilla1.8/source/toolkit/content/contentAreaUtils.js#56

They look about equivalent to me.

(in reply to: ↑ 13 ; follow-up: ↓ 15 ) 07/24/07 19:33:25 changed by aranti..@gmail.com

Replying to boo..@youngpup.net:

There's also openNewTabWith(): http://lxr.mozilla.org/mozilla1.8/source/browser/base/content/browser.js#4812

This one appears to be a property of an object related to context menus, with references to "this" that won't work here.

http://lxr.mozilla.org/mozilla1.8/source/toolkit/content/contentAreaUtils.js#56

This one wants an event, which we don't really have at this point.

(in reply to: ↑ 14 ; follow-up: ↓ 24 ) 07/24/07 19:38:55 changed by boo..@youngpup.net

Replying to aranti..@gmail.com:

Replying to boo..@youngpup.net:

There's also openNewTabWith(): http://lxr.mozilla.org/mozilla1.8/source/browser/base/content/browser.js#4812

This one appears to be a property of an object related to context menus, with references to "this" that won't work here.

I was pointing at the invocation, as an example of how you can pass null for the other args. Whichever seems less coupled to Mozilla internals is good with me.

07/25/07 06:52:28 changed by loucypher.m..@gmail.com

Both openUILinkIn() and openNewTabWith() use browser method loadOneTab() to open a URL in new tab (see line line 88 and line 227). It has arguments for load in background tab and referrer as well, so why don't we just use loadOneTab() instead?

07/25/07 06:59:31 changed by aranti..@gmail.com

Because either or both of those methods perform all sorts of logic that we would have to re-implement. Nothing super complex, but it's already done!

07/25/07 08:30:34 changed by boo..@youngpup.net

I would rather go as high up in the call stack as possible so that we capture as much of the logic as possible that Mozilla does when you click "open in new tab" on a link.

If we re-implement the logic for determining whether to open in the foreground or background, for example, then we will have to update it when Mozilla changes this logic.

07/31/07 22:59:57 changed by loucypher.m..@gmail.com

OK, I get it now. I think openNewTabWith() is the strong candidate. It's used by "Open in New Tab" on context menu. Also, openUILinkIn() uses pref "browser.tabs.loadBookmarksInBackground" instead of "browser.tabs.loadInBackground".

The second argument in openNewTabWith() is used to set the referrer header and to do a security check of whether the document as allowed to reference the URL (for example, if we click on a chrome link. I found another bug on this with current GM_openInTab()).

Test case:
http://zoolcar9.lhukie.net/test/GM_openInTab.html
http://zoolcar9.lhukie.net/test/GM_openInTab.user.js

Patch follows.

07/31/07 23:00:54 changed by loucypher.m..@gmail.com

  • attachment ticket#22.patch added.

uses openNewTabWith()

08/14/07 18:15:49 changed by anonymous

04/01/08 01:32:13 changed by anonymous

江苏省顺利牧业是一家专业从事良种瘦肉型仔猪繁育、仔猪销售的独资企业。基地成立以来,一直深受省、市、县三级领导的关心与扶持,年年被评为诚实、守信企业,全国外三元育种协作组成员单位,经过不断的扩建,和仔猪品种的改良,基地常年面向全国供应25-110斤长白、杜洛克、双肌臀大约克、内 外三元、纯种四元优质瘦肉型苗猪, 养猪基地所有繁育场采用科学节约化繁育管理,技术质量高,抗病能力强、成活率高。目前加盟我公司连锁大型猪场已达50多家,确保质量。 基地主防:口蹄疫、链球菌、蓝耳病、弓形虫猪圆环病毒、二型混合感染等。 目前公司苗猪远销:苏、沪、浙、皖、鄂、赣、豫、湘、京、冀、晋、陕、新、粤、闽以及东北三省,内蒙等地。让每一个客户都能在顺利苗猪繁殖场,买到良种瘦肉型苗猪是公司最根本宗旨!

1、建立外贸型公司,原料、市场、技术、人才、资金、信息等资;

2、利用现代电子信息技术,建立和完善顺利牧业的电子商务系统和计算机管理系统,实现网上的物流管理,网下的配送服务;

04/14/08 20:52:27 changed by brain

8y4oHd 0f9v37f7d2g9flas5

04/19/08 08:56:43 changed by anonymous

(in reply to: ↑ 15 ) 05/22/08 08:01:52 changed by anonymous

Replying to boo..@youngpup.net:

Replying to aranti..@gmail.com:

Replying to boo..@youngpup.net:

There's also openNewTabWith(): http://lxr.mozilla.org/mozilla1.8/source/browser/base/content/browser.js#4812

This one appears to be a property of an object related to context menus, with references to "this" that won't work here.

I was pointing at the invocation, as an example of how you can pass null for the other args. Whichever seems less coupled to Mozilla internals is good with me.

(follow-up: ↓ 26 ) 05/22/08 08:03:15 changed by anonymous

can happy am has dont your the fun jet really

(in reply to: ↑ 25 ) 05/22/08 08:03:55 changed by anonymous

Replying to anonymous:

can happy am has dont your the fun jet really

(in reply to: ↑ description ) 05/22/08 08:05:35 changed by anonymous

Replying to loucypher.m..@gmail.com:

By default, GM_openInTab(url) command loads the url in a new background tab. It should obey Firefox tab option "When I open a link in a new tab, switch to it immediately", or "browser.tabs.loadInBackground" in prefs.

05/22/08 08:06:06 changed by anonymous

CHEYENE MAME HAPPE

05/22/08 08:07:02 changed by anonymous

(: :) HAPPY


Add/Change #22 (GM_openInTab should obey Firefox tab option)