chronakis / firefox-sticky-window-containers

Firefox extention to make the current container "sticky" when opening a new tab
Mozilla Public License 2.0
37 stars 8 forks source link

Stop new tabs from closing automatically #4

Closed DouweM closed 4 years ago

DouweM commented 4 years ago

When a new tab is opened with URL about:newtab (aka "Firefox Home (Default)") and SWC is triggered, both tab.url and details.url are set to about:newtab, which leads to openInDifferentContainer being called with urlOverride about:newtab, and browser.tabs.create with url: 'about:newtab' (despite the blankPages.has(url) check), leading to an Illegal URL: about:newtab error, and the originally opened tab closing, without a new tab opening to replace it.

For reasons unclear to me, opening a new tab does not consistently trigger SWC--the Browser Console doesn't always show an onBeforeNavigate log message-- but when it does, this behavior shows consistently.

DouweM commented 4 years ago

@chronakis Thanks for creating this extension! I enjoy it every day, but unfortunately keep running into a bug. Can you please check out this PR to (hopefully) fix it? Thanks!

chronakis commented 4 years ago

Hi @DouweM , thank you very much for your patch!

Please give me a couple of days to get back into the context and try to accept the PR and get a new release out.

chronakis commented 4 years ago

Hi @DouweM ,

Your fix works great, thanks!

For reasons unclear to me, opening a new tab does not consistently trigger SWC--the Browser Console doesn't always show an onBeforeNavigate log message-- but when it does, this behavior shows consistently.

I have been very puzzled myself about the newtab page and why some people had the problem and I could not reproduce it. I finally discovered that this settings makes the difference.

When "New tabs" is set to "Firefox home (default)", opening a new tab does not generate the OnBeforeNavigate event. Page Info shows that the page URL is clearly "about:newtab" but it is unclear how it got there.

On the other hand, when it is set to "Blank page", it generated the OnBeforeNavigate event with the known consequences that your patch fixes.

In any case, I am merging your pull request and making a release tonight.

Many thanks!

Yiannis

DouweM commented 4 years ago

In any case, I am merging your pull request and making a release tonight.

@chronakis Awesome, thank you!

When "New tabs" is set to "Firefox home (default)", opening a new tab does not generate the OnBeforeNavigate event. Page Info shows that the page URL is clearly "about:newtab" but it is unclear how it got there.

On the other hand, when it is set to "Blank page", it generated the OnBeforeNavigate event with the known consequences that your patch fixes.

I'm not sure it's that simple. I actually have the setting set to "Firefox Home (Default)", but keep running into this bug. As I wrote, the OnBeforeNavigate event seems to be triggered only some of the times I create a new tab (usually using the Cmd+T shortcut). When it does, the bug triggers and the tab auto-closes. When it doesn't, it opens and I can use it without issue.

I haven't been able to figure out what determined whether or not the event would trigger; usually when opening a new tab using Cmd+Tab fails, I just hit the shortcut a couple more times until finally a new tab "sticks" because it didn't trigger the OnBeforeNavigate event. One or two more tries usually do the trick.

I haven't yet gone so far as look at the Firefox source code to figure this one out, but I'm tempted 😃

In any case, this fix should stop the auto-closing so I'm happy!

Thanks for the merge and all the best in these crazy times.