aboutsummaryrefslogtreecommitdiff
path: root/tools
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 /tools
parent10b92e403dd2128fb3df40658eb88bbc7c7bd517 (diff)
fix file preloading in workers and add test
Diffstat (limited to 'tools')
-rw-r--r--tools/file_packager.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py
index 3ba5b23f..7d9344cd 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -453,7 +453,13 @@ if has_preloaded:
package_uuid = uuid.uuid4();
remote_package_name = os.path.basename(Compression.compressed_name(data_target) if Compression.on else data_target)
code += r'''
- var PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
+ var PACKAGE_PATH;
+ if (typeof window === 'object') {
+ PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
+ } else {
+ // worker
+ PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/');
+ }
var PACKAGE_NAME = '%s';
var REMOTE_PACKAGE_NAME = '%s';
var PACKAGE_UUID = '%s';