From 914c106e20c0d2a702b966a660198b2f8d5a4576 Mon Sep 17 00:00:00 2001 From: Zach Clendenen Date: Mon, 28 Sep 2026 19:18:29 -0500 Subject: [PATCH 1/4] fix(streaming): let the webstation frame use camera and microphone The room asks for the webcam and mic with getUserMedia, but the player frame never delegated either, so multiplayer voice and webcam were refused even with browser permission granted. Fixes #4906 --- .../v2/components/Player/StreamStage.test.ts | 22 +++++++++++++++++++ .../src/v2/components/Player/StreamStage.vue | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/frontend/src/v2/components/Player/StreamStage.test.ts b/frontend/src/v2/components/Player/StreamStage.test.ts index eb29d125a..6fcb01509 100644 --- a/frontend/src/v2/components/Player/StreamStage.test.ts +++ b/frontend/src/v2/components/Player/StreamStage.test.ts @@ -30,4 +30,26 @@ describe("StreamStage", () => { .attributes("sandbox"); expect(sandbox).not.toContain("allow-top-navigation"); }); + + it.each(["gamepad", "fullscreen", "autoplay", "camera", "microphone"])( + "delegates %s to the container", + (feature) => { + const allow = mountStage("http://box:3010/room") + .find("iframe") + .attributes("allow"); + expect(allow).toContain(`${feature} *`); + }, + ); + + // An opaque origin gets no media permission, so the room's webcam and mic + // need the container to keep its own origin. + it.each(["allow-scripts", "allow-same-origin"])( + "keeps %s so the room can run and ask for media", + (flag) => { + const sandbox = mountStage("http://box:3010/room") + .find("iframe") + .attributes("sandbox"); + expect(sandbox).toContain(flag); + }, + ); }); diff --git a/frontend/src/v2/components/Player/StreamStage.vue b/frontend/src/v2/components/Player/StreamStage.vue index 7bad463d6..4070eac14 100644 --- a/frontend/src/v2/components/Player/StreamStage.vue +++ b/frontend/src/v2/components/Player/StreamStage.vue @@ -304,7 +304,7 @@ defineExpose({ ref="streamFrame" :src="frameSrc" class="r-v2-stage__frame" - allow="gamepad *; fullscreen *; autoplay *" + allow="gamepad *; fullscreen *; autoplay *; camera *; microphone *" allowfullscreen referrerpolicy="no-referrer" sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-pointer-lock allow-downloads" From 10b07e79f0c8e225ffd035bc0a6f155682362ace Mon Sep 17 00:00:00 2001 From: Zach Clendenen Date: Mon, 28 Sep 2026 19:25:52 -0500 Subject: [PATCH 2/4] fix(streaming): delegate clipboard-write and tighten frame tests (code-review) The room's invite button copies with navigator.clipboard, which a cross-origin frame is refused for the same reason as camera and mic. Tests now compare whole directives and unmount between cases. --- .../v2/components/Player/StreamStage.test.ts | 46 +++++++++++-------- .../src/v2/components/Player/StreamStage.vue | 9 +++- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/frontend/src/v2/components/Player/StreamStage.test.ts b/frontend/src/v2/components/Player/StreamStage.test.ts index 6fcb01509..d3603fcf4 100644 --- a/frontend/src/v2/components/Player/StreamStage.test.ts +++ b/frontend/src/v2/components/Player/StreamStage.test.ts @@ -1,7 +1,11 @@ -import { mount } from "@vue/test-utils"; -import { describe, expect, it } from "vitest"; +import { enableAutoUnmount, mount } from "@vue/test-utils"; +import { afterEach, describe, expect, it } from "vitest"; import StreamStage from "./StreamStage.vue"; +// The stage listens on window and runs attach timers, so a mount left standing +// would answer the next test's events. +enableAutoUnmount(afterEach); + function mountStage(src: string) { return mount(StreamStage, { props: { src, frameTitle: "Stream" }, @@ -9,6 +13,12 @@ function mountStage(src: string) { }); } +function frameAttr(name: string): string { + return ( + mountStage("http://box:3010/room").find("iframe").attributes(name) ?? "" + ); +} + describe("StreamStage", () => { it("renders a container URL the broker answered with", () => { const wrapper = mountStage("http://192.168.1.10:3000/streaming/room/abc"); @@ -25,31 +35,29 @@ describe("StreamStage", () => { ); it("does not let the container steer the tab it sits in", () => { - const sandbox = mountStage("http://box:3010/room") - .find("iframe") - .attributes("sandbox"); - expect(sandbox).not.toContain("allow-top-navigation"); + expect(frameAttr("sandbox")).not.toContain("allow-top-navigation"); }); - it.each(["gamepad", "fullscreen", "autoplay", "camera", "microphone"])( - "delegates %s to the container", - (feature) => { - const allow = mountStage("http://box:3010/room") - .find("iframe") - .attributes("allow"); - expect(allow).toContain(`${feature} *`); - }, - ); + it.each([ + "gamepad", + "fullscreen", + "autoplay", + "camera", + "microphone", + "clipboard-write", + ])("delegates %s to the container", (feature) => { + const directives = frameAttr("allow") + .split(";") + .map((d) => d.trim()); + expect(directives).toContain(`${feature} *`); + }); // An opaque origin gets no media permission, so the room's webcam and mic // need the container to keep its own origin. it.each(["allow-scripts", "allow-same-origin"])( "keeps %s so the room can run and ask for media", (flag) => { - const sandbox = mountStage("http://box:3010/room") - .find("iframe") - .attributes("sandbox"); - expect(sandbox).toContain(flag); + expect(frameAttr("sandbox").split(/\s+/)).toContain(flag); }, ); }); diff --git a/frontend/src/v2/components/Player/StreamStage.vue b/frontend/src/v2/components/Player/StreamStage.vue index 4070eac14..f2abcf124 100644 --- a/frontend/src/v2/components/Player/StreamStage.vue +++ b/frontend/src/v2/components/Player/StreamStage.vue @@ -304,7 +304,14 @@ defineExpose({ ref="streamFrame" :src="frameSrc" class="r-v2-stage__frame" - allow="gamepad *; fullscreen *; autoplay *; camera *; microphone *" + allow=" + gamepad *; + fullscreen *; + autoplay *; + camera *; + microphone *; + clipboard-write *; + " allowfullscreen referrerpolicy="no-referrer" sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-pointer-lock allow-downloads" From bb17fbaa984aae49684abb570c06fc07a2bd1441 Mon Sep 17 00:00:00 2001 From: Zach Clendenen Date: Mon, 28 Sep 2026 19:27:56 -0500 Subject: [PATCH 3/4] test(streaming): read the frame's static attributes once (simplify) --- .../v2/components/Player/StreamStage.test.ts | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/frontend/src/v2/components/Player/StreamStage.test.ts b/frontend/src/v2/components/Player/StreamStage.test.ts index d3603fcf4..38f6cdfa1 100644 --- a/frontend/src/v2/components/Player/StreamStage.test.ts +++ b/frontend/src/v2/components/Player/StreamStage.test.ts @@ -1,5 +1,5 @@ import { enableAutoUnmount, mount } from "@vue/test-utils"; -import { afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeAll, describe, expect, it } from "vitest"; import StreamStage from "./StreamStage.vue"; // The stage listens on window and runs attach timers, so a mount left standing @@ -13,13 +13,17 @@ function mountStage(src: string) { }); } -function frameAttr(name: string): string { - return ( - mountStage("http://box:3010/room").find("iframe").attributes(name) ?? "" - ); -} - describe("StreamStage", () => { + // The frame's allow and sandbox lists are static, so one mount serves every + // case that reads them. + let allow: string[] = []; + let sandbox: string[] = []; + beforeAll(() => { + const frame = mountStage("http://box:3010/room").find("iframe"); + allow = (frame.attributes("allow") ?? "").split(";").map((d) => d.trim()); + sandbox = (frame.attributes("sandbox") ?? "").split(/\s+/); + }); + it("renders a container URL the broker answered with", () => { const wrapper = mountStage("http://192.168.1.10:3000/streaming/room/abc"); expect(wrapper.find("iframe").attributes("src")).toBe( @@ -35,7 +39,7 @@ describe("StreamStage", () => { ); it("does not let the container steer the tab it sits in", () => { - expect(frameAttr("sandbox")).not.toContain("allow-top-navigation"); + expect(sandbox.join(" ")).not.toContain("allow-top-navigation"); }); it.each([ @@ -46,10 +50,7 @@ describe("StreamStage", () => { "microphone", "clipboard-write", ])("delegates %s to the container", (feature) => { - const directives = frameAttr("allow") - .split(";") - .map((d) => d.trim()); - expect(directives).toContain(`${feature} *`); + expect(allow).toContain(`${feature} *`); }); // An opaque origin gets no media permission, so the room's webcam and mic @@ -57,7 +58,7 @@ describe("StreamStage", () => { it.each(["allow-scripts", "allow-same-origin"])( "keeps %s so the room can run and ask for media", (flag) => { - expect(frameAttr("sandbox").split(/\s+/)).toContain(flag); + expect(sandbox).toContain(flag); }, ); }); From 78443fecc184b2eaeadee9b7514f852f7f2d8f84 Mon Sep 17 00:00:00 2001 From: Zach Clendenen Date: Mon, 28 Sep 2026 19:34:28 -0500 Subject: [PATCH 4/4] test(streaming): drop a comment restating the setup (review-polish) --- frontend/src/v2/components/Player/StreamStage.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/v2/components/Player/StreamStage.test.ts b/frontend/src/v2/components/Player/StreamStage.test.ts index 38f6cdfa1..614299268 100644 --- a/frontend/src/v2/components/Player/StreamStage.test.ts +++ b/frontend/src/v2/components/Player/StreamStage.test.ts @@ -14,8 +14,6 @@ function mountStage(src: string) { } describe("StreamStage", () => { - // The frame's allow and sandbox lists are static, so one mount serves every - // case that reads them. let allow: string[] = []; let sandbox: string[] = []; beforeAll(() => {