add emit() function to script scope in worker scripts. add tests.