Your test is nearly identical to what modernizr does. :)