The following should come up with a Safebrowsing phishing page, but doesn't. All the settings for Safebrowsing should be correct.
import time
from playwright.sync_api import sync_playwright, TimeoutError, Error
firefox_preferences = {'browser.safebrowsing.blockedURIs.enabled': True,
'browser.safebrowsing.downloads.enabled': True,
'browser.safebrowsing.malware.enabled': True,
'browser.safebrowsing.phishing.enabled': True,
'browser.safebrowsing.provider.mozilla.updateURL': 'https://shavar.services.mozilla.com/downloads?client=SAFEBROWSING_ID&appver=%MAJOR_VERSION%&pver=2.2'}
with sync_playwright() as p:
# https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch-option-firefox-user-prefs
browser = p.firefox.launch(headless=False, firefox_user_prefs=firefox_preferences)
context = browser.new_context(ignore_https_errors=False)
context.set_default_timeout(30000)
page = context.new_page()
try:
# http://itisatrap.org/firefox/unwanted.html
# http://itisatrap.org/firefox/its-a-trap.html
# http://itisatrap.org/firefox/its-an-attack.html
page.goto('https://testsafebrowsing.appspot.com/s/phishing.html')
except Error as e:
if 'NS_ERROR_MALWARE_URI' in str(e):
print('MALWARE')
elif 'NS_ERROR_PHISHING_URI' in str(e):
print('PHISHING')
elif 'NS_ERROR_UNWANTED_URI' in str(e):
print('UNWANTED')
else:
print(f'Uncaught exception: {str(e)}')
time.sleep(45)
context.close()
browser.close()
This thread is trying to answer question "Why doesn't Safebrowsing work on any URLs other than the hardcoded ones despite having the correct settings?"
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].