You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: make the primary domain communicator a singleton per cypress instance (#20653)
* fix: make the primary domain communicator a singleton per cypress instance
* leverage a factory to make typescript happy with their super() constructor rules
* remove singleton instance from communicator and only bind message events once in the primary and per spec bridge. Forward all message events to the respective communicator instance, if available.
* remove data.actual reference in primary communicator onMessage as it is no longer needed
* Initializes the event handler to receive messages from the spec bridge.
28
-
* @param {Window} win - a reference to the window object in the primary domain.
26
+
* The callback handler that receives messages from secondary domains.
27
+
* @param {MessageEvent.data} data - a reference to the MessageEvent.data sent through the postMessage event. See https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
28
+
* @param {MessageEvent.source} source - a reference to the MessageEvent.source sent through the postMessage event. See https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/source
@@ -164,20 +153,14 @@ export class SpecBridgeDomainCommunicator extends EventEmitter {
164
153
}
165
154
166
155
/**
167
-
* Initializes the event handler to receive messages from the primary domain.
168
-
* @param {Window} win - a reference to the window object in the spec bridge/iframe.
156
+
* The callback handler that receives messages from the primary domain.
157
+
* @param {MessageEvent.data} data - a reference to the MessageEvent.data sent through the postMessage event. See https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
169
158
* @returns {Void}
170
159
*/
171
-
initialize(win){
172
-
if(this.windowReference)return
173
-
174
-
this.windowReference=win
175
-
176
-
this.windowReference.addEventListener('message',({ data })=>{
177
-
if(!data)return
160
+
onMessage({ data }){
161
+
if(!data)return
178
162
179
-
this.emit(data.event,data.data)
180
-
},false)
163
+
this.emit(data.event,data.data)
181
164
}
182
165
183
166
/**
@@ -190,7 +173,7 @@ export class SpecBridgeDomainCommunicator extends EventEmitter {
0 commit comments