Fix race condition in connectToParentWindow.
Fix race condition in connectToParentWindow.

Previously there was time for a snapshot to come in after the "hello"
was sent but before the onmessage listener was attached. By moving the
channel create into the setImmediate callback we can avoid this, and
also unify code between the cases.

mcanthony/tracing-framework,dockbiz/tracing-framework,dockbiz/tracing-framework,looker/tracing-framework,lollerbus/tracing-framework,google/tracing-framework,looker/tracing-framework,mcanthony/tracing-framework,dockbiz/tracing-framework,vinodpanicker/tracing-framework,vinodpanicker/tracing-framework,mcanthony/tracing-framework,lollerbus/tracing-framework,lollerbus/tracing-framework,vinodpanicker/tracing-framework,google/tracing-framework,vinodpanicker/tracing-framework,mcanthony/tracing-framework,lollerbus/tracing-framework,looker/tracing-framework,dockbiz/tracing-framework,looker/tracing-framework,feisuo/tracing-framework,google/tracing-framework,feisuo/tracing-framework,feisuo/tracing-framework,feisuo/tracing-framework,google/tracing-framework