mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 10:15:37 +02:00
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:
parent
e162df59bb
commit
42099c564f
2 changed files with 0 additions and 88 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue