diff --git a/package.json b/package.json index 91f23305..121cf610 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openpgp", "description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.", - "version": "0.9.0", + "version": "0.10.0", "homepage": "http://openpgpjs.org/", "engines": { "node": ">=0.8" diff --git a/src/openpgp.js b/src/openpgp.js index f70d9f9c..e02fe8d8 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -56,8 +56,9 @@ var asyncProxy = null; // instance of the asyncproxy * @return {Boolean} true if worker created successfully */ function initWorker(path, options) { - if (options && options.worker || - typeof window !== 'undefined' && window.Worker) { + if (options && options.worker || typeof window !== 'undefined' && window.Worker) { + options = options || {}; + options.config = this.config; asyncProxy = new AsyncProxy(path, options); return true; } else { diff --git a/src/worker/async_proxy.js b/src/worker/async_proxy.js index 2a9b6699..f94201c6 100644 --- a/src/worker/async_proxy.js +++ b/src/worker/async_proxy.js @@ -38,6 +38,7 @@ var INITIAL_RANDOM_SEED = 50000, // random bytes seeded to worker * Initializes a new proxy and loads the web worker * @constructor * @param {String} path The path to the worker or 'openpgp.worker.js' by default + * @param {Object} [options.config=Object] config The worker configuration * @param {Object} [options.worker=Object] alternative to path parameter: * web worker initialized with 'openpgp.worker.js' */ @@ -54,7 +55,7 @@ function AsyncProxy(path, options) { this.seedRandom(INITIAL_RANDOM_SEED); // FIFO this.tasks = []; - this.worker.postMessage({event: 'configure', config: config}); + this.worker.postMessage({event: 'configure', config: options.config}); } /** diff --git a/src/worker/worker.js b/src/worker/worker.js index 2b20f0e9..beb81aec 100644 --- a/src/worker/worker.js +++ b/src/worker/worker.js @@ -54,10 +54,10 @@ self.onmessage = function (event) { switch (msg.event) { case 'configure': - for(var i in msg.config){ + for (var i in msg.config) { window.openpgp.config[i] = msg.config[i]; } - break; + break; case 'seed-random': if (!(msg.buf instanceof Uint8Array)) { msg.buf = new Uint8Array(msg.buf); diff --git a/test/worker/api.js b/test/worker/api.js index 424c3b6d..d23d8a60 100644 --- a/test/worker/api.js +++ b/test/worker/api.js @@ -202,13 +202,13 @@ describe('High level API', function() { describe('Main', function(){ it('Configuration', function(done){ - openpgp.config.show_comment = false; openpgp.config.show_version = false; + openpgp.config.commentstring = 'different'; openpgp.initWorker('../dist/openpgp.worker.js'); openpgp.encryptMessage([pubKeyRSA], plaintext).then(function(data) { expect(data).to.exist; expect(data).not.to.match(/^Version:/); - expect(data).not.to.match(/^Comment:/); + expect(data).to.match(/Comment: different/); done(); }); });