Skip to content

Commit

Permalink
Merge pull request #6913 from Rob--W/importScripts-work-around
Browse files Browse the repository at this point in the history
Improve work-around for importScripts bug.
  • Loading branch information
timvandermeij committed Feb 4, 2016
2 parents 4c59712 + 097e273 commit a0aa781
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions src/worker_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': '.'}});
Expand Down

0 comments on commit a0aa781

Please sign in to comment.