Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions modules/browser_object_navigation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from typing import Literal

from selenium.common.exceptions import TimeoutException
from selenium.webdriver import ActionChains, Firefox
Expand Down Expand Up @@ -658,3 +659,43 @@ def expect_bookmarks_toolbar_visibility(self, expected: bool) -> None:
self.expect_element_attribute_contains(
self.bookmarks_toolbar, "collapsed", expected_value
)

#
def set_site_autoplay_permission(
self,
settings: Literal["allow-audio-video", "block-audio-video", "allow-audio-only"],
) -> BasePage:
"""
Open the Site audio-video permission panel and set a specific autoplay setting.

Arguments:
settings: "allow-audio-video" → Allow Audio and Video, "block-audio-video" → Block Audio and Video,
"allow-audio-only" → Allow Audio but block Video
"""
self.click_on("autoplay-icon-blocked")

if settings == "allow-audio-video":
self.element_clickable("permission-popup-audio-blocked")
self.click_on("permission-popup-audio-blocked")
self.click_and_hide_menu("allow-audio-video-menuitem")

elif settings == "block-audio-video":
self.element_clickable("permission-popup-audio-video-allowed")
self.click_and_hide_menu("block-audio-video-menuitem")

elif settings == "allow-audio-only":
self.element_clickable("permission-popup-audio-video-allowed")
self.click_and_hide_menu("allow-audio-only-menuitem")
return self

def verify_autoplay_state(self, expected: Literal["allow", "block"]) -> None:
"""Verify the current state of the autoplay permission panel and icon.
Arguments:
expected: "allow" → Allow Audio and Video, "block" → Block Audio and Video
"""
if expected == "allow":
self.element_visible("permission-popup-audio-video-allowed")
self.element_not_visible("autoplay-icon-blocked")
else:
self.element_visible("permission-popup-audio-video-blocked")
self.element_visible("autoplay-icon-blocked")
5 changes: 4 additions & 1 deletion modules/browser_object_tabbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,13 @@ def get_tab_title(self, tab_element: WebElement) -> str:
tab_label = tab_element.find_element(*self.get_selector("tab-title"))
return tab_label.text

@BasePage.context_chrome
def expect_tab_sound_status(
self, identifier: Union[str, int], status: MediaStatus
) -> BasePage:
"""Check to see if the tab has an expected MediaStatus"""
"""
Check to see if the tab has an expected MediaStatus
"""
tab = self.get_tab(identifier)
self.wait.until(lambda _: tab.get_attribute(status) is not None)
return self
Expand Down
6 changes: 0 additions & 6 deletions modules/data/navigation.components.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,6 @@
"groups": []
},

"autoplay-permission": {
"selectorData": "blocked-permissions-container",
"strategy": "id",
"groups": []
},

"permissions-location-icon": {
"selectorData": "permissions-granted-icon",
"strategy": "id",
Expand Down
28 changes: 27 additions & 1 deletion modules/page_object_prefs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import re
from time import sleep
from typing import List
from typing import List, Literal

from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
Expand Down Expand Up @@ -561,6 +561,32 @@ def get_manage_data_site_element(self, site: str) -> WebElement:
element = self.get_element("manage-cookies-site", labels=[site])
return element

def open_autoplay_modal(self) -> BasePage:
"""
Opens the Autoplay settings modal dialog from the about:preferences#privacy page.
"""
self.open()
self.click_on("autoplay-settings-button")
self.driver.switch_to.frame(self.get_iframe())
self.click_on("autoplay-settings")
return self

def set_autoplay_setting_in_preferences(
self,
settings: Literal["allow-audio-video", "block-audio-video", "allow-audio-only"],
) -> BasePage:
"""
Open the Autoplay settings panel and choose a setting for all sites.
Arguments:
settings: "allow-audio-video" → Allow Audio and Video, "block-audio-video" → Block Audio and Video,
"allow-audio-only" → Allow Audio but block Video
"""
self.open_autoplay_modal()
self.click_on(settings)
self.click_on("spacer")
self.click_on("autoplay-save-changes")
return self

# Utility Functions
def import_bookmarks(self, browser_name: str, platform) -> BasePage:
"""
Expand Down
38 changes: 6 additions & 32 deletions tests/audio_video/test_allow_audio_video_functionality.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import sys
from os import environ
from time import sleep

import pytest
from selenium.webdriver import Firefox

from modules.browser_object_tabbar import TabBar
from modules.page_object_generics import GenericPage
from modules.page_object_prefs import AboutPrefs
from modules.util import BrowserActions


@pytest.fixture()
Expand All @@ -27,40 +25,16 @@ def test_case():
@pytest.mark.noxvfb
def test_allow_audio_video_functionality(driver: Firefox):
"""
C330155 : 'Allow Audio and Video' functionality
C330155: 'Allow Audio and Video' functionality
"""
# Instantiate objects
about_prefs = AboutPrefs(driver, category="privacy")
ba = BrowserActions(driver)
tabs = TabBar(driver)
page = GenericPage(driver, url=TEST_URL)

# Open privacy and click on the "Settings" button from Autoplay
about_prefs.open()
about_prefs.get_element("autoplay-settings-button").click()
about_prefs.set_autoplay_setting_in_preferences("allow-audio-video")

# Get the web element for the iframe
iframe = about_prefs.get_iframe()
ba.switch_to_iframe_context(iframe)

# Click on the autoplay settings for all websites
about_prefs.get_element("autoplay-settings").click()

# Choose allow audio and video and save changes
about_prefs.click_on("allow-audio-video")
about_prefs.get_element("spacer").click()
about_prefs.get_element("autoplay-save-changes").click()

# Open test website and check the site is loaded and the featured video starts playing with sound
GenericPage(driver, url=TEST_URL).open()
max_retries = 3
for attempt in range(max_retries):
try:
with driver.context(driver.CONTEXT_CHROME):
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
break # Success!
except AssertionError:
sleep(2)
else:
pytest.fail(
f"Tab sound status did not reach PLAYING after {max_retries} retries."
)
# Open the website and check if the video starts playing with sound
page.open()
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
24 changes: 5 additions & 19 deletions tests/audio_video/test_block_audio_video_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from modules.browser_object_navigation import Navigation
from modules.page_object_generics import GenericPage
from modules.page_object_prefs import AboutPrefs
from modules.util import BrowserActions


@pytest.fixture()
Expand All @@ -21,26 +20,13 @@ def test_block_audio_video_functionality(driver: Firefox):
"""
# Instantiate objects
about_prefs = AboutPrefs(driver, category="privacy")
ba = BrowserActions(driver)
nav = Navigation(driver)
page = GenericPage(driver, url=TEST_URL)

# Open privacy and click on the "Settings" button from Autoplay
about_prefs.open()
about_prefs.get_element("autoplay-settings-button").click()

# Get the web element for the iframe
iframe = about_prefs.get_iframe()
ba.switch_to_iframe_context(iframe)

# Click on the autoplay settings for all websites
about_prefs.get_element("autoplay-settings").click()

# Choose block audio and video and save changes
about_prefs.click_on("block-audio-video")
about_prefs.get_element("spacer").click()
about_prefs.get_element("autoplay-save-changes").click()
about_prefs.set_autoplay_setting_in_preferences("block-audio-video")

# Open test website and check the site is loaded and the featured video is not playing
GenericPage(driver, url=TEST_URL).open()
nav.click_on("autoplay-permission")
nav.element_visible("permission-popup-audio-video-blocked")
page.open()
nav.click_on("autoplay-icon-blocked")
nav.verify_autoplay_state("block")
51 changes: 17 additions & 34 deletions tests/audio_video/test_users_actions_saved_on_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from modules.browser_object_navigation import Navigation
from modules.page_object_generics import GenericPage
from modules.page_object_prefs import AboutPrefs
from modules.util import BrowserActions


@pytest.fixture()
Expand All @@ -30,49 +29,33 @@ def test_users_actions_saved_on_reload(driver: Firefox):
# Instantiate objects
nav = Navigation(driver)
about_prefs = AboutPrefs(driver, category="privacy")
ba = BrowserActions(driver)
page = GenericPage(driver, url=TEST_URL)

# Open Test page
GenericPage(driver, url=TEST_URL).open()
# Open the test page
page.open()

# Open the Site information panel and check "Allow Audio and Video"
nav.click_on("autoplay-permission")
nav.click_on("permission-popup-audio-blocked")
nav.click_and_hide_menu("allow-audio-video-menuitem")
# Open the Audio-Video Permission panel and check "Allow Audio and Video"
nav.set_site_autoplay_permission("allow-audio-video")

# Refresh test page and check the site information panel shows "Allow Audio and Video"
# Refresh test page and check the Audio-Video Permission panel shows "Allow Audio and Video" and the crossed off
# Play icon is no longer displayed
driver.get(driver.current_url)
nav.element_visible("permission-popup-audio-video-allowed")

# Check the Crossed off Play icon is no longer displayed
nav.element_not_visible("autoplay-icon-blocked")
nav.verify_autoplay_state("allow")

# Check the website is added to the exceptions list in about:preferences#privacy
about_prefs.open()
about_prefs.get_element("autoplay-settings-button").click()

# Get the web element for the iframe
iframe = about_prefs.get_iframe()
ba.switch_to_iframe_context(iframe)

about_prefs.open_autoplay_modal()
about_prefs.element_visible("mlb-allow-audio-video-settings")

# Open Test page
GenericPage(driver, url=TEST_URL).open()
# # Open the test page
page.open()

# Open the Site information panel and check "Block Audio and Video"
nav.click_on("autoplay-permission")
nav.click_on("permission-popup-audio-video-allowed")
nav.click_and_hide_menu("block-audio-video-menuitem")
# Open the Audio-Video Permission panel and check "Block Audio and Video"
nav.set_site_autoplay_permission("block-audio-video")

# Refresh test page and check the site information panel shows "Block Audio and Video"
# Refresh test page and check the Audio-Video Permission panel shows "Block Audio and Video"
driver.get(driver.current_url)
nav.element_visible("permission-popup-audio-video-blocked")
nav.element_visible("autoplay-icon-blocked")
nav.verify_autoplay_state("block")

# Revisit test page and check Site information panel shows "Block Audio and Video"
GenericPage(driver, url=TEST_URL).open()
nav.element_visible("permission-popup-audio-video-blocked")

# Check the Crossed off Play icon is displayed
nav.element_visible("autoplay-icon-blocked")
page.open()
nav.verify_autoplay_state("block")
7 changes: 7 additions & 0 deletions tests/preferences/test_clear_cookie_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import sys
from os import environ

import pytest
from selenium.webdriver import Firefox

Expand All @@ -10,13 +13,17 @@ def test_case():
return "143627"


WIN_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("win")


def open_clear_cookies_data_dialog(about_prefs: AboutPrefs, ba: BrowserActions):
about_prefs.open()
clear_data_popup = about_prefs.press_button_get_popup_dialog_iframe("Clear Data")
ba.switch_to_iframe_context(clear_data_popup)
return about_prefs.get_clear_cookie_data_value()


@pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows GA, tracked in 1990570")
def test_clear_cookie_data(driver: Firefox):
"""
C143627: Cookies and site data can be cleared via the "Clear Data" panel
Expand Down
1 change: 1 addition & 0 deletions tests/scrolling_panning_zooming/test_zoom_text_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def reject_consent_page(web_page: GenericPage):
pass


@pytest.mark.skip(reason="Tracked in bug 1991139")
@pytest.mark.ci
@pytest.mark.noxvfb
def test_zoom_text_only_from_settings(
Expand Down