Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Let a remote server's page take a chat video fullscreen

wlals0874a0b462f7a462
diff --git a/electron/app-permissions.mjs b/electron/app-permissions.mjs
index 9e1e4cb8da..faf68a4c99 100644
--- a/electron/app-permissions.mjs
+++ b/electron/app-permissions.mjs
@@ -79,10 +79,11 @@ export function appPermissionHandlers({ rendererOrigin, mainContents, cloudHomeO
activeRemoteMicrophone = () => false, askRemoteMicrophone = () => null, homeOrigin = () => null }) {
// Notifications for the main window's main frame on `origin`: My Cloud as home, or the remote server the person
// switched to (Settings → Notifications there has no browser site settings to fall back on).
+ // Fullscreen too, so a chat video's own fullscreen button works there (it still needs the person's click).
const notifiesAs = (origin, contents, permission, requesting, details) => {
const page = webOrigin(origin);
- return permission === "notifications" && Boolean(page) && Boolean(contents) && contents === mainContents() &&
- details?.isMainFrame === true && webOrigin(requesting) === page;
+ return (permission === "notifications" || permission === "fullscreen") && Boolean(page) && Boolean(contents) &&
+ contents === mainContents() && details?.isMainFrame === true && webOrigin(requesting) === page;
};
const asksAsCloud = (contents, permission, requesting, details) =>
Boolean(contents) && contents === mainContents() && mainFrameMicrophoneAllowed(permission, requesting, requesting, details);
diff --git a/electron/app-permissions.node-test.mjs b/electron/app-permissions.node-test.mjs
index a7a61e2be3..4fca7b2066 100644
--- a/electron/app-permissions.node-test.mjs
+++ b/electron/app-permissions.node-test.mjs
@@ -222,7 +222,7 @@ test("the verified Cloud open in this window may write the clipboard, by the rem
assert.equal(ask(write, onCloud(), { getURL: () => `${CLOUD}/` }), false, "the main window is gone");
});
-test("once My Cloud is home its page may show notifications, in the main window's main frame only; any other page still may not", () => {
+test("once My Cloud is home its page may show notifications and go fullscreen, in the main window's main frame only; any other page still may not", () => {
const state = { home: null, main: { getURL: () => `${CLOUD}/chat` } };
const handlers = appPermissionHandlers({ rendererOrigin: () => LOCAL_ORIGIN, mainContents: () => state.main, cloudHomeOrigin: () => CLOUD, homeOrigin: () => state.home });
const ask = (details, contents = state.main) => { let granted; handlers.request(contents, "notifications", (value) => { granted = value; }, details); return granted; };
@@ -235,7 +235,9 @@ test("once My Cloud is home its page may show notifications, in the main window'
assert.equal(check(CLOUD, {}), false, "a frame it cannot vouch for");
assert.equal(ask(onCloud(), { getURL: () => `${CLOUD}/` }), false, "another window");
assert.equal(ask({ requestingUrl: "https://bots.example.test/", isMainFrame: true }), false, "another server");
- for (const permission of ["geolocation", "camera", "clipboard-read", "fullscreen"]) {
+ let fullscreen; handlers.request(state.main, "fullscreen", (value) => { fullscreen = value; }, onCloud());
+ assert.equal(fullscreen, true, "a chat video's fullscreen button");
+ for (const permission of ["geolocation", "camera", "clipboard-read"]) {
let granted; handlers.request(state.main, permission, (value) => { granted = value; }, onCloud());
assert.equal(granted, false, permission);
}
@@ -526,7 +528,7 @@ test("the base policy itself still grants a remote origin nothing", () => {
}
});
-test("the active remote server's page may show notifications, in the main window's main frame only", () => {
+test("the active remote server's page may show notifications and go fullscreen, in the main window's main frame only", () => {
const state = { remote: REMOTE, main: { getURL: () => `${REMOTE}/chat` } };
const handlers = appPermissionHandlers({ rendererOrigin: () => LOCAL_ORIGIN, mainContents: () => state.main, cloudHomeOrigin: () => null,
activeRemoteOrigin: () => state.remote });
@@ -540,10 +542,16 @@ test("the active remote server's page may show notifications, in the main window
assert.equal(handlers.check(state.main, "notifications", REMOTE, {}), false, "a frame it cannot vouch for");
assert.equal(ask(onRemote(), { getURL: () => `${REMOTE}/` }), false, "another window");
assert.equal(ask(onRemote({ requestingUrl: "https://other.tail1.ts.net:9444/" })), false, "another server");
- for (const permission of ["geolocation", "camera", "clipboard-read", "fullscreen"]) {
+ assert.equal(ask(onRemote(), state.main, "fullscreen"), true, "a chat video's fullscreen button");
+ assert.equal(handlers.check(state.main, "fullscreen", REMOTE, { isMainFrame: true }), true);
+ assert.equal(ask(onRemote({ isMainFrame: false }), state.main, "fullscreen"), false, "fullscreen from a frame inside it");
+ assert.equal(ask(onRemote({ requestingUrl: "https://other.tail1.ts.net:9444/" }), state.main, "fullscreen"), false, "fullscreen for another server");
+ assert.equal(ask(onRemote(), { getURL: () => `${REMOTE}/` }, "fullscreen"), false, "fullscreen in another window");
+ for (const permission of ["geolocation", "camera", "clipboard-read"]) {
assert.equal(ask(onRemote(), state.main, permission), false, permission);
}
state.remote = null;
assert.equal(ask(onRemote()), false, "no active remote: at once");
+ assert.equal(ask(onRemote(), state.main, "fullscreen"), false, "no active remote: no fullscreen");
for (const requesting of ["about:blank", "data:text/html,x", ""]) assert.equal(ask(onRemote({ requestingUrl: requesting })), false, `${requesting || "(empty)"}`);
});
diff --git a/electron/remote-clipboard-permission.node-test.mjs b/electron/remote-clipboard-permission.node-test.mjs
index d7e4522d32..50404ded61 100644
--- a/electron/remote-clipboard-permission.node-test.mjs
+++ b/electron/remote-clipboard-permission.node-test.mjs
@@ -50,10 +50,10 @@ test("the active paired server may write the clipboard, on request and on check"
assert.equal(h.check("clipboard-sanitized-write", "", { isMainFrame: true }, Object.assign(h.mainContents, { getURL: () => `${VPS}/chat` })), true);
});
-// Notifications are the one other permission the active server's main frame gets (app-permissions.node-test.mjs).
+// Notifications and fullscreen are the only other permissions the active server's main frame gets (app-permissions.node-test.mjs).
test("a remote page can never read the clipboard or gain another permission", () => {
const h = harness(viewing("vps"));
- for (const permission of ["clipboard-read", "fullscreen", "media", "geolocation", "camera", "display-capture", "openExternal", "unknown"]) {
+ for (const permission of ["clipboard-read", "media", "geolocation", "camera", "display-capture", "openExternal", "unknown"]) {
assert.equal(h.request(permission, `${VPS}/`, { isMainFrame: true, mediaTypes: ["audio"] }), false, `request ${permission}`);
assert.equal(h.check(permission, VPS), false, `check ${permission}`);
}