mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
fix: keep autoplay fallback from saving mute
(cherry picked from commit f373bb9ce7)
This commit is contained in:
1 parent
0513c7fcd8
commit
d8e5113efd
7 files changed
+96
-10
No files matched your search
@@ -44,21 +44,27 @@ describe("PlaybackService", () => {
|
||||
const service = new PlaybackService();
|
||||
const video = document.createElement("video");
|
||||
|
||||
// Default: muted (unless localStorage says unmuted)
|
||||
// Default: sound on unless the viewer explicitly chose mute.
|
||||
localStorage.removeItem("unmutedAutoplay");
|
||||
service.prepareVideoElement(video);
|
||||
assert.equal(video.muted, true);
|
||||
assert.equal(video.muted, false);
|
||||
assert.equal(video.dataset.autoplayBound, "true");
|
||||
|
||||
// Simulate volume change
|
||||
video.muted = false;
|
||||
// Simulate an explicit mute choice.
|
||||
video.muted = true;
|
||||
video.dispatchEvent(new window.Event("volumechange"));
|
||||
assert.equal(localStorage.getItem("unmutedAutoplay"), "true");
|
||||
assert.equal(localStorage.getItem("unmutedAutoplay"), "false");
|
||||
|
||||
// Test respecting stored value
|
||||
const video2 = document.createElement("video");
|
||||
service.prepareVideoElement(video2);
|
||||
assert.equal(video2.muted, false);
|
||||
assert.equal(video2.muted, true);
|
||||
|
||||
// A browser-policy fallback is temporary and must not become a saved mute.
|
||||
localStorage.setItem("unmutedAutoplay", "true");
|
||||
video2.muted = false;
|
||||
service.muteForAutoplayFallback(video2);
|
||||
assert.equal(localStorage.getItem("unmutedAutoplay"), "true");
|
||||
});
|
||||
|
||||
test("registerUrlPlaybackWatchdogs triggers onFallback on error", () => {
|
||||
|
||||
Reference in new issue
Block a user