juliangruber / browser-run

Run code inside a browser from the command line
447 stars 62 forks source link

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

Open naugtur opened 8 years ago

naugtur commented 8 years ago

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.

juliangruber commented 8 years ago

Do you have a suggestion how to fix this?

naugtur commented 8 years ago

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 commented 7 years ago

@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.

juliangruber commented 7 years ago

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

naugtur commented 7 years ago

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

juliangruber commented 7 years ago

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

naugtur commented 7 years ago

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.

mvoss9000 commented 7 years ago

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.

naugtur commented 7 years ago

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 :)

mvoss9000 commented 7 years ago

Sounds good. look forward to it!

naugtur commented 7 years ago

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

I see following options to move it forward: