Merge pull request #4923 from LoneAngelFayt/fix/4906-webstation-camera-mic

fix(streaming): let the Webstation frame use camera, microphone and clipboard
This commit is contained in:
Georges-Antoine Assi
2026-09-30 10:41:41 -04:00
committed by GitHub
2 changed files with 43 additions and 7 deletions

View File

@@ -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, 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
// would answer the next test's events.
enableAutoUnmount(afterEach);
function mountStage(src: string) {
return mount(StreamStage, {
props: { src, frameTitle: "Stream" },
@@ -10,6 +14,14 @@ function mountStage(src: string) {
}
describe("StreamStage", () => {
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(
@@ -25,9 +37,26 @@ 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(sandbox.join(" ")).not.toContain("allow-top-navigation");
});
it.each([
"gamepad",
"fullscreen",
"autoplay",
"camera",
"microphone",
"clipboard-write",
])("delegates %s to the container", (feature) => {
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) => {
expect(sandbox).toContain(flag);
},
);
});

View File

@@ -304,7 +304,14 @@ defineExpose({
ref="streamFrame"
:src="frameSrc"
class="r-v2-stage__frame"
allow="gamepad *; fullscreen *; autoplay *"
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"