Re-land fix for unload/beforeunload events

The implementation code change compared to last time is fixes a stack overflow in the BeforeUnloadEvent polyfill, which the new test is hitting. This affected Safari which doesn't have a native BeforeUnloadEvent yet.

The test has several fixes for IE 10/11. IE had two different problems: e.target is window vs document in others, and the unload event won't fire in an iframe unless we setTimeout(0) before adding the handler.

This fixes https://github.com/Polymer/platform/issues/83

@kegluneq @arv mind taking another look?

BeforeUnloadEvent calls super here:
https://github.com/Polymer/ShadowDOM/blob/master/src/wrappers/events.js#L641

so we need to check that to prevent a stack overflow