# postMessage API not always working

**URL:** <https://forum.collaboraonline.com/t/postmessage-api-not-always-working/3884>\
**Category:** Installation & Configuration\
**Created:** [July 14, 2025, 8:57am UTC](https://forum.collaboraonline.com/t/postmessage-api-not-always-working/3884 "2025-07-14T08:57:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DierkDroth](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@DierkDroth](https://forum.collaboraonline.com/u/DierkDroth)\
**Post date:** [July 14, 2025, 8:57am UTC](https://forum.collaboraonline.com/t/postmessage-api-not-always-working/3884/1 "2025-07-14T08:57:03Z")

</div>

Hi,

I wanted to use Collabora Online in 2 different scenarios:  
a) in a ([WASM](https://de.wikipedia.org/wiki/WebAssembly)) browser app  
b) in a [WebView2](https://developer.microsoft.com/de-de/microsoft-edge/webview2?form=MA13LH) 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='Document_Loaded'` 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 well** → **bad**.

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

---

<div class="post-metadata">

**Author:** ![darshan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/darshan/32/2230_2.png) [@darshan](https://forum.collaboraonline.com/u/darshan)\
**Post date:** [July 14, 2025, 1:13pm UTC](https://forum.collaboraonline.com/t/postmessage-api-not-always-working/3884/2 "2025-07-14T13:13:52Z")

</div>

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.

> **[Contact Us](https://www.collaboraonline.com/contact-us/)**
>
> Contact Us Get more information If you have any general questions or comments, complete the contact form and we’ll aim to get back to you within 3 working days. For a faster reply, please use one of the useful links. Demo Try out the FREE demo Get a...

> **[Engineering Support](https://www.collaboraonline.com/engineering-support/)**
>
> Collabora Online offers a range of business benefits that make it a real and attractive alternative to other big-brand office document solutions. We recognise how important office document software is to most organisations. It is generally the most...

or you can also mail to get more information : [hello@collabora.com](mailto:hello@collabora.com)

Thanks again and keep up the awesome work!

Darshan

---

<div class="post-metadata">

**Author:** ![DierkDroth](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@DierkDroth](https://forum.collaboraonline.com/u/DierkDroth)\
**Post date:** [July 15, 2025, 5:19am UTC](https://forum.collaboraonline.com/t/postmessage-api-not-always-working/3884/3 "2025-07-15T05:19:11Z")

</div>

Thanks for your feedback @darshan.

I printed out the value of `window.location.origin` in my simple HTML which hosts the iframe. Results:

- scenario a: `window.location.origin=null` → likely does not help
- scenario b: `window.location.origin=http://localhost:59516` (this is my debugging setup) → as I set this in `PostMessageOrigin` on `CheckFileInfo` I again am experiencing that `postMessage` stops working

I have a suspicion that the `PostMessageOrigin` concept might not be prepared for my scenarios and in fact is a road block for scenario a.

Would you have any thoughts?

Also: I will contact the Collabora team, since I needed to get resolved the issues I came across on my pass #1 on integrating Collabora Online.

---

<div class="post-metadata">

**Author:** ![darshan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/darshan/32/2230_2.png) [@darshan](https://forum.collaboraonline.com/u/darshan)\
**Post date:** [July 15, 2025, 1:43pm UTC](https://forum.collaboraonline.com/t/postmessage-api-not-always-working/3884/4 "2025-07-15T13:43:32Z")

</div>

Closed on July 15, 2025, 1:43pm UTC



---

<div class="post-metadata">

**Author:** ![darshan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/darshan/32/2230_2.png) [@darshan](https://forum.collaboraonline.com/u/darshan)\
**Post date:** [July 24, 2025, 11:30am UTC](https://forum.collaboraonline.com/t/postmessage-api-not-always-working/3884/5 "2025-07-24T11:30:29Z")

</div>

Opened on July 24, 2025, 11:30am UTC


