2016-12-01 18:01:20 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* `setTimeout` changes context of execution from other window
|
|
|
|
(e.g. popup) to background window, so we may catch errors
|
|
|
|
in bg error handlers.
|
|
|
|
More: https://bugs.chromium.org/p/chromium/issues/detail?id=357568
|
2016-12-02 21:52:11 +03:00
|
|
|
|
|
|
|
setTimeout is applied to Async methods only (name ends with Async)
|
2016-12-01 18:01:20 +03:00
|
|
|
*/
|
|
|
|
// Fix error context of methods of all APIs.
|
2016-12-02 21:52:11 +03:00
|
|
|
/*
|
|
|
|
for(const apiName of Object.keys(window.apis)) {
|
|
|
|
const api = window.apis[apiName];
|
2016-12-01 18:01:20 +03:00
|
|
|
for(const prop of Object.keys(api)) {
|
2016-12-02 21:52:11 +03:00
|
|
|
const method = api[prop];
|
|
|
|
if ( !(typeof(api[prop]) === 'function'
|
|
|
|
&& method.name.endsWith('Async')) ) {
|
2016-12-01 18:01:20 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
api[prop] = function(...args) {
|
|
|
|
|
|
|
|
setTimeout(method.bind(this, ...args), 0);
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
2016-12-02 21:52:11 +03:00
|
|
|
}*/
|