2022-05-27 22:12:01 +00:00
|
|
|
// Copyright 2014-2022 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-12-09 08:06:04 +00:00
|
|
|
/* global Whisper, _, Backbone */
|
2014-11-25 01:28:51 +00:00
|
|
|
|
2014-11-04 22:59:48 +00:00
|
|
|
/*
|
|
|
|
* global helpers for tests
|
|
|
|
*/
|
2014-11-16 21:19:51 +00:00
|
|
|
|
2018-11-02 18:02:53 +00:00
|
|
|
function deleteIndexedDB() {
|
2018-07-25 22:02:37 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2018-11-08 00:53:41 +00:00
|
|
|
const idbReq = indexedDB.deleteDatabase('test');
|
2018-07-25 22:02:37 +00:00
|
|
|
idbReq.onsuccess = resolve;
|
|
|
|
idbReq.error = reject;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-04-16 01:02:44 +00:00
|
|
|
/* Delete the database before running any tests */
|
2018-07-25 22:02:37 +00:00
|
|
|
before(async () => {
|
2021-06-16 00:44:14 +00:00
|
|
|
window.Signal.Util.MessageController.install();
|
|
|
|
|
2018-11-02 18:02:53 +00:00
|
|
|
await deleteIndexedDB();
|
2021-03-04 21:44:57 +00:00
|
|
|
try {
|
2021-10-07 23:28:47 +00:00
|
|
|
window.SignalContext.log.info('Initializing SQL in renderer');
|
2021-04-08 23:27:41 +00:00
|
|
|
const isTesting = true;
|
2021-10-07 18:16:51 +00:00
|
|
|
await window.Signal.Data.startInRenderer(isTesting);
|
2021-10-07 23:28:47 +00:00
|
|
|
window.SignalContext.log.info('SQL initialized in renderer');
|
2021-03-04 21:44:57 +00:00
|
|
|
} catch (err) {
|
2021-10-07 23:28:47 +00:00
|
|
|
window.SignalContext.log.error(
|
2021-03-04 21:44:57 +00:00
|
|
|
'SQL failed to initialize',
|
|
|
|
err && err.stack ? err.stack : err
|
|
|
|
);
|
|
|
|
}
|
2021-09-15 18:45:22 +00:00
|
|
|
await window.Signal.Util.initializeMessageCounter();
|
2018-07-27 01:13:56 +00:00
|
|
|
await window.Signal.Data.removeAll();
|
2019-01-14 21:49:58 +00:00
|
|
|
await window.storage.fetch();
|
2018-07-25 22:02:37 +00:00
|
|
|
});
|
2018-04-03 15:39:08 +00:00
|
|
|
|
2019-01-14 21:49:58 +00:00
|
|
|
window.Whisper = window.Whisper || {};
|
|
|
|
window.Whisper.events = _.clone(Backbone.Events);
|
2022-06-03 16:30:03 +00:00
|
|
|
|
|
|
|
window.textsecure.storage.protocol = new window.SignalProtocolStore();
|