MCPcopy
hub / github.com/mailvelope/mailvelope / postMessage

Method postMessage

test/integration/__mocks__/chrome-api-setup.js:59–75  ·  view source on GitHub ↗

* Send a message to the other end of the port * @param {any} message - The message to send (should be JSON-ifiable)

(message)

Source from the content-addressed store, hash-verified

57 * @param {any} message - The message to send (should be JSON-ifiable)
58 */
59 postMessage(message) {
60 if (!this._isConnected) {
61 throw new Error('Attempting to use a disconnected port object');
62 }
63
64 if (this._otherPort?._isConnected) {
65 // Clone the message to simulate serialization
66 const clonedMessage = JSON.parse(JSON.stringify(message));
67
68 // Asynchronously deliver the message to simulate real behavior
69 setTimeout(async () => {
70 if (this._otherPort?._isConnected) {
71 await this._otherPort._triggerMessageEvent(clonedMessage, this);
72 }
73 }, 0);
74 }
75 }
76
77 /**
78 * Disconnect the port

Callers 5

setupEditorFunction · 0.45
editor.test.jsFile · 0.45

Calls 1

_triggerMessageEventMethod · 0.45

Tested by 2

setupEditorFunction · 0.36