mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-04-19 07:15:52 -04:00
tests for dismissal of javascript dialogs (alert, prompt, confirm)
This commit is contained in:
parent
d2ed6b97a2
commit
011d814ee2
@ -204,10 +204,14 @@ class WebsockReceiverThread(threading.Thread):
|
||||
|
||||
def _javascript_dialog_opening(self, message):
|
||||
self.logger.info('javascript dialog opened: %s', message)
|
||||
if message['params']['type'] == 'alert':
|
||||
accept = True
|
||||
else:
|
||||
accept = False
|
||||
self.websock.send(
|
||||
json.dumps(dict(
|
||||
id=0, method='Page.handleJavaScriptDialog',
|
||||
params={'accept': True})))
|
||||
params={'accept': accept})))
|
||||
|
||||
def _handle_message(self, websock, json_message):
|
||||
message = json.loads(json_message)
|
||||
|
2
setup.py
2
setup.py
@ -32,7 +32,7 @@ def find_package_data(package):
|
||||
|
||||
setuptools.setup(
|
||||
name='brozzler',
|
||||
version='1.1b9.dev166',
|
||||
version='1.1b9.dev167',
|
||||
description='Distributed web crawling with browsers',
|
||||
url='https://github.com/internetarchive/brozzler',
|
||||
author='Noah Levitt',
|
||||
|
13
tests/htdocs/site4/alert.html
Normal file
13
tests/htdocs/site4/alert.html
Normal file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>a page that pops up an alert</title>
|
||||
<script>
|
||||
alert("I'm an alert")
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>alert</h1>
|
||||
<p>this is a page that pops up an alert</p>
|
||||
</body>
|
||||
</html>
|
||||
|
13
tests/htdocs/site4/confirm.html
Normal file
13
tests/htdocs/site4/confirm.html
Normal file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>a page that pops up an alert</title>
|
||||
<script>
|
||||
confirm("I'm a confirm dialog")
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>confirm</h1>
|
||||
<p>this is a page that pops up a confirm modal dialog</p>
|
||||
</body>
|
||||
</html>
|
||||
|
13
tests/htdocs/site4/print.html
Normal file
13
tests/htdocs/site4/print.html
Normal file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>a page that pops up an print dialog</title>
|
||||
<script>
|
||||
print()
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>print</h1>
|
||||
<p>this is a page that pops up a print dialog</p>
|
||||
</body>
|
||||
</html>
|
||||
|
13
tests/htdocs/site4/prompt.html
Normal file
13
tests/htdocs/site4/prompt.html
Normal file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>a page that pops up an prompt</title>
|
||||
<script>
|
||||
prompt("I'm a prompt")
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>prompt</h1>
|
||||
<p>this is a page that pops up a prompt</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -114,7 +114,6 @@ def test_on_response(httpd):
|
||||
url = 'http://localhost:%s/site3/page.html' % httpd.server_port
|
||||
with brozzler.Browser(chrome_exe=chrome_exe) as browser:
|
||||
browser.browse_page(url, on_response=on_response)
|
||||
browser.browse_page(url)
|
||||
assert response_urls[0] == 'http://localhost:%s/site3/page.html' % httpd.server_port
|
||||
assert response_urls[1] == 'http://localhost:%s/site3/brozzler.svg' % httpd.server_port
|
||||
assert response_urls[2] == 'http://localhost:%s/favicon.ico' % httpd.server_port
|
||||
@ -126,3 +125,20 @@ def test_420(httpd):
|
||||
with pytest.raises(brozzler.ReachedLimit) as excinfo:
|
||||
browser.browse_page(url)
|
||||
assert excinfo.value.warcprox_meta == WARCPROX_META_420
|
||||
|
||||
def test_js_dialogs(httpd):
|
||||
chrome_exe = brozzler.suggest_default_chrome_exe()
|
||||
url = 'http://localhost:%s/site4/alert.html' % httpd.server_port
|
||||
with brozzler.Browser(chrome_exe=chrome_exe) as browser:
|
||||
# before commit d2ed6b97a24 these would hang and eventually raise
|
||||
# brozzler.browser.BrowsingTimeout, which would cause this test to fail
|
||||
browser.browse_page(
|
||||
'http://localhost:%s/site4/alert.html' % httpd.server_port)
|
||||
browser.browse_page(
|
||||
'http://localhost:%s/site4/confirm.html' % httpd.server_port)
|
||||
browser.browse_page(
|
||||
'http://localhost:%s/site4/prompt.html' % httpd.server_port)
|
||||
# XXX print dialog unresolved
|
||||
# browser.browse_page(
|
||||
# 'http://localhost:%s/site4/print.html' % httpd.server_port)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user