MCPcopy
hub / github.com/ampproject/amphtml / sendMessage

Method sendMessage

3p/iframe-messaging-client.js:118–139  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 14

getDataMethod · 0.95
makeRequestMethod · 0.95
requestOnceMethod · 0.95
requestResizeMethod · 0.45
signalInteractiveMethod · 0.45
noContentAvailableMethod · 0.45
report3pErrorMethod · 0.45
bootstrapLoadedMethod · 0.45
renderStartMethod · 0.45

Calls 4

sendMessageInternal_Method · 0.95
serializeMessageFunction · 0.90
devFunction · 0.90
assertStringMethod · 0.80

Tested by

no test coverage detected