// Which keys the screen page leaves to the browser. Run by `npm test`. import assert from "node:assert/strict"; import { test } from "node:test"; import { keepForBrowser } from "../src/screen-keys.js"; const plain = { closest: () => null }; const button = { closest: (sel) => (sel === "button" ? {} : null) }; test("reload, the address bar and the dev tools stay with the browser", () => { assert.equal(keepForBrowser({ key: "F5", target: plain }), true); assert.equal(keepForBrowser({ key: "F12", target: plain }), true); assert.equal( keepForBrowser({ key: "r", ctrlKey: true, target: plain }), true, ); assert.equal( keepForBrowser({ key: "R", metaKey: true, target: plain }), true, ); assert.equal( keepForBrowser({ key: "l", ctrlKey: true, target: plain }), true, ); }); test("a key pressed on a button stays with the button", () => { assert.equal(keepForBrowser({ key: "Enter", target: button }), true); assert.equal(keepForBrowser({ key: " ", target: button }), true); }); test("everything else goes to the remote desktop", () => { assert.equal(keepForBrowser({ key: "a", target: plain }), false); assert.equal(keepForBrowser({ key: "r", target: plain }), false); assert.equal( keepForBrowser({ key: "c", ctrlKey: true, target: plain }), false, ); assert.equal(keepForBrowser({ key: "F4", target: plain }), false); assert.equal(keepForBrowser({ key: "Enter" }), false); });