moar stuff
This commit is contained in:
parent
42de35dd72
commit
4595ad0fc4
3 changed files with 59 additions and 1 deletions
|
@ -565,7 +565,7 @@ function doAjax(param) {
|
|||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
var code = jqXHR.status;
|
||||
if (code == 200) {// happens sometimes when we get no response
|
||||
if (code == 200) {// happens sometimes when we get no response (TODO: Fix server to return 204? instead)
|
||||
if (param.success_callback !== undefined)
|
||||
param.success_callback(null);
|
||||
return;
|
||||
|
|
21
test.html
Normal file
21
test.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<html>
|
||||
|
||||
<head><title>TextSecure test runner</title></head>
|
||||
<body>
|
||||
|
||||
<h1>Run this out of the chrome-plugin:// namespace (and expect plugin state to be cleared/corrupted), not file://</h1>
|
||||
<div id="tests">
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="jquery.atmosphere.js"></script>
|
||||
<script type="text/javascript" src="aes.js"></script>
|
||||
<script type="text/javascript" src="hmac-sha256.js"></script>
|
||||
<script type="text/javascript" src="lib-typedarrays.js"></script>
|
||||
<script type="text/javascript" src="Long.min.js"></script>
|
||||
<script type="text/javascript" src="ByteBuffer.min.js"></script>
|
||||
<script type="text/javascript" src="ProtoBuf.min.js"></script>
|
||||
<script type="text/javascript" src="helpers.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
</html>
|
37
test.js
Normal file
37
test.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Setup dumb test wrapper
|
||||
var testsdiv = $('#tests');
|
||||
function TEST(func, name) {
|
||||
var funcName = name === undefined ? func + "" : name;
|
||||
try {
|
||||
if (func())
|
||||
testsdiv.append('<p style="color: green;">' + funcName + ' passed</p>');
|
||||
else
|
||||
testsdiv.append('<p style="color: red;">' + funcName + ' returned false</p>');
|
||||
} catch (e) {
|
||||
testsdiv.append('<p style="color: red;">' + funcName + ' threw ' + e + '</p>');
|
||||
}
|
||||
}
|
||||
|
||||
// Random tests to check my JS knowledge
|
||||
TEST(function() { return !objectContainsKeys({}); });
|
||||
TEST(function() { return objectContainsKeys({ a: undefined }); });
|
||||
TEST(function() { return objectContainsKeys({ a: null }); });
|
||||
|
||||
// Basic sanity-checks on the crypto library
|
||||
TEST(function() {
|
||||
var PushMessageProto = dcodeIO.ProtoBuf.loadProtoFile("IncomingPushMessageSignal.proto").build("textsecure.PushMessageContent");
|
||||
var IncomingMessageProto = dcodeIO.ProtoBuf.loadProtoFile("IncomingPushMessageSignal.proto").build("textsecure.IncomingPushMessageSignal");
|
||||
|
||||
var text_message = new PushMessageProto();
|
||||
text_message.body = "Hi Mom";
|
||||
var server_message = {type: 0, // unencrypted
|
||||
source: "+19999999999", timestamp: 42, message: text_message.encode() };
|
||||
|
||||
crypto.handleIncomingPushMessageProto(server_message);
|
||||
return server_message.message.body == text_message.body &&
|
||||
server_message.message.attachments.length == text_message.attachments.length &&
|
||||
text_message.attachments.length == 0;
|
||||
}, 'Unencrypted PushMessageProto "decrypt"');
|
||||
|
||||
// TODO: Run through the test vectors for the axolotl ratchet
|
||||
|
Loading…
Reference in a new issue