aboutsummaryrefslogtreecommitdiff
path: root/tests/test_browser.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-02 16:17:23 -0500
committerAlon Zakai <alonzakai@gmail.com>2013-12-02 16:17:23 -0500
commita42f659391fcbd0b85b29e5b8725b48a364eb20e (patch)
tree1bdf2e538a4bc630dbb39bfac40a3dea7369b671 /tests/test_browser.py
parent10b92e403dd2128fb3df40658eb88bbc7c7bd517 (diff)
fix file preloading in workers and add test
Diffstat (limited to 'tests/test_browser.py')
-rw-r--r--tests/test_browser.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/test_browser.py b/tests/test_browser.py
index b2cd62f8..d0618af8 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -1218,10 +1218,7 @@ keydown(100);keyup(100); // trigger the end
def test_worker(self):
# Test running in a web worker
- output = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_worker.cpp'), '-o', 'worker.js'], stdout=PIPE, stderr=PIPE).communicate()
- assert len(output[0]) == 0, output[0]
- assert os.path.exists('worker.js'), output
- self.assertContained('you should not see this text when in a worker!', run_js('worker.js')) # code should run standalone
+ open('file.dat', 'w').write('data for worker')
html_file = open('main.html', 'w')
html_file.write('''
<html>
@@ -1240,7 +1237,15 @@ keydown(100);keyup(100); // trigger the end
</html>
''')
html_file.close()
- self.run_browser('main.html', 'You should see that the worker was called, and said "hello from worker!"', '/report_result?hello%20from%20worker!')
+
+ # no file data
+ for file_data in [0, 1]:
+ print 'file data', file_data
+ output = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_worker.cpp'), '-o', 'worker.js'] + (['--preload-file', 'file.dat'] if file_data else []) , stdout=PIPE, stderr=PIPE).communicate()
+ assert len(output[0]) == 0, output[0]
+ assert os.path.exists('worker.js'), output
+ if not file_data: self.assertContained('you should not see this text when in a worker!', run_js('worker.js')) # code should run standalone
+ self.run_browser('main.html', '', '/report_result?hello%20from%20worker,%20and%20|' + ('data%20for%20w' if file_data else '') + '|')
def test_chunked_synchronous_xhr(self):
main = 'chunked_sync_xhr.html'