1- from platform import system
2-
31import pytest
42from selenium .webdriver import Firefox
53
@@ -20,6 +18,20 @@ def test_case():
2018alpenglow_map = {"light" : "rgba(255, 255, 255, 0.76)" , "dark" : "rgba(40, 29, 78, 0.96)" }
2119
2220
21+ def colors_match (a , b ):
22+ """Determine if two colors are close enough to be considered matches"""
23+ tolerance = 0.14
24+ a_colorstring = a .split ("(" )[1 ][:- 1 ]
25+ b_colorstring = b .split ("(" )[1 ][:- 1 ]
26+ a_colors = [float (n ) for n in a_colorstring .split ("," )]
27+ b_colors = [float (n ) for n in b_colorstring .split ("," )]
28+ for i in range (len (a_colors )):
29+ diff = abs ((a_colors [i ] / b_colors [i ]) - 1.0 )
30+ if diff > tolerance :
31+ return False
32+ return True
33+
34+
2335@pytest .mark .ci
2436def test_redirect_to_addons (driver : Firefox ):
2537 """
@@ -34,7 +46,6 @@ def test_redirect_to_addons(driver: Firefox):
3446 assert driver .current_url == "about:addons"
3547
3648
37- @pytest .mark .skipif (system ().lower ().startswith ("win" ), reason = "Bug 1974109" )
3849@pytest .mark .parametrize ("theme_name" , list (themes .keys ()))
3950def test_open_addons (driver : Firefox , theme_name : str ):
4051 """
@@ -56,10 +67,12 @@ def test_open_addons(driver: Firefox, theme_name: str):
5667 # Already default on Firefox standard; skip activation/assertion
5768 pytest .skip ("Compact Light is default on Firefox, skipping." )
5869
59- abt_addons .activate_theme (nav , theme_name , themes [theme_name ])
70+ current_bg = abt_addons .activate_theme (
71+ nav , theme_name , themes [theme_name ], perform_assert = False
72+ )
73+ assert colors_match (current_bg , themes [theme_name ])
6074
6175
62- @pytest .mark .skipif (system ().lower ().startswith ("win" ), reason = "Bug 1974109" )
6376def test_alpenglow_theme (driver : Firefox ):
6477 """
6578 C118173, specifically for alpenglow theme because color can be two values for dark or light mode
@@ -72,4 +85,7 @@ def test_alpenglow_theme(driver: Firefox):
7285 nav , "firefox-alpenglow_mozilla_org-heading" , "" , perform_assert = False
7386 )
7487
75- assert current_bg == alpenglow_map ["light" ] or current_bg == alpenglow_map ["dark" ]
88+ # assert current_bg == alpenglow_map["light"] or current_bg == alpenglow_map["dark"]
89+ assert colors_match (current_bg , alpenglow_map ["light" ]) or colors_match (
90+ current_bg , alpenglow_map ["dark" ]
91+ )
0 commit comments