summaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-09-03 09:20:00 +0200
committerBenoit Foucher <benoit@zeroc.com>2015-09-03 09:20:00 +0200
commit71b622ef86f3e42c3e9a059a8a4ad418882eb2b0 (patch)
tree9978b0e5e3641c9fa83baac484c2d9578daa0cbf /js/src
parentFixed test controller hang if server process failed to start (diff)
downloadice-71b622ef86f3e42c3e9a059a8a4ad418882eb2b0.tar.bz2
ice-71b622ef86f3e42c3e9a059a8a4ad418882eb2b0.tar.xz
ice-71b622ef86f3e42c3e9a059a8a4ad418882eb2b0.zip
Fixed ICE-6769 - fallback code in case Worker and blob URLs aren't supported
Diffstat (limited to 'js/src')
-rw-r--r--js/src/Ice/browser/TimerUtil.js32
1 files changed, 26 insertions, 6 deletions
diff --git a/js/src/Ice/browser/TimerUtil.js b/js/src/Ice/browser/TimerUtil.js
index 518cd3c8dbc..ae15429c771 100644
--- a/js/src/Ice/browser/TimerUtil.js
+++ b/js/src/Ice/browser/TimerUtil.js
@@ -22,13 +22,11 @@ if(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope
// If running in a worker we don't need to create a separate worker for the timers
//
var Timer = {};
-
Timer.setTimeout = setTimeout;
Timer.clearTimeout = clearTimeout;
Timer.setInterval = setInterval;
Timer.clearInterval = clearInterval;
Timer.setImmediate = setImmediate;
-
Ice.Timer = Timer;
}
else
@@ -176,9 +174,31 @@ else
if(worker === undefined)
{
- worker = new Worker(window.URL.createObjectURL(new Blob([workerCode()], {type : 'text/javascript'})));
- worker.onmessage = Timer.onmessage;
- }
+ var url;
+ try
+ {
+ url = window.URL.createObjectURL(new Blob([workerCode()], {type : 'text/javascript'}));
+ worker = new Worker(url);
+ worker.onmessage = Timer.onmessage;
+ Ice.Timer = Timer;
+ }
+ catch(ex)
+ {
+ window.URL.revokeObjectURL(url)
- Ice.Timer = Timer;
+ //
+ // Fallback on setInterval/setTimeout if the worker creating failed. Some IE10 and IE11 don't
+ // support creating workers from blob URLs for instance. Note that we also have to use apply
+ // with null as the first argument to workaround an issue where IE doesn't like these functions
+ // to be called with an unknown object (it reports an "Invalid calling object" error).
+ //
+ var Timer = {};
+ Timer.setTimeout = function () { setTimeout.apply(null, arguments); }
+ Timer.clearTimeout = function () { clearTimeout.apply(null, arguments); };
+ Timer.setInterval = function () { setInterval.apply(null, arguments); };
+ Timer.clearInterval = function () { clearInterval.apply(null, arguments); };
+ Timer.setImmediate = function () { setImmediate.apply(null, arguments); }
+ Ice.Timer = Timer;
+ }
+ }
}