summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/tabs/browser_tab_label_picture_in_picture.js
blob: dae4ffc44475593752dfb8ecec47e4314defc7ad (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function test_pip_label_changes_tab() {
  let newWin = await BrowserTestUtils.openNewBrowserWindow();

  let pipTab = newWin.document.querySelector(".tabbrowser-tab[selected]");
  pipTab.setAttribute("pictureinpicture", true);

  let pipLabel = pipTab.querySelector(".tab-icon-sound-pip-label");

  await BrowserTestUtils.withNewTab("about:blank", async browser => {
    let selectedTab = newWin.document.querySelector(
      ".tabbrowser-tab[selected]"
    );
    Assert.ok(
      selectedTab != pipTab,
      "Picture in picture tab is not selected tab"
    );

    selectedTab = await BrowserTestUtils.switchTab(newWin.gBrowser, () =>
      pipLabel.click()
    );
    Assert.ok(selectedTab == pipTab, "Picture in picture tab is selected tab");
  });

  await BrowserTestUtils.closeWindow(newWin);
});