improve the setImmediate/requestAnimationFrame detection

add a test the spec to verify the behavior and a browser test runner
to ensure the browser behavior works properly