Skip to content

Commit bacfeff

Browse files
authored
bc/private window from panelui (#119)
* ergo for other security tests; finish priv window test * fix ergo, lint * documentation * use new method
1 parent ecb1fe0 commit bacfeff

15 files changed

+74
-25
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"main-logo": {
3+
"selectorData": "about-private-browsing-logo",
4+
"strategy": "id",
5+
"groups": [
6+
"requiredForPage"
7+
]
8+
}
9+
10+
}

modules/data/panel_ui.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
]
4242
},
4343

44+
"new-private-window-option": {
45+
"selectorData": "appMenu-new-private-window-button2",
46+
"strategy": "id",
47+
"groups": []
48+
},
49+
4450
"more-tools": {
4551
"selectorData": "appMenu-more-button2",
4652
"strategy": "id",

modules/page_base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,19 @@ def wait_for_num_tabs(self, num_tabs: int) -> Page:
537537
logging.warn("Timeout waiting for the number of windows to be:", num_tabs)
538538
return self
539539

540-
def switch_to_new_tab(self):
540+
def switch_to_new_tab(self) -> Page:
541541
"""Get list of all window handles, switch to the newly opened tab"""
542542
handles = self.driver.window_handles
543543
self.driver.switch_to.window(handles[-1])
544+
return self
545+
546+
def wait_for_num_windows(self, num: int) -> Page:
547+
"""Wait for the number of open tabs + windows to equal given int"""
548+
return self.wait_for_num_tabs(num)
549+
550+
def switch_to_new_window(self) -> Page:
551+
"""Switch to newest window"""
552+
return self.switch_to_new_tab()
544553

545554
def hide_popup(self, context_menu: str, chrome=False) -> Page:
546555
"""

modules/page_object.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from modules.page_object_about_logins import *
55
from modules.page_object_about_newtab import *
66
from modules.page_object_about_prefs import *
7+
from modules.page_object_about_privatebrowsing import *
78
from modules.page_object_about_profiles import *
89
from modules.page_object_about_telemetry import *
910
from modules.page_object_addons_mozilla_org import *

modules/page_object_about_prefs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from modules.classes.autofill_base import AutofillAddressBase
1111
from modules.classes.credit_card import CreditCardBase
1212
from modules.page_base import BasePage
13-
from modules.util import BrowserActions, PomUtils
13+
from modules.util import PomUtils
1414

1515

1616
class AboutPrefs(BasePage):
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from modules.page_base import BasePage
2+
3+
4+
class AboutPrivatebrowsing(BasePage):
5+
URL_TEMPLATE = "about:privatebrowsing"

modules/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ def shadow_from_script():
565565
def css_selector_matches_element(
566566
self, element: Union[WebElement, ShadowRoot], selector: list
567567
) -> bool:
568-
if type(element) == ShadowRoot:
568+
if isinstance(element, ShadowRoot):
569569
return False
570570
sel = f'"{selector[1]}"'
571571
return self.driver.execute_script(

new_model.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import re
77
import sys
88

9-
SNAKE_RE = re.compile(r"^[a-z](_[a-z])*[a-z]$")
9+
SNAKE_RE = re.compile(r"^[a-z]+([_a-z][a-z])*$")
1010
PASCAL_RE = re.compile(r"^[A-Z][a-zA-Z]*[a-z]$")
1111

1212

@@ -61,20 +61,38 @@ def pascalify(snake: str) -> str:
6161

6262

6363
if __name__ == "__main__":
64+
first = True
65+
second = False
6466
while not model_type:
67+
if second:
68+
print("Please enter POM or BOM.")
6569
resp = input("What type of model is this? ")
6670
resp = resp.strip().lower()
6771
if resp not in ["pom", "bom"]:
6872
resp = None
6973
model_type = resp
74+
if second:
75+
second = False
76+
if first:
77+
first = False
78+
second = True
7079

80+
first = True
81+
second = False
7182
while not model_name:
83+
if second:
84+
print("Please enter the name in either snake_case or PascalCase.")
7285
resp = input("What is the name of the model? ")
7386
resp = resp.strip()
7487
if SNAKE_RE.match(resp):
7588
model_name = resp
7689
elif PASCAL_RE.match(resp):
7790
model_name = snakify(resp)
91+
if second:
92+
second = False
93+
if first:
94+
first = False
95+
second = True
7896

7997
model_type_name = "page" if model_type == "pom" else "browser"
8098

tests/preferences/test_clear_cookie_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def open_clear_cookies_data_dialog():
2727

2828
# Check for a non-zero value of the 'Cookies and site data' option
2929
cookie_value = about_prefs.get_clear_cookie_data_value()
30-
assert cookie_value is not 0
30+
assert cookie_value != 0
3131

3232
# Then clear the cookies and site data
3333
about_prefs.get_element("clear-data-accept-button").click()
3434

3535
# Finally, check the value of the dialog option, it should be 0
3636
open_clear_cookies_data_dialog()
3737
cookie_value2 = about_prefs.get_clear_cookie_data_value()
38-
assert cookie_value2 is 0
38+
assert cookie_value2 == 0

tests/security_and_privacy/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ def suite_id():
66
return ("5833", "Security and Privacy")
77

88

9+
@pytest.fixture()
10+
def add_prefs():
11+
return []
12+
13+
914
@pytest.fixture()
1015
def set_prefs(add_prefs: dict):
1116
"""Set prefs"""

0 commit comments

Comments
 (0)