mirror of
https://github.com/moparisthebest/mail
synced 2024-11-26 10:52:17 -05:00
web worker tests work again
This commit is contained in:
parent
0e9be73791
commit
1368672c1d
@ -51,6 +51,7 @@ module.exports = function(grunt) {
|
|||||||
qunit: {
|
qunit: {
|
||||||
all: {
|
all: {
|
||||||
options: {
|
options: {
|
||||||
|
timeout: 20000,
|
||||||
urls: [
|
urls: [
|
||||||
'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
|
'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
|
||||||
'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'
|
'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'
|
||||||
|
@ -2,21 +2,23 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// import web worker dependencies
|
// import web worker dependencies
|
||||||
importScripts('../../lib/forge/forge.rsa.bundle.js');
|
importScripts('../../lib/require.js');
|
||||||
importScripts('../app-config.js');
|
|
||||||
importScripts('./crypto-batch.js');
|
|
||||||
importScripts('./aes-cbc.js');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the web worker thread context, 'this' and 'self' can be used as a global
|
* 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
|
* variable namespace similar to the 'window' object in the main thread
|
||||||
*/
|
*/
|
||||||
self.onmessage = function(e) {
|
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,
|
var i = e.data,
|
||||||
output = null,
|
output = null;
|
||||||
aes = new cryptoLib.AesCBC(forge),
|
|
||||||
batch = new cryptoLib.CryptoBatch(aes);
|
|
||||||
|
|
||||||
if (i.type === 'encrypt' && i.list) {
|
if (i.type === 'encrypt' && i.list) {
|
||||||
// start encryption
|
// start encryption
|
||||||
@ -32,6 +34,9 @@
|
|||||||
|
|
||||||
// pass output back to main thread
|
// pass output back to main thread
|
||||||
self.postMessage(output);
|
self.postMessage(output);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}());
|
}());
|
@ -2,19 +2,23 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// import web worker dependencies
|
// import web worker dependencies
|
||||||
importScripts('../../lib/forge/forge.rsa.bundle.js');
|
importScripts('../../lib/require.js');
|
||||||
importScripts('../app-config.js');
|
|
||||||
importScripts('./aes-cbc.js');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the web worker thread context, 'this' and 'self' can be used as a global
|
* 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
|
* variable namespace similar to the 'window' object in the main thread
|
||||||
*/
|
*/
|
||||||
self.onmessage = function(e) {
|
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,
|
var i = e.data,
|
||||||
output = null,
|
output = null;
|
||||||
aes = new cryptoLib.AesCBC(forge);
|
|
||||||
|
|
||||||
if (i.type === 'encrypt' && i.plaintext && i.key && i.iv) {
|
if (i.type === 'encrypt' && i.plaintext && i.key && i.iv) {
|
||||||
// start encryption
|
// start encryption
|
||||||
@ -30,6 +34,9 @@
|
|||||||
|
|
||||||
// pass output back to main thread
|
// pass output back to main thread
|
||||||
self.postMessage(output);
|
self.postMessage(output);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}());
|
}());
|
@ -2,26 +2,23 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// import web worker dependencies
|
// import web worker dependencies
|
||||||
importScripts('../../lib/underscore-1.4.4.min.js');
|
importScripts('../../lib/require.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');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the web worker thread context, 'this' and 'self' can be used as a global
|
* 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
|
* variable namespace similar to the 'window' object in the main thread
|
||||||
*/
|
*/
|
||||||
self.onmessage = function(e) {
|
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,
|
var i = e.data,
|
||||||
output = null,
|
output = null;
|
||||||
aes = new cryptoLib.AesCBC(forge),
|
|
||||||
rsa = new cryptoLib.RSA(forge),
|
|
||||||
util = new cryptoLib.Util(),
|
|
||||||
batch = new cryptoLib.CryptoBatch(aes, rsa, util, _);
|
|
||||||
|
|
||||||
if (i.type === 'encrypt' && i.receiverPubkeys && i.senderPrivkey && i.list) {
|
if (i.type === 'encrypt' && i.receiverPubkeys && i.senderPrivkey && i.list) {
|
||||||
// start encryption
|
// start encryption
|
||||||
@ -37,6 +34,9 @@
|
|||||||
|
|
||||||
// pass output back to main thread
|
// pass output back to main thread
|
||||||
self.postMessage(output);
|
self.postMessage(output);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}());
|
}());
|
@ -2,7 +2,9 @@
|
|||||||
* High level crypto api that invokes native crypto (if available) and
|
* High level crypto api that invokes native crypto (if available) and
|
||||||
* gracefully degrades to JS crypto (if unavailable)
|
* 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';
|
'use strict';
|
||||||
|
|
||||||
var self = {};
|
var self = {};
|
||||||
|
@ -2,22 +2,26 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// import web worker dependencies
|
// import web worker dependencies
|
||||||
importScripts('../../lib/forge/forge.rsa.bundle.js');
|
importScripts('../../lib/require.js');
|
||||||
importScripts('../app-config.js');
|
|
||||||
importScripts('./pbkdf2.js');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the web worker thread context, 'this' and 'self' can be used as a global
|
* 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
|
* variable namespace similar to the 'window' object in the main thread
|
||||||
*/
|
*/
|
||||||
self.onmessage = function(e) {
|
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,
|
var i = e.data,
|
||||||
key = null;
|
key = null;
|
||||||
|
|
||||||
if (i.password && i.keySize) {
|
if (i.password && i.keySize) {
|
||||||
// start deriving key
|
// start deriving key
|
||||||
var pbkdf2 = new app.crypto.PBKDF2();
|
|
||||||
key = pbkdf2.getKey(i.password, i.keySize);
|
key = pbkdf2.getKey(i.password, i.keySize);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -26,6 +30,9 @@
|
|||||||
|
|
||||||
// pass output back to main thread
|
// pass output back to main thread
|
||||||
self.postMessage(key);
|
self.postMessage(key);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}());
|
}());
|
@ -13,7 +13,6 @@ require(['../../src/require-config'], function() {
|
|||||||
window.Worker = undefined;
|
window.Worker = undefined;
|
||||||
|
|
||||||
app.config.workerPath = '../../src/js';
|
app.config.workerPath = '../../src/js';
|
||||||
app.config.cloudUrl = 'http://localhost:8888';
|
|
||||||
|
|
||||||
startTests();
|
startTests();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user