Hi there,
We have a problem, and I'm not sure in which project to report it: jquery, jquery.forms or webdriver.
We're using jquery.forms as part of a file upload page. In order to test this page, we use webdriver.
We need to test what happens on the page while a user uploads a large file. In order to simulate this, we have the server block upon serving the request it receives in response to the user clicking on 'upload'. But, since this upload happens via a call to .ajaxSubmit, it should not block the browser itself, allowing us to further interact with the browser in the test.
That's the theory.
The plan works well, except when one includes a an uploadProgress function in the call to .ajaxSubmit.
If you do this, and only if you do this, new commands to webdriver are blocked.
This seems to be related to setting xhr.upload.onprogress on line 241 of jquery.form.js (3.14). If that does not happen, everything works as expected.
We're using jquery 1.8.2, jquery.form 3.14, selenium 2.25.0 and firefox 13.
Can anyone help in pointing out the right project to report this in?
Here is some python code that reproduces the issue. It needs
distribute, webob and selenium in order to run.
(With distribute installed, you can just run "pip install webob selenium" to get the other two.)
- from threading import Thread, Event, current_thread
- from wsgiref import simple_server
- from pkg_resources import require
- require('selenium >= 2.25.0')
- require('webob >= 1.2.2')
- from selenium import webdriver
- from webob import Request, Response
- from webob.exc import HTTPNotFound
- html = '''
- <!DOCTYPE html>
- <head><title>Home page</title>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
- <script src="http://malsup.github.com/jquery.form.js"></script>
- <!-- <script type="text/javascript" src="/static/jquery.form-3.14.js"></script> -->
- <script type="text/javascript">
- jQuery(document).ready(function($){
- $("input[name='upload']").click(function(){
- $('#testform').ajaxSubmit({
- uploadProgress: function(event, position, total, percentComplete){
- }
- });
- return false;
- });
- });
- </script>
- </head>
- <body>
- <form id="testform" action="/blocking_url" enctype="multipart/form-data" method="POST">
- <input name="uploaded_file" type="file">
- <input name="upload" value="Upload" type="submit">
- </form>
- </body>
- '''
- class SimpleApp(object):
- def __call__(self, environ, start_response):
- self.request = Request(environ)
- response = None
- if self.request.path == '/':
- response = Response(body=html)
- elif self.request.path == '/blocking_url':
- print 'BLOCKING'
- Event().wait()
- assert None, 'UNBLOCKED!'
- else:
- response = HTTPNotFound()
- return response(environ, start_response)
-
- class MultiThreadedServer(simple_server.WSGIServer):
- def handle_request(self):
- thread = Thread(target=super(MultiThreadedServer, self).handle_request)
- thread.daemon = True
- thread.start()
- app = SimpleApp()
- httpd = simple_server.make_server('', 8000, app, server_class=MultiThreadedServer)
- http_thread = Thread(target=httpd.serve_forever)
- http_thread.daemon=True
- http_thread.start()
- wd = webdriver.Firefox()
- wd.get('http://localhost:8000/')
- wd.find_element_by_name('uploaded_file').send_keys('/etc/hosts')
- print 'GOING TO CLICK upload'
- wd.find_element_by_name('upload').click()
- print 'CLICKED upload'
- print 'GOING TO GET TITLE'
- print wd.title
- print 'DONE GETTING TITLE'
- wd.close()