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
16 changes: 15 additions & 1 deletion SELECTOR_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,22 @@ Path to .json: modules/data/about_prefs.components.json
```
```
Selector Name: prefs-button
Selector Data: "moz-box-button[label^='{name}']"
Description: Checkbox for a option by label of moz box button
Location: about:preferences#privacy
Path to .json: modules/data/about_prefs.components.json
```
```
Selector Name: action-button
Selector Data: "button[label^='{name}']"
Description: Checkbox for a option by label
Description: Checkbox for a option by label of normal button
Location: about:preferences#privacy
Path to .json: modules/data/about_prefs.components.json
```
```
Selector Name: close-dialog
Selector Data: "button[data-l10n-id='close-button']"
Description: Close dialog button
Location: about:preferences#privacy
Path to .json: modules/data/about_prefs.components.json
```
Expand Down
2 changes: 2 additions & 0 deletions l10n_CM/Unified/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def prefs_list(add_to_prefs_list: List[tuple[str, str | bool]], region: str):
("extensions.formautofill.addresses.supportedCountries", region),
("browser.aboutConfig.showWarning", False),
("browser.search.region", region),
("extensions.formautofill.addresses.enabled", True),
("extensions.formautofill.creditCards.enabled", True),
]
prefs.extend(add_to_prefs_list)
return prefs
Expand Down
27 changes: 21 additions & 6 deletions modules/data/about_prefs.components.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,25 @@
"groups": []
},
"prefs-button": {
"selectorData": "moz-box-button[label^='{name}']",
"strategy": "css",
"groups": []
},
"action-button": {
"selectorData": "button[label^='{name}']",
"strategy": "css",
"groups": []
},
"close-dialog": {
"selectorData": "button[data-l10n-id='close-button']",
"strategy": "css",
"groups": []
},
"clear-site-data-button": {
"selectorData": "clearSiteDataButton",
"strategy": "id",
"groups": []
},
"saved-payments-button": {
"selectorData": "[data-l10n-id='autofill-payment-methods-manage-payments-button']",
"strategy": "css",
Expand Down Expand Up @@ -317,10 +332,15 @@
"groups": []
},
"cookies-privacy-label": {
"selectorData": "[data-l10n-id='sitedata-delete-on-close-private-browsing3']",
"selectorData": "moz-message-bar[data-l10n-id='sitedata-delete-on-close-private-browsing3']",
"strategy": "css",
"groups": []
},
"history-privacy-label": {
"selectorData": "historyPane",
"strategy": "id",
"groups": []
},
"cookies-delete-on-close": {
"selectorData": "deleteOnClose",
"strategy": "id",
Expand All @@ -336,11 +356,6 @@
"strategy": "id",
"groups": []
},
"history-privacy-label": {
"selectorData": "description[data-l10n-id='history-dontremember-description']",
"strategy": "css",
"groups": []
},
"language-dropdown": {
"selectorData": "primaryBrowserLocale",
"strategy": "id",
Expand Down
14 changes: 14 additions & 0 deletions modules/page_object_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,22 @@ def press_button_get_popup_dialog_iframe(self, button_label: str) -> WebElement:
"""
Returns the iframe object for the dialog panel in the popup after pressing some button that triggers a popup
"""
# hack to know if the current iframe is the default browser one or not
if self.get_iframe().location['x'] > 0:
self.click_on('close-dialog')
self.click_on("prefs-button", labels=[button_label])
iframe = self.get_element("browser-popup")
return iframe

def clear_cookies_and_get_dialog_iframe(self):
"""
Returns the iframe object for the dialog panel in the popup after pressing the clear site data button.
"""
self.element_clickable("clear-site-data-button")
self.click_on("clear-site-data-button")
iframe = self.get_element("browser-popup")
return iframe

def get_saved_addresses_popup_iframe(self) -> WebElement:
"""
Returns the iframe object for the dialog panel in the popup
Expand Down Expand Up @@ -534,6 +546,8 @@ def get_clear_cookie_data_value(self) -> int | None:
options = self.get_elements("clear-data-dialog-options")

# Extract the text from the label the second option
print(f"All options: {options}")
self.expect(lambda _: len(options) > 1)
second_option = options[1]
label_text = second_option.text
print(f"The text of the option is: {label_text}")
Expand Down
44 changes: 11 additions & 33 deletions tests/preferences/test_clear_cookie_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from platform import system

import pytest
from selenium.webdriver import Firefox
from selenium.webdriver.support.ui import WebDriverWait
Expand All @@ -16,49 +14,29 @@ def test_case():
WEBSITE_ADDRESS = "https://www.wikipedia.com"
# WIN_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("win")


def _dialog_options_present(about_prefs: AboutPrefs) -> bool:
"""Return True when the Clear Data dialog options container exists."""
try:
about_prefs.get_element("clear-data-dialog-options")
return True
except Exception:
return False


def _open_clear_cookies_data_dialog(
about_prefs: AboutPrefs, ba: BrowserActions, wait: WebDriverWait
about_prefs: AboutPrefs, ba: BrowserActions
):
"""
Open about:preferences#privacy, show 'Clear Data' dialog, switch into its iframe,
wait for its options container to be present, read the value, then switch back.
Open about:preferences#privacy, show the 'Clear Data' dialog, switch into its iframe,
wait for its option container to be present, read the value, then switch back.
"""
about_prefs.open()

# Click the button and grab the dialog iframe element
dlg_iframe = about_prefs.press_button_get_popup_dialog_iframe("Clear Data")

# Wait until the iframe is attached and visible before switching
wait.until(lambda _: dlg_iframe and dlg_iframe.is_displayed())
dlg_iframe = about_prefs.clear_cookies_and_get_dialog_iframe()

# Enter dialog iframe
ba.switch_to_iframe_context(dlg_iframe)

# Wait for dialog content to be ready (no custom timeout kwarg)
wait.until(lambda _: _dialog_options_present(about_prefs))

value = about_prefs.get_clear_cookie_data_value()

# Always return to content context
# Always return to the content context
ba.switch_to_content_context()
about_prefs.close_dialog_box()
return value


# @pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows GA, tracked in 1990570")
@pytest.mark.skipif(
system().lower().startswith("darwin") or system().lower().startswith("linux"),
reason="bug 1994055",
)
def test_clear_cookie_data(driver: Firefox):
"""
C143627: Cookies and site data can be cleared via the "Clear Data" panel
Expand All @@ -71,19 +49,19 @@ def test_clear_cookie_data(driver: Firefox):
driver.get(WEBSITE_ADDRESS)

# Open dialog and read current value (must be > 0)
cookie_value = _open_clear_cookies_data_dialog(about_prefs, ba, wait)
cookie_value = _open_clear_cookies_data_dialog(about_prefs, ba)
assert cookie_value > 0, f"Expected cookie/site data > 0, got {cookie_value}"

# Clear cookies and site data: open dialog again, wait for iframe, click clear
# Clear cookies and site data: open the dialog again, wait for iframe, click clear
about_prefs.open()
dlg_iframe = about_prefs.press_button_get_popup_dialog_iframe("Clear Data")
dlg_iframe = about_prefs.clear_cookies_and_get_dialog_iframe()
wait.until(lambda _: dlg_iframe and dlg_iframe.is_displayed())
ba.switch_to_iframe_context(dlg_iframe)
about_prefs.get_element("clear-data-accept-button").click()
ba.switch_to_content_context()

# Wait until the dialog reports 0 (reopen/poll via helper)
wait.until(lambda _: _open_clear_cookies_data_dialog(about_prefs, ba, wait) == 0)
wait.until(lambda _: _open_clear_cookies_data_dialog(about_prefs, ba) == 0)

final_value = _open_clear_cookies_data_dialog(about_prefs, ba, wait)
final_value = _open_clear_cookies_data_dialog(about_prefs, ba)
assert final_value == 0, f"Expected 0 after clearing, got {final_value}"
7 changes: 1 addition & 6 deletions tests/preferences/test_manage_cookie_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from platform import system
from time import sleep

import pytest
Expand All @@ -17,10 +16,6 @@ def test_case():
COOKIE_SITE = "google.com"


@pytest.mark.skipif(
system().lower().startswith("darwin") or system().lower().startswith("linux"),
reason="bug 1994056",
)
@pytest.mark.headed
@pytest.mark.noxvfb
def test_manage_cookie_data(driver: Firefox):
Expand All @@ -36,7 +31,7 @@ def test_manage_cookie_data(driver: Firefox):
def open_manage_cookies_data_dialog():
about_prefs.open()
manage_data_popup = about_prefs.press_button_get_popup_dialog_iframe(
"Manage Data…"
"Manage browsing data"
)
ba.switch_to_iframe_context(manage_data_popup)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def test_never_remember_browsing_history_settings(driver: Firefox):
login_exceptions = about_prefs.get_element("logins-exceptions")
assert login_exceptions.get_attribute("disabled") == "true"

history_label = about_prefs.get_element("history-privacy-label")
assert history_label.get_attribute("innerHTML") == HISTORY_LABEL_TEXT
about_prefs.element_has_text("history-privacy-label", HISTORY_LABEL_TEXT)


def test_never_remember_browsing_history_from_panel(driver: Firefox):
Expand Down