postMessage API not always working

Hi,

I wanted to use Collabora Online in 2 different scenarios:
a) in a (WASM) browser app
b) in a WebView2 component of a .NET desktop app

Both scenarios

  • consume the same (simple) HTML which holds the iframe referencing the WOPISrc URL
  • where the JavaScript glue code waits until App_LoadingStatus with Status='Initialized' before firing a postMessage event
  • and the postMessage event simply hides a button in the toolbar (just for testing purposes, the effect is the same for any other postMessage event

I’m aware of the PostMessageOrigin parameter in the CheckFileInfo call which I have not set at this time.

Result:

  • in scenario a the toolbar button is hidden → good
  • in scenario b the toolbar button is not hidden, postMessage events have not effect at all → bad

I tried to set the PostMessageOrigin parameter on the CheckFileInfo call to https:<my-domain> where my-domain is the same domain is with the WOPISrc parameter, but this only made scenario a stop working as wellbad.

What am I doing wrong? Any hint would be appreciated.

Hii @DierkDroth

Regarding your issue:

  • Scenario A (WASM app) works because the postMessage API is fully supported in a standard browser environment, and the origin aligns as expected.
  • Scenario B (WebView2) fails likely because window.postMessage behaves differently or is restricted in embedded browser environments. WebView2 may impose limitations on cross-origin messaging or lack proper origin propagation, especially if sandboxing or security flags are involved.

Also, the PostMessageOrigin parameter in the CheckFileInfo response must exactly match the origin of the embedding page (as seen by the iframe). If set incorrectly, it will block all postMessages which explains why scenario A stopped working when you added it.

To proceed:

  • Confirm that the origin your .NET WebView2 host uses exactly matches the PostMessageOrigin string (scheme, host, port).
  • Use DevTools (F12) in the embedded WebView2 if possible, or log window.origin from within the host page and the iframe to compare.
  • Try running the same HTML with an embedded iframe outside the app but served from the same local server to verify if it’s an origin issue.

That said I must say, you’re doing some really great hacking and integration work with Collabora Online! It’s exciting to see how deeply you’re exploring its capabilities.

However, please note that our public support channels are limited in scope. If you have urgent requirements or need faster assistance, I’d recommend considering our customer support or partner programs they can offer more direct help and faster turnaround for advanced use cases like yours.

or you can also mail to get more information : hello@collabora.com

Thanks again and keep up the awesome work!

Darshan