Remove the console polyfills

All browsers that we intend to support with PDF.js version 2.0 already supports `console` natively.
This commit is contained in:
Jonas Jenwald 2017-11-16 09:34:51 +01:00
parent e162df59bb
commit 42099c564f
2 changed files with 0 additions and 88 deletions

View File

@ -1363,13 +1363,6 @@ var PDFWorker = (function PDFWorkerClosure() {
}
});
messageHandler.on('console_log', function (data) {
console.log.apply(console, data);
});
messageHandler.on('console_error', function (data) {
console.error.apply(console, data);
});
messageHandler.on('ready', (data) => {
worker.removeEventListener('error', onWorkerError);
if (this.destroyed) {

View File

@ -347,87 +347,6 @@ PDFJS.compatibilityChecked = true;
});
})();
// Checking if worker has console support. Forwarding all messages to the main
// thread if console object is absent.
(function checkWorkerConsoleCompatibility() {
if (typeof importScripts === 'undefined' || 'console' in globalScope) {
return;
}
var consoleTimer = {};
var workerConsole = {
log: function log() {
var args = Array.prototype.slice.call(arguments);
globalScope.postMessage({
targetName: 'main',
action: 'console_log',
data: args,
});
},
error: function error() {
var args = Array.prototype.slice.call(arguments);
globalScope.postMessage({
targetName: 'main',
action: 'console_error',
data: args,
});
},
time: function time(name) {
consoleTimer[name] = Date.now();
},
timeEnd: function timeEnd(name) {
var time = consoleTimer[name];
if (!time) {
throw new Error('Unknown timer name ' + name);
}
this.log('Timer:', name, Date.now() - time);
},
};
globalScope.console = workerConsole;
})();
// Check console compatibility
// In older IE versions the console object is not available
// unless console is open.
// Support: IE<10
(function checkConsoleCompatibility() {
if (!hasDOM) {
return;
}
if (!('console' in window)) {
window.console = {
log() {},
error() {},
warn() {},
};
return;
}
if (!('bind' in console.log)) {
// native functions in IE9 might not have bind
console.log = (function(fn) {
return function(msg) {
return fn(msg);
};
})(console.log);
console.error = (function(fn) {
return function(msg) {
return fn(msg);
};
})(console.error);
console.warn = (function(fn) {
return function(msg) {
return fn(msg);
};
})(console.warn);
return;
}
})();
// Check onclick compatibility in Opera
// Support: Opera<15
(function checkOnClickCompatibility() {