browser-run icon indicating copy to clipboard operation
browser-run copied to clipboard

Hangs in FF. running window.close() won't finish process

Open naugtur opened this issue 9 years ago • 11 comments

FF just says

Scripts may not close windows that were not opened by script.

and wouldn't close.

Env: linux with FF 49.0

Also noticed a tab with sessionrestore whenever I browser-run FF more than once.

naugtur avatar Nov 04 '16 11:11 naugtur

Do you have a suggestion how to fix this?

juliangruber avatar Nov 07 '16 11:11 juliangruber

I hoped for "oh it's ajust a minor regression"

But there might be a command line switch that would disable the security restriction on window.close

naugtur avatar Nov 07 '16 12:11 naugtur

@juliangruber I have two fixes for this.

  1. run-browser uses tap-finished. I made a PoC a change that'd add an option to use it. Not sure what your userbase uses for testing.
  2. add an option to define that if there's no console output for a certain number of miliseconds, tests should be considered done.

I can PR both solutions, but I'd rather know which will get accepted before I do ;)

For both solutions I didn't check if browser.kill() is available in all launchers, but there must be a way to kill a process.

naugtur avatar Nov 12 '16 15:11 naugtur

Ah, so you're using this through tape-run?

juliangruber avatar Nov 13 '16 13:11 juliangruber

I'm piping browserify output (or webpack in other repo) to browser-run and then to tap-spec

What I'm hoping to get here is if this is the popular way browser-run is used for testing or not. The timeout option would work with anything that produces output

naugtur avatar Nov 13 '16 14:11 naugtur

I guess we can just add another timeout that will kill the browser child_process if window.close() fails

juliangruber avatar Nov 13 '16 15:11 juliangruber

One more idea - if browser-run prints pid of the browser in the first line, an external tool could easily kill the browser based on the output.

naugtur avatar Nov 13 '16 15:11 naugtur

Hi - I use tape and browser-run. (I like to use the minimum amount of framework when possible). I would love to see a --close-after-tap (or similar) that shuts down the browser based on tap tests finishing as well.

mvoss9000 avatar Jan 12 '17 13:01 mvoss9000

I could implement that, but it seems like something more generic would be nice... Maybe not just tap, but a 'safeword' anyone could use to finish by console.logging it...

I'll probably have to figure it out some time this month anyway :)

naugtur avatar Feb 05 '17 10:02 naugtur

Sounds good. look forward to it!

mvoss9000 avatar Feb 06 '17 06:02 mvoss9000

@mvoss9000 @juliangruber I added a PR for tap-finish

I see following options to move it forward:

  • leave as is, for tap support only
  • add an additional option to kill the browser if no output was printed for configurable number of miliseconds
  • replace this with just the timeout to avoid a dependency

naugtur avatar Feb 17 '17 12:02 naugtur