(iframe, targets, type, object, opt_is3P)
| 372 | * @param {boolean=} opt_is3P set to true if the iframe is 3p. |
| 373 | */ |
| 374 | export function postMessageToWindows(iframe, targets, type, object, opt_is3P) { |
| 375 | if (!iframe.contentWindow) { |
| 376 | return; |
| 377 | } |
| 378 | object['type'] = type; |
| 379 | object['sentinel'] = getSentinel_(iframe, opt_is3P); |
| 380 | let payload = object; |
| 381 | if (opt_is3P) { |
| 382 | // Serialize ourselves because that is much faster in Chrome. |
| 383 | payload = 'amp-' + JSON.stringify(object); |
| 384 | } |
| 385 | for (let i = 0; i < targets.length; i++) { |
| 386 | const target = targets[i]; |
| 387 | target.win./*OK*/ postMessage(payload, target.origin); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | /** |
| 392 | * Gets the sentinel string. |
no test coverage detected