1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-22 17:02:17 -05:00

web worker tests work again

This commit is contained in:
Tankred Hase 2013-06-11 00:55:53 +02:00
parent 0e9be73791
commit 1368672c1d
7 changed files with 97 additions and 76 deletions

View File

@ -51,6 +51,7 @@ module.exports = function(grunt) {
qunit: {
all: {
options: {
timeout: 20000,
urls: [
'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'

View File

@ -2,21 +2,23 @@
'use strict';
// import web worker dependencies
importScripts('../../lib/forge/forge.rsa.bundle.js');
importScripts('../app-config.js');
importScripts('./crypto-batch.js');
importScripts('./aes-cbc.js');
importScripts('../../lib/require.js');
/**
* In the web worker thread context, 'this' and 'self' can be used as a global
* variable namespace similar to the 'window' object in the main thread
*/
self.onmessage = function(e) {
// fetch dependencies via require.js
require(['../../require-config'], function() {
require.config({
baseUrl: '../../lib'
});
require(['cryptoLib/crypto-batch'], function(batch) {
var i = e.data,
output = null,
aes = new cryptoLib.AesCBC(forge),
batch = new cryptoLib.CryptoBatch(aes);
output = null;
if (i.type === 'encrypt' && i.list) {
// start encryption
@ -32,6 +34,9 @@
// pass output back to main thread
self.postMessage(output);
});
});
};
}());

View File

@ -2,19 +2,23 @@
'use strict';
// import web worker dependencies
importScripts('../../lib/forge/forge.rsa.bundle.js');
importScripts('../app-config.js');
importScripts('./aes-cbc.js');
importScripts('../../lib/require.js');
/**
* In the web worker thread context, 'this' and 'self' can be used as a global
* variable namespace similar to the 'window' object in the main thread
*/
self.onmessage = function(e) {
// fetch dependencies via require.js
require(['../../require-config'], function() {
require.config({
baseUrl: '../../lib'
});
require(['cryptoLib/aes-cbc'], function(aes) {
var i = e.data,
output = null,
aes = new cryptoLib.AesCBC(forge);
output = null;
if (i.type === 'encrypt' && i.plaintext && i.key && i.iv) {
// start encryption
@ -30,6 +34,9 @@
// pass output back to main thread
self.postMessage(output);
});
});
};
}());

View File

@ -2,26 +2,23 @@
'use strict';
// import web worker dependencies
importScripts('../../lib/underscore-1.4.4.min.js');
importScripts('../../lib/forge/forge.rsa.bundle.js');
importScripts('../app-config.js');
importScripts('./crypto-batch.js');
importScripts('./aes-cbc.js');
importScripts('./util.js');
importScripts('./rsa.js');
importScripts('../../lib/require.js');
/**
* In the web worker thread context, 'this' and 'self' can be used as a global
* variable namespace similar to the 'window' object in the main thread
*/
self.onmessage = function(e) {
// fetch dependencies via require.js
require(['../../require-config'], function() {
require.config({
baseUrl: '../../lib'
});
require(['cryptoLib/crypto-batch'], function(batch) {
var i = e.data,
output = null,
aes = new cryptoLib.AesCBC(forge),
rsa = new cryptoLib.RSA(forge),
util = new cryptoLib.Util(),
batch = new cryptoLib.CryptoBatch(aes, rsa, util, _);
output = null;
if (i.type === 'encrypt' && i.receiverPubkeys && i.senderPrivkey && i.list) {
// start encryption
@ -37,6 +34,9 @@
// pass output back to main thread
self.postMessage(output);
});
});
};
}());

View File

@ -2,7 +2,9 @@
* High level crypto api that invokes native crypto (if available) and
* gracefully degrades to JS crypto (if unavailable)
*/
define(['cryptoLib/util', 'cryptoLib/aes-cbc', 'cryptoLib/rsa', 'cryptoLib/crypto-batch', 'js/crypto/pbkdf2'], function(util, aes, rsa, cryptoBatch, pbkdf2) {
define(['cryptoLib/util', 'cryptoLib/aes-cbc', 'cryptoLib/rsa', 'cryptoLib/crypto-batch',
'js/crypto/pbkdf2'
], function(util, aes, rsa, cryptoBatch, pbkdf2) {
'use strict';
var self = {};

View File

@ -2,22 +2,26 @@
'use strict';
// import web worker dependencies
importScripts('../../lib/forge/forge.rsa.bundle.js');
importScripts('../app-config.js');
importScripts('./pbkdf2.js');
importScripts('../../lib/require.js');
/**
* In the web worker thread context, 'this' and 'self' can be used as a global
* variable namespace similar to the 'window' object in the main thread
*/
self.onmessage = function(e) {
// fetch dependencies via require.js
require(['../../require-config'], function() {
require.config({
baseUrl: '../../lib'
});
require(['js/crypto/pbkdf2'], function(pbkdf2) {
var i = e.data,
key = null;
if (i.password && i.keySize) {
// start deriving key
var pbkdf2 = new app.crypto.PBKDF2();
key = pbkdf2.getKey(i.password, i.keySize);
} else {
@ -26,6 +30,9 @@
// pass output back to main thread
self.postMessage(key);
});
});
};
}());

View File

@ -13,7 +13,6 @@ require(['../../src/require-config'], function() {
window.Worker = undefined;
app.config.workerPath = '../../src/js';
app.config.cloudUrl = 'http://localhost:8888';
startTests();
});