* Send a postMessage to Host Window, or all parent windows if host window is * not set. * @param {string} type The type of message to send. * @param {JsonObject=} opt_payload The payload of message to send.
(type, opt_payload)
| 116 | * @param {JsonObject=} opt_payload The payload of message to send. |
| 117 | */ |
| 118 | sendMessage(type, opt_payload) { |
| 119 | const msg = serializeMessage( |
| 120 | type, |
| 121 | dev().assertString(this.sentinel_), |
| 122 | opt_payload, |
| 123 | this.rtvVersion_ |
| 124 | ); |
| 125 | |
| 126 | if (!this.hostWindow_) { |
| 127 | for ( |
| 128 | let j = 0, hostWin = this.win_; |
| 129 | j < 10 && hostWin != this.win_.top; |
| 130 | j++ |
| 131 | ) { |
| 132 | hostWin = hostWin.parent; |
| 133 | this.sendMessageInternal_(hostWin, msg); |
| 134 | j++; |
| 135 | } |
| 136 | } else { |
| 137 | this.sendMessageInternal_(this.hostWindow_, msg); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * @param {!Window} win |
no test coverage detected