Merge pull request #9140 from Snuffleupagus/rm-console-polyfill
Remove the `console` polyfills
This commit is contained in:
commit
9e8cf448b0
@ -1360,13 +1360,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) => {
|
messageHandler.on('ready', (data) => {
|
||||||
worker.removeEventListener('error', onWorkerError);
|
worker.removeEventListener('error', onWorkerError);
|
||||||
if (this.destroyed) {
|
if (this.destroyed) {
|
||||||
|
@ -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
|
// Check onclick compatibility in Opera
|
||||||
// Support: Opera<15
|
// Support: Opera<15
|
||||||
(function checkOnClickCompatibility() {
|
(function checkOnClickCompatibility() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user