Safari firing 2 focus events when I change tabs

I’ve been having some problems with Safari’s focus events. I noticed that Safari fires 2 focus events when I switch between tabs, and chrome only fires one. Why is this the case? Is it because Safari treats a “tab” and a “window” as separate events?

When I click out of the window and click back again, only one focus event is fired.
Do help!

This is the code that I wrote in the developer tools console to track the firing of focus events:

let counter = 0
window.addEventListener("focus", () => {
  counter++;
  console.log(`focus ${counter}`)
})

Then, just click on a new tab and return to this tab and you should see the logged messages.