Index: lib/adblockplus_compat.js |
=================================================================== |
--- a/lib/adblockplus_compat.js |
+++ b/lib/adblockplus_compat.js |
@@ -147,8 +147,8 @@ |
readFromFile: function(file, decode, listener, callback, timeLineID) |
{ |
- // Fake asynchronous execution |
- setTimeout(function() |
+ var Utils = require("utils").Utils; |
+ Utils.runAsync(function() |
{ |
if ("spec" in file && /^defaults\b/.test(file.spec)) |
{ |
@@ -173,7 +173,7 @@ |
listener.process(lines[i]); |
listener.process(null); |
callback(null); |
- }.bind(this), 0); |
+ }.bind(this)); |
}, |
writeToFile: function(file, encode, data, callback, timeLineID) |
@@ -308,10 +308,16 @@ |
runAsync: function(callback, thisPtr) |
{ |
var params = Array.prototype.slice.call(arguments, 2); |
- window.setTimeout(function() |
+ |
+ function invokeCallback() |
{ |
callback.apply(thisPtr, params); |
- }, 0); |
+ } |
+ |
+ if (document.readyState === "complete") |
+ window.setTimeout(invokeCallback); |
Wladimir Palant
2012/11/21 15:47:58
setTimeout(..., 0)?
Felix Dahlke
2012/11/21 15:56:56
You're right. This only worked because the readySt
|
+ else |
+ window.addEventListener("load", invokeCallback); |
}, |
get appLocale() |
{ |