ueokande / vim-vixen

Accelerates your web browsing with Vim power!!
https://ueokande.github.io/vim-vixen/
MIT License
2.11k stars 138 forks source link

Opening a new tab from a tab with popups allowed does not activate the new tab #634

Open dadrc opened 5 years ago

dadrc commented 5 years ago

I'm opening this issue because:

Description

When opening a new tab (using the t binding), Firefox switches to that tab. This feature does not work as expected if the website in the old tab has been granted the permission to open popup windows. The new tab is instead created in the background, the old tab remains active.

Steps to Reproduce

  1. Open any website in a tab and create a popup blocker exception for that website via about:preferences#privacy
  2. Use t to open any other website.

Actual result: The website will be opened in a new tab, but the tab will not be activated. Expected result: The website will be opened in a new tab and the new tab will be activated.

System configuration

Console logs

No output in the console is available.

JudgeGregg commented 5 years ago

I've investigated a bit and it seems to be linked to a Promise resolving too late:

You can reproduce it with any tab by putting a breakpoint in console.ts line 53 (return hideCommand()) The tab will then open in the background, and the current tab will keep focus.

Also if you return null in the enterCommand, the problem will go away (for a tab with pop ups allowed for example)

const enterCommand = async(
  text: string,
): Promise<any>=> {
  await browser.runtime.sendMessage({
    type: messages.CONSOLE_ENTER_COMMAND,
    text,
  });
  return null
};

Finally we see that the function onSelected from tabPresenter is called one more time when the "bug" occurs. I think that the Promise resolving late triggers a focus on the previous tab, skipping the new tab.

I have no idea why a tab with allowed popups would take longer to resolve that Promise though..

Thank you for your work on vim-vixen.

System configuration

Operating system: Arch Linux
Firefox version: 69.0.1
Vim-Vixen version: 0.25

Console logs

No output in the console is available.