karma-runner/karma-safari-launcher

Tests do not run when Safari window is not in the foreground

murrayju opened this issue · 5 comments

macOS Sierra 10.12.4
Safari 10.1 (12603.1.30.0.34)

I have my karma tests running on Chrome, Firefox, and Safari. Generally, I have a full-screen terminal window where I start the tests from, so the browsers are launched in the background (on a separate "desktop"). Chrome and Firefox both complete the tests quickly with no issue, but Safari just hangs out not doing anything. The tests will not run until I switch desktops and bring Safari into the foreground (unclear if it has to be focused), at which point the tests then quickly complete.

I've looked through all of the Safari preferences, and tried disabling the "Stop plug-ins to save power" option with no success. I also tried globally disabling the OSX "App Nap" feature (which doesn't seem to include Safari anyways).

If there is any sort of workaround for this, it would be great if karma-safari-launcher could turn it on automatically :)

Would using any of these options with the open command resolve the issue?:

  • --wait-apps
  • --new
  • --fresh
  • -a

Any movement on this? I noticed this happening today

Same problem here. Tests won't run in Safari unless I select it as the foreground app

Safari by default throttles background tabs which causes issues with Karma. To get around this, you can enable a debug menu by going to your terminal and executing

defaults write com.apple.Safari IncludeInternalDebugMenu 1

(More info can be found at https://www.defaults-write.com/enable-the-safari-debug-menu/)

Then if you restart Safari, you will then see a debug menu. In the debug menu, go to "Miscellaneous flags" and check "Disable Hidden Page Timer Throttling"

I do not know how to automate this yet.

Disabling App Nap in the Miscellaneous flags also helps since Safari will start to limit connections on idle tabs. It then causes disconnections from the Karma server.