fix(controller): keep video controls accessible

This commit is contained in:
joshpatra committed 2026-07-12 15:50:37 -04:00
1 parent a56742b421
commit bbab33f55f
8 files changed
+369 -44

No files matched your search

+43
View File
@@ -140,4 +140,47 @@ describe("inject.js helper logic", () => {
expect(window.tc.settings.controllerMarginBottom).toBe(0);
expect(window.tc.settings.rememberSpeed).toBe(true);
});
it("sizes and positions the controller host to the video bounds", async () => {
bootInject();
await flushAsyncWork(3);
const mount = document.createElement("div");
const video = document.createElement("video");
const wrapper = document.createElement("div");
wrapper.className = "vsc-controller";
mount.append(video, wrapper);
document.body.appendChild(mount);
Object.defineProperties(mount, {
offsetWidth: { value: 400 },
offsetHeight: { value: 240 },
clientLeft: { value: 2 },
clientTop: { value: 2 }
});
mount.getBoundingClientRect = () => ({
left: 100,
top: 50,
right: 500,
bottom: 290,
width: 400,
height: 240
});
video.getBoundingClientRect = () => ({
left: 140,
top: 70,
right: 460,
bottom: 250,
width: 320,
height: 180
});
window.positionControllerHost(wrapper, video, mount);
expect(wrapper.style.getPropertyValue("left")).toBe("38px");
expect(wrapper.style.getPropertyValue("top")).toBe("18px");
expect(wrapper.style.getPropertyValue("width")).toBe("320px");
expect(wrapper.style.getPropertyValue("height")).toBe("180px");
expect(wrapper.style.getPropertyPriority("width")).toBe("important");
});
});
+24
View File
@@ -134,4 +134,28 @@ describe("popup UI", () => {
);
expect(chrome.tabs.executeScript).toHaveBeenCalled();
});
it("toggles force last saved speed and applies it to the active page", async () => {
const chrome = await setupPopup({
sync: { lastSpeed: 1.8, forceLastSavedSpeed: false }
});
chrome.tabs.sendMessage.mockClear();
document.getElementById("forceLastSavedSpeed").click();
await flushAsyncWork();
expect(chrome.storage.sync.__state.forceLastSavedSpeed).toBe(true);
expect(
document.getElementById("forceLastSavedSpeed").getAttribute("aria-pressed")
).toBe("true");
expect(chrome.tabs.sendMessage).toHaveBeenCalledWith(
1,
{
action: "set_force_last_saved_speed",
enabled: true,
speed: 1.8
},
expect.any(Function)
);
});
});