Fix global object handling in worker script JS files.

Task-number: QTBUG-36874
Task-number: QTBUG-36881
Change-Id: Iacf4807dd37862e792ad1ba4ce540a6d48f1e495
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>