A desktop browser with x402 built in: when a page asks for payment, it pays in stablecoins and shows the content.

9 downloads

dbbasic-browser/apps/browser/test/shortcuts.test.ts
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-browser.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-browser.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-browser.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 toolbar: Back and Forward are greyed out when there's nowhere to go cc08c7a 1 week, 2 days ago History
shortcuts.test.ts · 2.5 KB · 33 lines
1import { describe, expect, it } from "vitest";
2import { reservedShortcut, type KeyInput } from "../src/shortcuts";
3
4const k = (over: Partial<KeyInput>): KeyInput => ({ type: "keyDown", key: "", code: "", meta: false, control: false, shift: false, alt: false, ...over });
5
6describe("the browser's own keys", () => {
7 it("⌘⇧] and ⌘⇧[ switch tabs on a Mac, by the key's place or by the character any layout reports", () => {
8 expect(reservedShortcut(k({ meta: true, shift: true, code: "BracketRight", key: "}" }), true)).toBe("next");
9 expect(reservedShortcut(k({ meta: true, shift: true, code: "", key: "]" }), true)).toBe("next");
10 expect(reservedShortcut(k({ meta: true, shift: true, code: "BracketLeft", key: "{" }), true)).toBe("prev");
11 expect(reservedShortcut(k({ meta: true, alt: true, key: "ArrowRight" }), true)).toBe("next");
12 });
13 it("Ctrl+Tab everywhere, ⌘1–⌘9, ⌘T, ⌘W, ⌘L and ⌘R", () => {
14 expect(reservedShortcut(k({ control: true, key: "Tab" }), true)).toBe("next");
15 expect(reservedShortcut(k({ control: true, shift: true, key: "Tab" }), false)).toBe("prev");
16 expect(reservedShortcut(k({ meta: true, code: "Digit3", key: "3" }), true)).toBe("tab:3");
17 expect(reservedShortcut(k({ meta: true, key: "t" }), true)).toBe("new");
18 expect(reservedShortcut(k({ meta: true, key: "W" }), true)).toBe("close");
19 expect(reservedShortcut(k({ meta: true, key: "l" }), true)).toBe("focus-url");
20 expect(reservedShortcut(k({ control: true, key: "t" }), false)).toBe("new");
21 expect(reservedShortcut(k({ meta: true, key: "r" }), true)).toBe("reload"); // even while the page has the keyboard
22 expect(reservedShortcut(k({ control: true, key: "r" }), false)).toBe("reload");
23 expect(reservedShortcut(k({ meta: true, shift: true, key: "R" }), true)).toBeNull(); // ⌘⇧R is the AI Reader's (the menu's)
24 });
25 it("leaves everything else to the page", () => {
26 expect(reservedShortcut(k({ meta: true, key: "k" }), true)).toBeNull(); // the page's own search box
27 expect(reservedShortcut(k({ meta: true, key: "]", code: "BracketRight" }), true)).toBeNull(); // ⌘] (forward) stays with the page first: editors indent with it
28 expect(reservedShortcut(k({ meta: true, key: "c" }), true)).toBeNull();
29 expect(reservedShortcut(k({ key: "]" }), true)).toBeNull();
30 expect(reservedShortcut(k({ control: true, key: "t" }), true)).toBeNull(); // Ctrl+T on a Mac is the page's
31 expect(reservedShortcut(k({ meta: true, shift: true, code: "BracketRight", key: "}", type: "keyUp" }), true)).toBeNull();
32 });
33});