Merge pull request #6913 from Rob--W/importScripts-work-around

Improve work-around for importScripts bug.
This commit is contained in:
Tim van der Meij 2016-02-04 19:51:26 +01:00
commit a0aa781c39
2 changed files with 11 additions and 9 deletions

View File

@ -1301,16 +1301,7 @@ var PDFWorker = (function PDFWorkerClosure() {
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
var worker = new Worker(workerSrc);
var messageHandler = new MessageHandler('main', 'worker', worker);
//#if !PRODUCTION
// Don't allow worker to be destroyed by Chrome, see:
// https://code.google.com/p/chromium/issues/detail?id=572225
var jsWorkerId = '_workerKungfuGrip_' + Math.random();
window[jsWorkerId] = worker;
//#endif
messageHandler.on('test', function PDFWorker_test(data) {
//#if !PRODUCTION
delete window[jsWorkerId];
//#endif
if (this.destroyed) {
this._readyCapability.reject(new Error('Worker was destroyed'));
messageHandler.destroy();

View File

@ -15,6 +15,17 @@
'use strict';
//#if !PRODUCTION
//// Patch importScripts to work around a bug in WebKit and Chrome 48-.
//// See https://crbug.com/572225 and https://webkit.org/b/153317.
self.importScripts = (function (importScripts) {
return function() {
setTimeout(function () {}, 0);
return importScripts.apply(this, arguments);
};
})(importScripts);
//#endif
importScripts('../node_modules/requirejs/require.js');
require.config({paths: {'pdfjs': '.'}});