Added support for passing in the window object directly

Updates code to check for `contentWindow` so we can pass in a window object directly.

This adds support for talking to windows opened by `window.open` as it returns a reference to the child's window object.