Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content script does not receive events from background page when page is preloaded by "Safari top hit" #159

ameshkov opened this issue Feb 3, 2016 · 1 comment


None yet
1 participant
Copy link

commented Feb 3, 2016

Safari may preload webpages in the background to improve the user experience. Therefore, it is possible for each tab to be associated with more than one webpage, some of which are hidden from the user.

When dispatching messages to the page property of SafariBrowserTab objects, Safari dispatches your message to all pages associated with that tab, including pages not visible to the user. Updating the UI of a non-visible page impacts battery life and does not benefit the user. If your extension updates the UI of the page, first ensure that the page is visible to avoid executing code on hidden webpages.

You ensure the current page is visible by using the Page Visibility API. Query that document.hidden is false before running code on the webpage. Also listen for the visibilitychange JavaScript event to determine whether the visibility of the page has changed.

@ameshkov ameshkov self-assigned this Feb 3, 2016

@ameshkov ameshkov added this to the 2.1 milestone Feb 3, 2016

adguard pushed a commit that referenced this issue Feb 3, 2016


This comment has been minimized.

Copy link
Member Author

commented Feb 3, 2016

Fixed, we now check "document.hidden" in case of Safari.

@ameshkov ameshkov closed this Feb 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.