mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-02 14:21:05 +01:00
Update electron to 16.0.4
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
node: false,
|
||||
mocha: true,
|
||||
},
|
||||
parserOptions: {
|
||||
sourceType: 'script',
|
||||
},
|
||||
rules: {
|
||||
strict: 'off',
|
||||
'more/no-then': 'off',
|
||||
},
|
||||
globals: {
|
||||
assert: true,
|
||||
getString: true,
|
||||
},
|
||||
};
|
||||
@@ -1,70 +0,0 @@
|
||||
// Copyright 2015-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* global chai */
|
||||
|
||||
mocha.setup('bdd');
|
||||
window.assert = chai.assert;
|
||||
|
||||
const OriginalReporter = mocha._reporter;
|
||||
|
||||
const SauceReporter = function Constructor(runner) {
|
||||
const failedTests = [];
|
||||
|
||||
runner.on('end', () => {
|
||||
window.mochaResults = runner.stats;
|
||||
window.mochaResults.reports = failedTests;
|
||||
});
|
||||
|
||||
runner.on('fail', (test, err) => {
|
||||
const flattenTitles = item => {
|
||||
const titles = [];
|
||||
while (item.parent.title) {
|
||||
titles.push(item.parent.title);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
item = item.parent;
|
||||
}
|
||||
return titles.reverse();
|
||||
};
|
||||
failedTests.push({
|
||||
name: test.title,
|
||||
result: false,
|
||||
message: err.message,
|
||||
stack: err.stack,
|
||||
titles: flattenTitles(test),
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-new
|
||||
new OriginalReporter(runner);
|
||||
};
|
||||
|
||||
SauceReporter.prototype = OriginalReporter.prototype;
|
||||
|
||||
mocha.reporter(SauceReporter);
|
||||
|
||||
/*
|
||||
* global helpers for tests
|
||||
*/
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
window.Whisper.events = {
|
||||
on() {},
|
||||
trigger() {},
|
||||
};
|
||||
|
||||
before(async () => {
|
||||
try {
|
||||
window.SignalContext.log.info('Initializing SQL in renderer');
|
||||
const isTesting = true;
|
||||
await window.Signal.Data.startInRenderer(isTesting);
|
||||
window.SignalContext.log.info('SQL initialized in renderer');
|
||||
} catch (err) {
|
||||
window.SignalContext.log.error(
|
||||
'SQL failed to initialize',
|
||||
err && err.stack ? err.stack : err
|
||||
);
|
||||
}
|
||||
|
||||
await window.Signal.Util.initializeMessageCounter();
|
||||
});
|
||||
@@ -1,59 +0,0 @@
|
||||
// Copyright 2018-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
window.setImmediate = window.nodeSetImmediate;
|
||||
|
||||
const getKeysForIdentifierMap = {};
|
||||
const messagesSentMap = {};
|
||||
|
||||
const fakeCall = () => Promise.resolve();
|
||||
|
||||
const fakeAPI = {
|
||||
confirmCode: fakeCall,
|
||||
getAttachment: fakeCall,
|
||||
getAvatar: fakeCall,
|
||||
getDevices: fakeCall,
|
||||
// getKeysForIdentifier : fakeCall,
|
||||
getMyKeys: fakeCall,
|
||||
getProfile: fakeCall,
|
||||
getProvisioningResource: fakeCall,
|
||||
putAttachment: fakeCall,
|
||||
registerKeys: fakeCall,
|
||||
requestVerificationSMS: fakeCall,
|
||||
requestVerificationVoice: fakeCall,
|
||||
// sendMessages: fakeCall,
|
||||
setSignedPreKey: fakeCall,
|
||||
|
||||
getKeysForIdentifier(number) {
|
||||
const res = getKeysForIdentifierMap[number];
|
||||
if (res !== undefined) {
|
||||
delete getKeysForIdentifierMap[number];
|
||||
return Promise.resolve(res);
|
||||
}
|
||||
throw new Error('getKeysForIdentfier of unknown/used number');
|
||||
},
|
||||
|
||||
sendMessages(destination, messageArray) {
|
||||
for (let i = 0, max = messageArray.length; i < max; i += 1) {
|
||||
const msg = messageArray[i];
|
||||
if (
|
||||
(msg.type !== 1 && msg.type !== 3) ||
|
||||
msg.destinationDeviceId === undefined ||
|
||||
msg.destinationRegistrationId === undefined ||
|
||||
msg.body === undefined ||
|
||||
msg.timestamp === undefined ||
|
||||
msg.relay !== undefined ||
|
||||
msg.destination !== undefined
|
||||
) {
|
||||
throw new Error('Invalid message');
|
||||
}
|
||||
|
||||
messagesSentMap[`${destination}.${messageArray[i].destinationDeviceId}`] =
|
||||
msg;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
window.WebAPI = {
|
||||
connect: () => fakeAPI,
|
||||
};
|
||||
@@ -1,44 +0,0 @@
|
||||
<!-- Copyright 2015-2021 Signal Messenger, LLC -->
|
||||
<!-- SPDX-License-Identifier: AGPL-3.0-only -->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>libtextsecure test runner</title>
|
||||
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<div id="tests"></div>
|
||||
|
||||
<script type="text/javascript" src="fake_web_api.js"></script>
|
||||
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="../protocol_wrapper.js"
|
||||
data-cover
|
||||
></script>
|
||||
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="../../js/libphonenumber-util.js"
|
||||
></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="../../js/components.js"
|
||||
data-cover
|
||||
></script>
|
||||
|
||||
<script type="text/javascript" src="task_with_timeout_test.js"></script>
|
||||
<script type="text/javascript" src="account_manager_test.js"></script>
|
||||
<script type="text/javascript" src="sendmessage_test.js"></script>
|
||||
|
||||
<!-- Uncomment to start tests without code coverage enabled -->
|
||||
<script type="text/javascript">
|
||||
mocha.run();
|
||||
window.Signal.conversationControllerStart();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,114 +0,0 @@
|
||||
// Copyright 2019-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* global textsecure, WebAPI */
|
||||
/* eslint-disable no-console */
|
||||
|
||||
const BUCKET_SIZES = [
|
||||
541, 568, 596, 626, 657, 690, 725, 761, 799, 839, 881, 925, 972, 1020, 1071,
|
||||
1125, 1181, 1240, 1302, 1367, 1436, 1507, 1583, 1662, 1745, 1832, 1924, 2020,
|
||||
2121, 2227, 2339, 2456, 2579, 2708, 2843, 2985, 3134, 3291, 3456, 3629, 3810,
|
||||
4001, 4201, 4411, 4631, 4863, 5106, 5361, 5629, 5911, 6207, 6517, 6843, 7185,
|
||||
7544, 7921, 8318, 8733, 9170, 9629, 10110, 10616, 11146, 11704, 12289, 12903,
|
||||
13549, 14226, 14937, 15684, 16469, 17292, 18157, 19065, 20018, 21019, 22070,
|
||||
23173, 24332, 25549, 26826, 28167, 29576, 31054, 32607, 34238, 35950, 37747,
|
||||
39634, 41616, 43697, 45882, 48176, 50585, 53114, 55770, 58558, 61486, 64561,
|
||||
67789, 71178, 74737, 78474, 82398, 86518, 90843, 95386, 100155, 105163,
|
||||
110421, 115942, 121739, 127826, 134217, 140928, 147975, 155373, 163142,
|
||||
171299, 179864, 188858, 198300, 208215, 218626, 229558, 241036, 253087,
|
||||
265742, 279029, 292980, 307629, 323011, 339161, 356119, 373925, 392622,
|
||||
412253, 432866, 454509, 477234, 501096, 526151, 552458, 580081, 609086,
|
||||
639540, 671517, 705093, 740347, 777365, 816233, 857045, 899897, 944892,
|
||||
992136, 1041743, 1093831, 1148522, 1205948, 1266246, 1329558, 1396036,
|
||||
1465838, 1539130, 1616086, 1696890, 1781735, 1870822, 1964363, 2062581,
|
||||
2165710, 2273996, 2387695, 2507080, 2632434, 2764056, 2902259, 3047372,
|
||||
3199740, 3359727, 3527714, 3704100, 3889305, 4083770, 4287958, 4502356,
|
||||
4727474, 4963848, 5212040, 5472642, 5746274, 6033588, 6335268, 6652031,
|
||||
6984633, 7333864, 7700558, 8085585, 8489865, 8914358, 9360076, 9828080,
|
||||
10319484, 10835458, 11377231, 11946092, 12543397, 13170567, 13829095,
|
||||
14520550, 15246578, 16008907, 16809352, 17649820, 18532311, 19458926,
|
||||
20431872, 21453466, 22526139, 23652446, 24835069, 26076822, 27380663,
|
||||
28749697, 30187181, 31696540, 33281368, 34945436, 36692708, 38527343,
|
||||
40453710, 42476396, 44600216, 46830227, 49171738, 51630325, 54211841,
|
||||
56922433, 59768555, 62756983, 65894832, 69189573, 72649052, 76281505,
|
||||
80095580, 84100359, 88305377, 92720646, 97356678, 102224512, 107335738,
|
||||
];
|
||||
|
||||
describe('sendmessage', () => {
|
||||
let originalWebAPIConnect = null;
|
||||
let sendmessage = null;
|
||||
before(() => {
|
||||
originalWebAPIConnect = WebAPI.connect;
|
||||
WebAPI.connect = () => null;
|
||||
|
||||
sendmessage = new textsecure.MessageSender();
|
||||
});
|
||||
after(() => {
|
||||
WebAPI.connect = originalWebAPIConnect;
|
||||
});
|
||||
|
||||
describe('#_getAttachmentSizeBucket', () => {
|
||||
it('properly calculates first bucket', () => {
|
||||
for (let size = 0, max = BUCKET_SIZES[0]; size < max; size += 1) {
|
||||
assert.strictEqual(
|
||||
BUCKET_SIZES[0],
|
||||
sendmessage._getAttachmentSizeBucket(size)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('properly calculates entire table', () => {
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0, max = BUCKET_SIZES.length - 1; i < max; i += 1) {
|
||||
// Exact
|
||||
if (
|
||||
BUCKET_SIZES[i] !==
|
||||
sendmessage._getAttachmentSizeBucket(BUCKET_SIZES[i])
|
||||
) {
|
||||
count += 1;
|
||||
console.log(
|
||||
`${
|
||||
BUCKET_SIZES[i]
|
||||
} does not equal ${sendmessage._getAttachmentSizeBucket(
|
||||
BUCKET_SIZES[i]
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
// Just under
|
||||
if (
|
||||
BUCKET_SIZES[i] !==
|
||||
sendmessage._getAttachmentSizeBucket(BUCKET_SIZES[i] - 1)
|
||||
) {
|
||||
count += 1;
|
||||
console.log(
|
||||
`${
|
||||
BUCKET_SIZES[i]
|
||||
} does not equal ${sendmessage._getAttachmentSizeBucket(
|
||||
BUCKET_SIZES[i] - 1
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
// Just over
|
||||
if (
|
||||
BUCKET_SIZES[i + 1] !==
|
||||
sendmessage._getAttachmentSizeBucket(BUCKET_SIZES[i] + 1)
|
||||
) {
|
||||
count += 1;
|
||||
console.log(
|
||||
`${
|
||||
BUCKET_SIZES[i + 1]
|
||||
} does not equal ${sendmessage._getAttachmentSizeBucket(
|
||||
BUCKET_SIZES[i] + 1
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Failures: ${count}`);
|
||||
assert.strictEqual(count, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user