summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/browser/browser_ext_themes_tab_text.js
blob: d819f3a5f1d72cecdaa3ab8c917c434c05037dc8 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"use strict";

// This test checks whether applied WebExtension themes that attempt to change
// the text color of the selected tab are applied properly.

add_task(async function test_support_tab_text_property_css_color() {
  const TAB_TEXT_COLOR = "#9400ff";
  let extension = ExtensionTestUtils.loadExtension({
    manifest: {
      theme: {
        images: {
          theme_frame: "image1.png",
        },
        colors: {
          frame: ACCENT_COLOR,
          tab_background_text: TEXT_COLOR,
          tab_text: TAB_TEXT_COLOR,
        },
      },
    },
    files: {
      "image1.png": BACKGROUND,
    },
  });

  await extension.startup();

  info("Checking selected tab colors");
  let selectedTab = document.querySelector(".tabbrowser-tab[selected]");
  Assert.equal(
    window.getComputedStyle(selectedTab).color,
    "rgb(" + hexToRGB(TAB_TEXT_COLOR).join(", ") + ")",
    "Selected tab text color should be set."
  );

  await extension.unload();
});

add_task(async function test_support_tab_text_chrome_array() {
  const TAB_TEXT_COLOR = [148, 0, 255];
  let extension = ExtensionTestUtils.loadExtension({
    manifest: {
      theme: {
        images: {
          theme_frame: "image1.png",
        },
        colors: {
          frame: FRAME_COLOR,
          tab_background_text: TAB_BACKGROUND_TEXT_COLOR,
          tab_text: TAB_TEXT_COLOR,
        },
      },
    },
    files: {
      "image1.png": BACKGROUND,
    },
  });

  await extension.startup();

  info("Checking selected tab colors");
  let selectedTab = document.querySelector(".tabbrowser-tab[selected]");
  Assert.equal(
    window.getComputedStyle(selectedTab).color,
    "rgb(" + TAB_TEXT_COLOR.join(", ") + ")",
    "Selected tab text color should be set."
  );

  await extension.unload();
});