summaryrefslogtreecommitdiffstats
path: root/browser/extensions/pictureinpicture/tests/browser/test-mock-wrapper.js
blob: 2119122428ddc607e363b0d54da5493401510840 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

function toggleMute() {
  let video = document.getElementById("mock-video-controls");
  let muteButton = document.querySelector(".mute-button");
  let isMuted = video.muted;
  video.muted = !isMuted;

  if (video.muted) {
    muteButton.setAttribute("isMuted", true);
  } else {
    muteButton.removeAttribute("isMuted");
  }
}

function playPause() {
  let video = document.getElementById("mock-video-controls");
  let playPauseButton = document.querySelector(".play-pause-button");

  if (video.paused) {
    video.play();
    playPauseButton.removeAttribute("isPaused");
  } else {
    video.setAttribute("isPaused", true);
    video.pause();
  }
}