forked from phenom/healer-man
Release Healer Man 0.1.46
This commit is contained in:
1 parent
f82daf1c13
commit
9ff574ac0b
73 files changed
+33486
-174
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
MAX_MOUSE_DELTA_PER_FRAME,
|
||||
POINTER_LOCK_MOUSE_GRACE_MS,
|
||||
beginMouseLookDrag,
|
||||
clearBrowserSelection,
|
||||
clearJumpRequest,
|
||||
consumeJumpRequest,
|
||||
consumeMouseLook,
|
||||
@@ -31,9 +32,10 @@ import {
|
||||
import { normalizeInputPreferences, replaceInputBinding } from "../input/keybinds";
|
||||
import { setCapturingInput } from "../input/keybindRuntime";
|
||||
|
||||
function stubInputEventTargets(): void {
|
||||
function stubInputEventTargets(selection: Pick<Selection, "removeAllRanges"> | null = null): void {
|
||||
const windowTarget = new EventTarget();
|
||||
const documentTarget = new EventTarget();
|
||||
Object.defineProperty(windowTarget, "getSelection", { configurable: true, value: () => selection });
|
||||
Object.defineProperty(documentTarget, "pointerLockElement", { configurable: true, value: null });
|
||||
vi.stubGlobal("window", windowTarget);
|
||||
vi.stubGlobal("document", documentTarget);
|
||||
@@ -362,15 +364,19 @@ describe("gameplay input bindings", () => {
|
||||
});
|
||||
|
||||
it("turns the camera from a right-mouse drag without pointer lock", () => {
|
||||
stubInputEventTargets();
|
||||
const selection = { removeAllRanges: vi.fn() };
|
||||
stubInputEventTargets(selection);
|
||||
const nextActions = inputActionSpies();
|
||||
const dispose = installInput(nextActions);
|
||||
beginMouseLookDrag(100, 80);
|
||||
|
||||
const move = new Event("mousemove") as MouseEvent;
|
||||
expect(selection.removeAllRanges).toHaveBeenCalledOnce();
|
||||
|
||||
const move = new Event("pointermove") as PointerEvent;
|
||||
Object.defineProperties(move, {
|
||||
clientX: { value: 114 },
|
||||
clientY: { value: 73 },
|
||||
pointerType: { value: "mouse" },
|
||||
movementX: { value: 9_999 },
|
||||
movementY: { value: 9_999 },
|
||||
});
|
||||
@@ -387,6 +393,33 @@ describe("gameplay input bindings", () => {
|
||||
dispose();
|
||||
});
|
||||
|
||||
it("prevents page selection only while right-mouse camera drag is active", () => {
|
||||
stubInputEventTargets();
|
||||
const dispose = installInput(inputActionSpies());
|
||||
|
||||
const idleSelection = new Event("selectstart", { cancelable: true });
|
||||
document.dispatchEvent(idleSelection);
|
||||
expect(idleSelection.defaultPrevented).toBe(false);
|
||||
|
||||
beginMouseLookDrag(20, 30);
|
||||
const cameraSelection = new Event("selectstart", { cancelable: true });
|
||||
document.dispatchEvent(cameraSelection);
|
||||
expect(cameraSelection.defaultPrevented).toBe(true);
|
||||
|
||||
endMouseLookDrag();
|
||||
const releasedSelection = new Event("selectstart", { cancelable: true });
|
||||
document.dispatchEvent(releasedSelection);
|
||||
expect(releasedSelection.defaultPrevented).toBe(false);
|
||||
dispose();
|
||||
});
|
||||
|
||||
it("can clear an existing browser selection without a camera drag", () => {
|
||||
const selection = { removeAllRanges: vi.fn() };
|
||||
stubInputEventTargets(selection);
|
||||
clearBrowserSelection();
|
||||
expect(selection.removeAllRanges).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("contains malformed and stale pointer-lock movement", () => {
|
||||
expect(sanitizeMouseDelta(Number.NaN)).toBe(0);
|
||||
expect(sanitizeMouseDelta(Number.POSITIVE_INFINITY)).toBe(0);
|
||||
|
||||
Reference in new issue
Block a user