chrome extension eval support

This commit is contained in:
guybedford 2015-06-22 21:26:35 +02:00
parent 79a81e923a
commit be2db270a3

View File

@ -28,8 +28,23 @@ var __exec;
'\n//# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(load.metadata.sourceMap))) || '')
}
// Web Worker and Chrome Extensions use original ESML eval
// this may lead to some global module execution differences (eg var not defining onto global)
if (isWorker || isBrowser && window.chrome && window.chrome.extension) {
__exec = function(load) {
try {
preExec(this);
new Function(getSource(load)).call(__global);
postExec();
}
catch(e) {
throw addToError(e, 'Evaluating ' + load.address);
}
};
}
// use script injection eval to get identical global script behaviour
if (typeof document != 'undefined') {
else if (typeof document != 'undefined') {
var head;
var scripts = document.getElementsByTagName('script');
@ -55,20 +70,6 @@ var __exec;
throw e;
}
}
// Web Worker uses original ESML eval
// this may lead to some global module execution differences (eg var not defining onto global)
else if (isWorker) {
__exec = function(load) {
try {
preExec(this);
new Function(getSource(load)).call(__global);
postExec();
}
catch(e) {
throw addToError(e, 'Evaluating ' + load.address);
}
};
}
else {
// global scoped eval for node
var vmModule = 'vm';