Merge pull request #6913 from Rob--W/importScripts-work-around
Improve work-around for importScripts bug.
This commit is contained in:
		
						commit
						a0aa781c39
					
				@ -1301,16 +1301,7 @@ var PDFWorker = (function PDFWorkerClosure() {
 | 
				
			|||||||
          // https://bugzilla.mozilla.org/show_bug.cgi?id=683280
 | 
					          // https://bugzilla.mozilla.org/show_bug.cgi?id=683280
 | 
				
			||||||
          var worker = new Worker(workerSrc);
 | 
					          var worker = new Worker(workerSrc);
 | 
				
			||||||
          var messageHandler = new MessageHandler('main', 'worker', worker);
 | 
					          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) {
 | 
					          messageHandler.on('test', function PDFWorker_test(data) {
 | 
				
			||||||
//#if !PRODUCTION
 | 
					 | 
				
			||||||
            delete window[jsWorkerId];
 | 
					 | 
				
			||||||
//#endif
 | 
					 | 
				
			||||||
            if (this.destroyed) {
 | 
					            if (this.destroyed) {
 | 
				
			||||||
              this._readyCapability.reject(new Error('Worker was destroyed'));
 | 
					              this._readyCapability.reject(new Error('Worker was destroyed'));
 | 
				
			||||||
              messageHandler.destroy();
 | 
					              messageHandler.destroy();
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,17 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
'use strict';
 | 
					'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');
 | 
					importScripts('../node_modules/requirejs/require.js');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require.config({paths: {'pdfjs': '.'}});
 | 
					require.config({paths: {'pdfjs': '.'}});
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user