import Q = require('q');

import crypto_worker = require('./crypto_worker');
import env = require('./base/env');
import rpc = require('./net/rpc');
import testLib = require('./test');

if (env.isNodeJS()) {
	global.Worker = require('./node_worker').Worker;
}

testLib.addAsyncTest('worker test', (assert) => {
	let done = Q.defer<void>();

	let scriptPath = crypto_worker.SCRIPT_PATH;
	let worker = new Worker(scriptPath);

	let rpcHandler = new rpc.RpcHandler(new rpc.WindowMessagePort(worker, '*', 'crypto-worker', 'passcards'));
	rpcHandler.call('pbkdf2Block', ['inputPass', 'inputSalt', 100 /* iterations */, 0 /* blockIndex */],
		(err: any, block: string) => {
			assert.equal(err, null);
			assert.equal(block.length, 20);
			worker.terminate();
			done.resolve(null);
		});

	return done.promise;
});


import Q = require('q');

import crypto_worker = require('./crypto_worker');
import env = require('./base/env');
import rpc = require('./net/rpc');
import testLib = require('./test');

if (env.isNodeJS()) {
	Worker = require('./node_worker').Worker;
}

testLib.addAsyncTest('worker test', (assert) => {
	let done = Q.defer<void>();

	let scriptPath = crypto_worker.SCRIPT_PATH;
	let worker = new Worker(scriptPath);

	let rpcHandler = new rpc.RpcHandler(new rpc.WindowMessagePort(worker, '*', 'crypto-worker', 'passcards'));
	rpcHandler.call('pbkdf2Block', ['inputPass', 'inputSalt', 100 /* iterations */, 0 /* blockIndex */],
		(err: any, block: string) => {
			assert.equal(err, null);
			assert.equal(block.length, 20);
			worker.terminate();
			done.resolve(null);
		});

	return done.promise;
});


--- 
+++ 
@@ -6,7 +6,7 @@
 import testLib = require('./test');
 
 if (env.isNodeJS()) {
-	Worker = require('./node_worker').Worker;
+	global.Worker = require('./node_worker').Worker;
 }
 
 testLib.addAsyncTest('worker test', (assert) => {
Fix crypto test under current versions of Node

TypeScript >= 1.8.x adds "use strict"
at the top of modules, making the implicit assignment
to global.Worker fail.
