element-web/playwright/sample-files/fake-element-call-with-send.html
Valere Fedronic 3f472c8812
Some checks failed
Static Analysis / Workflow Lint (push) Has been cancelled
Static Analysis / Analyse Dead Code (push) Has been cancelled
Build / Build on macos-14 (push) Has been cancelled
Build / Build on ubuntu-24.04 (push) Has been cancelled
Build / Build on windows-2022 (push) Has been cancelled
Build and Deploy develop / Build & Deploy develop.element.io (push) Has been cancelled
Deploy documentation / GitHub Pages (push) Has been cancelled
Shared Component Visual Tests / Run Visual Tests (push) Has been cancelled
Static Analysis / Typescript Syntax Check (push) Has been cancelled
Static Analysis / i18n Check (push) Has been cancelled
Static Analysis / Rethemendex Check (push) Has been cancelled
Static Analysis / ESLint (push) Has been cancelled
Static Analysis / Style Lint (push) Has been cancelled
Deploy documentation / deploy (push) Has been cancelled
Fix: WidgetMessaging not properly closed causing side effects and bugs (#31598)
* test: Add a failing test reproducing the multi messaging leak bug

* fix: Missing widgetApi stop causing leaks
2025-12-24 09:23:04 +00:00

53 lines
1.5 KiB
HTML

<!doctype html>
<style>
body {
background: rgb(139, 192, 253);
}
</style>
<!-- element-call.spec.ts will insert the widget API in this block -->
<script>
widgetCodeHere;
</script>
<div>
<p>Fake Element Call</p>
<p>State: <span id="state">Loading</span></p>
<button id="send-button">Send Room Message</button>
</div>
<!-- Minimal fake implementation of Element Call. Just enough for testing the leagkin widgets.-->
<script>
const stateIndicator = document.querySelector("#state");
const { WidgetApi, WidgetApiToWidgetAction, MatrixCapabilities } = mxwidgets();
const widgetId = new URLSearchParams(window.location.search).get("widgetId");
const params = new URLSearchParams(window.location.hash.slice(1));
const roomId = params.get("roomId");
const api = new WidgetApi(widgetId, "*");
document.querySelector("#send-button").onclick = async () => {
await api.sendRoomEvent(
"m.room.message",
{ msgtype: "m.text", body: "I sent this once!!" },
roomId,
undefined,
undefined,
undefined,
);
};
api.requestCapability(MatrixCapabilities.AlwaysOnScreen);
api.requestCapability(`org.matrix.msc2762.timeline:${roomId}`);
api.requestCapabilityToSendMessage("m.text");
api.on("ready", (ev) => {
stateIndicator.innerHTML = "Ready";
});
// Start the messaging
api.start();
// If waitForIframeLoad is false, tell the client that we're good to go
api.sendContentLoaded();
</script>