Closed Bug 1446426 Opened 6 years ago Closed 6 years ago

gBrowser.addTab() with createLazyBrowser does not work

Categories

(Firefox :: Tabbed Browser, defect, P1)

55 Branch
defect

Tracking

()

VERIFIED FIXED
Tracking Status
firefox-esr52 --- unaffected
firefox59 --- wontfix
firefox60 --- wontfix
firefox61 --- wontfix
firefox67 --- verified

People

(Reporter: Oriol, Assigned: Oriol)

References

(Blocks 1 open bug)

Details

(Keywords: regression)

Attachments

(1 obsolete file)

Run this code in the browser console:

   gBrowser.addTab("http://example.com", {createLazyBrowser: true});

Result: an empty lazy tab is opened
Expected: a "http://example.com" lazy tab is opened

Regression window: https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=e2ea72d6ed2ca90f8ae3206d3f7c177031b6bdd1&tochange=a03617861cb658e7ad7ad3879bf6a22718d8f6e8
We keep the URI here but it looks like we never do anything with it (except for calling _unifiedComplete.registerOpenPage): https://searchfox.org/mozilla-central/rev/42b34ba1961e37e0d2236deafdd126a0ba21b9ec/browser/base/content/tabbrowser.js#2217

Notably, we don't set __SS_lazyData in that case.
Priority: -- → P5
Priority: P5 → P3
In bug 1378647 comment 15 they propose this workaround:

  let lazyTabState = {entries: [{url: "http://example.com/", ...}]};
  let tab = gBrowser.addTab("about:blank", {createLazyBrowser: true});
  SessionStore.setTabState(tab, JSON.stringify(lazyTabState));

I think something like this should be done automatically. Stringifying lazyTabState and parsing it immediately after does not seem a great idea, though.
See Also: → 1422588
Given bug 1422588 I'd like to see about getting something done here in this cycle.
Priority: P3 → P1
Attached patch WIP tabState (obsolete) — Splinter Review
What I would propose here is that addTab takes another parameter for the title, which is the only one missing for the basic tabstate.  We probably should also allow a favicon to be set.

In the extension api implementation for tabs.create (Bug 1378647), if discard is used, we accept additional parameters for title and favicon.  If discard is used we set aCreateLazyBrowser in the addTab call.
Assignee: nobody → mixedpuppy
Dao, does the suggestion look reasonable?

Oriol, if you want to do this feel free to take it (and 1378647).  I'd just like to get it done so we can land 1422588 and at the same time (fx version) have a solution for the use case.
Flags: needinfo?(dao+bmo)
Comment on attachment 8979634 [details] [diff] [review]
WIP tabState

I'm going a different direction with this.
Attachment #8979634 - Attachment is obsolete: true
Flags: needinfo?(dao+bmo)
I'm actually going to close this.  I don't want to mess with setting tabstate in addTab as that is called from sessionstore.  It works fine to deal with the nuances from the extension api for bug 1378647
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
I wasn't thinking about webextensions when I filed this, I think this might have uses outside them. It feels wrong to have a broken parameter that needs to be fixed by the caller.

I needed this kind of thing for bug 1521346, so I did it there.
Now this code loads http://example.com/ instead of an empty tab:

gBrowser.selectedTab = gBrowser.addTab('http://example.com/', {
  createLazyBrowser: true,
  triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
  allowInheritPrincipal: true,
});

Edit: allowInheritPrincipal: true was a hack, the proper way was skipLoad: true, which bug 1808615 sets automatically when using createLazyBrowser: true.

Assignee: mixedpuppy → oriol-bugzilla
Depends on: 1521346
Resolution: INVALID → FIXED
Blocks: 1529411
Flags: qe-verify+

Confirmed the issue with Firefox 66.0.3 on Windows 10.
Fix verified with 67.0b11 on Windows 10 and Ubuntu 16.04 and 68.0a1 (2019-04-17) on macOS 10.13.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: