Make the window.onerror test more resilient to old browsers

Check the number of arguments passed to window.onerror before
asserting the value of the argument.