remove spectron dependency

This commit is contained in:
audric 2021-08-13 14:47:00 +10:00
parent 43aeacb9c9
commit e5dab2781e
47 changed files with 702 additions and 12393 deletions

View File

@ -30,12 +30,8 @@ js/WebAudioRecorderMp3.js
libtextsecure/libsignal-protocol.js
js/util_worker.js
libtextsecure/test/blanket_mocha.js
test/blanket_mocha.js
mnemonic_languages/**
# Test fixtures
test/fixtures.js
# Managed by package manager (`bower` and `yarn`/`npm`):
/bower.json
/package.json

View File

@ -36,9 +36,9 @@ Then you need `git`, if you don't have that yet: https://git-scm.com/
### Windows
1. **Windows 7 only:**
* Install Microsoft .NET Framework 4.5.1:
- Install Microsoft .NET Framework 4.5.1:
https://www.microsoft.com/en-us/download/details.aspx?id=40773
* Install Windows SDK version 8.1: https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
- Install Windows SDK version 8.1: https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
1. Install _Windows Build Tools_: Open the [Command Prompt (`cmd.exe`) as Administrator](<https://technet.microsoft.com/en-us/library/cc947813(v=ws.10).aspx>)
and run: `npm install --vs2015 --global --production --add-python-to-path windows-build-tools`
@ -136,16 +136,6 @@ Please write tests! Our testing framework is
The easiest way to run all tests at once is `yarn test`.
You can browse tests from the command line with `grunt unit-tests` or in an
interactive session with `NODE_ENV=test yarn run start`. The `libtextsecure` tests are run
similarly: `grunt lib-unit-tests` and `NODE_ENV=test-lib yarn run start`. You can tweak
the appropriate `test.html` for both of these runs to get code coverage numbers via
`blanket.js` (it's shown at the bottom of the web page when the run is complete).
To run Node.js tests, you can run `yarn test-server` from the command line. You can get
code coverage numbers for this kind of run via `yarn test-server-coverage`, then display
the report with `yarn open-coverage`.
## Pull requests
So you wanna make a pull request? Please observe the following guidelines.
@ -156,29 +146,29 @@ So you wanna make a pull request? Please observe the following guidelines.
[Transifex](https://www.transifex.com/projects/p/signal-desktop).
-->
* First, make sure that your `yarn ready` run passes - it's very similar to what our
- First, make sure that your `yarn ready` run passes - it's very similar to what our
Continuous Integration servers do to test the app.
* Never use plain strings right in the source code - pull them from `messages.json`!
- Never use plain strings right in the source code - pull them from `messages.json`!
You **only** need to modify the default locale
[`_locales/en/messages.json`](_locales/en/messages.json).
<!-- TODO:
Other locales are generated automatically based on that file and then periodically
uploaded to Transifex for translation. -->
* [Rebase](https://nathanleclaire.com/blog/2014/09/14/dont-be-scared-of-git-rebase/) your
- [Rebase](https://nathanleclaire.com/blog/2014/09/14/dont-be-scared-of-git-rebase/) your
changes on the latest `development` branch, resolving any conflicts.
This ensures that your changes will merge cleanly when you open your PR.
* Be sure to add and run tests!
* Make sure the diff between our master and your branch contains only the
- Be sure to add and run tests!
- Make sure the diff between our master and your branch contains only the
minimal set of changes needed to implement your feature or bugfix. This will
make it easier for the person reviewing your code to approve the changes.
Please do not submit a PR with commented out code or unfinished features.
* Avoid meaningless or too-granular commits. If your branch contains commits like
- Avoid meaningless or too-granular commits. If your branch contains commits like
the lines of "Oops, reverted this change" or "Just experimenting, will
delete this later", please [squash or rebase those changes away](https://robots.thoughtbot.com/git-interactive-rebase-squash-amend-rewriting-history).
* Don't have too few commits. If you have a complicated or long lived feature
- Don't have too few commits. If you have a complicated or long lived feature
branch, it may make sense to break the changes up into logical atomic chunks
to aid in the review process.
* Provide a well written and nicely formatted commit message. See [this
- Provide a well written and nicely formatted commit message. See [this
link](http://chris.beams.io/posts/git-commit/)
for some tips on formatting. As far as content, try to include in your
summary

View File

@ -1,12 +1,6 @@
const path = require('path');
const packageJson = require('./package.json');
const importOnce = require('node-sass-import-once');
const rimraf = require('rimraf');
const mkdirp = require('mkdirp');
const spectron = require('spectron');
const asar = require('asar');
const fs = require('fs');
const assert = require('assert');
const sass = require('node-sass');
/* eslint-disable more/no-then, no-console */
@ -53,10 +47,6 @@ module.exports = grunt => {
src: libtextsecurecomponents,
dest: 'libtextsecure/components.js',
},
test: {
src: ['node_modules/mocha/mocha.js', 'node_modules/chai/chai.js', 'test/_test.js'],
dest: 'test/test.js',
},
libtextsecure: {
options: {
banner: ';(function() {\n',
@ -130,27 +120,6 @@ module.exports = grunt => {
cmd: 'yarn build-protobuf',
},
},
'test-release': {
osx: {
archive: `mac/${packageJson.productName}.app/Contents/Resources/app.asar`,
appUpdateYML: `mac/${packageJson.productName}.app/Contents/Resources/app-update.yml`,
exe: `mac/${packageJson.productName}.app/Contents/MacOS/${packageJson.productName}`,
},
mas: {
archive: 'mas/Signal.app/Contents/Resources/app.asar',
appUpdateYML: 'mac/Signal.app/Contents/Resources/app-update.yml',
exe: `mas/${packageJson.productName}.app/Contents/MacOS/${packageJson.productName}`,
},
linux: {
archive: 'linux-unpacked/resources/app.asar',
exe: `linux-unpacked/${packageJson.name}`,
},
win: {
archive: 'win-unpacked/resources/app.asar',
appUpdateYML: 'win-unpacked/resources/app-update.yml',
exe: `win-unpacked/${packageJson.productName}.exe`,
},
},
gitinfo: {}, // to be populated by grunt gitinfo
});
@ -197,186 +166,7 @@ module.exports = grunt => {
mkdirp.sync('release');
});
function runTests(environment, cb) {
let failure;
const { Application } = spectron;
const electronBinary = process.platform === 'win32' ? 'electron.cmd' : 'electron';
const app = new Application({
path: path.join(__dirname, 'node_modules', '.bin', electronBinary),
args: [path.join(__dirname, 'main.js')],
env: {
NODE_ENV: environment,
},
requireName: 'unused',
chromeDriverArgs: [
`remote-debugging-port=${Math.floor(Math.random() * (9999 - 9000) + 9000)}`,
],
});
function getMochaResults() {
// eslint-disable-next-line no-undef
return window.mochaResults;
}
app
.start()
.then(() =>
app.client.waitUntil(
() => app.client.execute(getMochaResults).then(data => Boolean(data.value)),
25000,
'Expected to find window.mochaResults set!'
)
)
.then(() => app.client.execute(getMochaResults))
.then(data => {
const results = data.value;
if (results.failures > 0) {
console.error(results.reports);
failure = () => grunt.fail.fatal(`Found ${results.failures} failing unit tests.`);
return app.client.log('browser');
}
grunt.log.ok(`${results.passes} tests passed.`);
return null;
})
.then(logs => {
if (logs) {
console.error();
console.error('Because tests failed, printing browser logs:');
console.error(logs);
}
})
.catch(error => {
failure = () => grunt.fail.fatal(`Something went wrong: ${error.message} ${error.stack}`);
})
.then(() => {
// We need to use the failure variable and this early stop to clean up before
// shutting down. Grunt's fail methods are the only way to set the return value,
// but they shut the process down immediately!
if (failure) {
console.log();
console.log('Main process logs:');
return app.client.getMainProcessLogs().then(logs => {
logs.forEach(log => {
console.log(log);
});
try {
return app.stop();
} catch (err) {
return Promise.resolve();
}
});
}
try {
return app.stop();
} catch (err) {
return Promise.resolve();
}
})
.then(() => {
if (failure) {
failure();
}
cb();
})
.catch(error => {
console.error('Second-level error:', error.message, error.stack);
if (failure) {
failure();
}
cb();
});
}
grunt.registerTask('unit-tests', 'Run unit tests w/Electron', function thisNeeded() {
const environment = grunt.option('env') || 'test';
const done = this.async();
runTests(environment, done);
});
grunt.registerMultiTask('test-release', 'Test packaged releases', function thisNeeded() {
const dir = grunt.option('dir') || 'release';
const environment = grunt.option('env') || 'production';
const config = this.data;
const archive = [dir, config.archive].join('/');
const files = [
'config/default.json',
`config/${environment}.json`,
`config/local-${environment}.json`,
];
console.log(this.target, archive);
const releaseFiles = files.concat(config.files || []);
releaseFiles.forEach(fileName => {
console.log(fileName);
try {
asar.statFile(archive, fileName);
return true;
} catch (e) {
console.log(e);
throw new Error(`Missing file ${fileName}`);
}
});
if (config.appUpdateYML) {
const appUpdateYML = [dir, config.appUpdateYML].join('/');
if (fs.existsSync(appUpdateYML)) {
console.log('auto update ok');
} else {
throw new Error(`Missing auto update config ${appUpdateYML}`);
}
}
const done = this.async();
// A simple test to verify a visible window is opened with a title
const { Application } = spectron;
const app = new Application({
path: [dir, config.exe].join('/'),
requireName: 'unused',
chromeDriverArgs: [
`remote-debugging-port=${Math.floor(Math.random() * (9999 - 9000) + 9000)}`,
],
});
app
.start()
.then(() => app.client.getWindowCount())
.then(count => {
assert.equal(count, 1);
console.log('window opened');
})
.then(() =>
// Get the window's title
app.client.getTitle()
)
.then(title => {
// TODO: restore once fixed on win
if (this.target !== 'win') {
// Verify the window's title
assert.equal(title, packageJson.productName);
console.log('title ok');
}
})
.then(() => {
assert(app.chromeDriver.logLines.indexOf(`NODE_ENV ${environment}`) > -1);
console.log('environment ok');
})
.then(
() =>
// Successfully completed test
app.stop(),
error =>
// Test failed!
app.stop().then(() => {
grunt.fail.fatal(`Test failed: ${error.message} ${error.stack}`);
})
)
.then(done);
});
grunt.registerTask('dev', ['default', 'watch']);
grunt.registerTask('test', ['unit-tests']);
grunt.registerTask('date', ['gitinfo', 'getExpireTime']);
grunt.registerTask('default', [
'exec:build-protobuf',

View File

@ -33,10 +33,6 @@ function initialize() {
} catch (error) {
const errorForDisplay = error && error.stack ? error.stack : error;
console.log(`sql channel error with call ${callName}: ${errorForDisplay}`);
// FIXME this line cause the test-integration to fail and we probably don't need it during test
if (!process.env.NODE_ENV.includes('test-integration')) {
event.sender.send(`${SQL_CHANNEL_KEY}-done`, jobId, errorForDisplay);
}
}
});

View File

@ -63,7 +63,7 @@
// of preload.js processing
window.setImmediate = window.nodeSetImmediate;
window.globalOnlineStatus = true; // default to true as we don't get an event on app start
window.getGlobalOnlineStatus = () => window.globalOnlineStatus;
const { Views } = window.Signal;
// Implicitly used in `indexeddb-backbonejs-adapter`:

38
main.js
View File

@ -344,13 +344,7 @@ async function createWindow() {
}
});
if (config.environment === 'test') {
mainWindow.loadURL(prepareURL([__dirname, 'test', 'index.html']));
} else if (config.environment.includes('test-integration')) {
mainWindow.loadURL(prepareURL([__dirname, 'background_test.html']));
} else {
mainWindow.loadURL(prepareURL([__dirname, 'background.html']));
}
mainWindow.loadURL(prepareURL([__dirname, 'background.html']));
if (config.get('openDevTools')) {
// Open the DevTools.
@ -368,11 +362,7 @@ async function createWindow() {
shouldQuit: windowState.shouldQuit(),
});
// If the application is terminating, just do the default
if (
config.environment === 'test' ||
config.environment.includes('test-integration') ||
(mainWindow.readyForShutdown && windowState.shouldQuit())
) {
if (mainWindow.readyForShutdown && windowState.shouldQuit()) {
return;
}
@ -492,7 +482,7 @@ function showPasswordWindow() {
passwordWindow.on('close', e => {
// If the application is terminating, just do the default
if (config.environment === 'test' || windowState.shouldQuit()) {
if (windowState.shouldQuit()) {
return;
}
@ -620,14 +610,12 @@ app.on('ready', async () => {
const userDataPath = await getRealPath(app.getPath('userData'));
const installPath = await getRealPath(app.getAppPath());
if (process.env.NODE_ENV !== 'test' && !process.env.NODE_ENV.includes('test-integration')) {
installFileHandler({
protocol: electronProtocol,
userDataPath,
installPath,
isWindows: process.platform === 'win32',
});
}
installFileHandler({
protocol: electronProtocol,
userDataPath,
installPath,
isWindows: process.platform === 'win32',
});
installWebHandler({
protocol: electronProtocol,
@ -640,7 +628,7 @@ app.on('ready', async () => {
logger.info('app ready');
logger.info(`starting version ${packageJson.version}`);
if (!locale) {
const appLocale = process.env.NODE_ENV === 'test' ? 'en' : app.getLocale();
const appLocale = app.getLocale() || 'en';
locale = loadLocale({ appLocale, logger });
}
@ -785,11 +773,7 @@ app.on('before-quit', () => {
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (
process.platform !== 'darwin' ||
config.environment === 'test' ||
config.environment.includes('test-integration')
) {
if (process.platform !== 'darwin') {
app.quit();
}
});

View File

@ -18,7 +18,6 @@
"start": "cross-env NODE_APP_INSTANCE=$MULTI electron .",
"start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod$MULTI electron .",
"start-prod2": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod2 electron .",
"start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=$MULTI electron .",
"grunt": "grunt",
"grunt:dev": "yarn clean-transpile; yarn grunt dev --force",
"generate": "yarn grunt --force",
@ -36,10 +35,7 @@
"clean-module-protobuf": "rimraf ts/protobuf/compiled.d.ts ts/protobuf/compiled.js",
"build-protobuf": "yarn build-module-protobuf",
"clean-protobuf": "yarn clean-module-protobuf",
"test": "yarn test-node && yarn test-electron",
"test-view": "NODE_ENV=test yarn run start",
"test-lib-view": "NODE_ENV=test-lib yarn run start",
"test-electron": "yarn grunt test",
"test": "yarn test-node",
"test-node": "mocha --recursive --exit --timeout 10000 test/app test/modules \"./ts/test/**/*_test.js\" ",
"eslint-full": "eslint .",
"lint-full": "yarn format-full && yarn lint-files-full",
@ -213,7 +209,6 @@
"qs": "6.5.1",
"run-script-os": "^1.1.6",
"sinon": "9.0.2",
"spectron": "^10.0.0",
"ts-loader": "4.1.0",
"ts-mock-imports": "^1.3.0",
"tslint": "5.19.0",

View File

@ -46,8 +46,6 @@ window.getServerTrustRoot = () => config.serverTrustRoot;
window.JobQueue = JobQueue;
window.isBehindProxy = () => Boolean(config.proxyUrl);
window.getStoragePubKey = key => (window.isDev() ? key.substring(2) : key);
window.lokiFeatureFlags = {
useOnionRequests: true,
useFileOnionRequests: true,
@ -56,10 +54,6 @@ window.lokiFeatureFlags = {
enablePinConversations: true,
};
if (typeof process.env.NODE_ENV === 'string' && process.env.NODE_ENV.includes('test-integration')) {
window.electronRequire = require;
}
window.isBeforeVersion = (toCheck, baseVersion) => {
try {
return semver.lt(toCheck, baseVersion);
@ -353,35 +347,6 @@ Promise.prototype.ignore = function() {
this.then(() => {});
};
if (
config.environment.includes('test') &&
!config.environment.includes('swarm-testing') &&
!config.environment.includes('test-integration')
) {
const isWindows = process.platform === 'win32';
/* eslint-disable global-require, import/no-extraneous-dependencies */
window.test = {
glob: require('glob'),
fse: require('fs-extra'),
tmp: require('tmp'),
path: require('path'),
basePath: __dirname,
attachmentsPath: window.Signal.Migrations.attachmentsPath,
isWindows,
};
/* eslint-enable global-require, import/no-extraneous-dependencies */
window.lokiFeatureFlags = {};
}
if (config.environment.includes('test-integration')) {
window.lokiFeatureFlags = {
useOnionRequests: false,
useFileOnionRequests: false,
};
/* eslint-disable global-require, import/no-extraneous-dependencies */
window.sinon = require('sinon');
/* eslint-enable global-require, import/no-extraneous-dependencies */
}
// Blocking
const { BlockedNumberController } = require('./ts/util/blockedNumberController');

View File

@ -1,39 +0,0 @@
// For reference: https://github.com/airbnb/javascript
module.exports = {
env: {
mocha: true,
browser: true,
},
globals: {
assert: true,
assertEqualArrayBuffers: true,
clearDatabase: true,
dcodeIO: true,
getString: true,
hexToArrayBuffer: true,
PROTO_ROOT: true,
stringToArrayBuffer: true,
},
parserOptions: {
sourceType: 'script',
},
rules: {
// We still get the value of this rule, it just allows for dev deps
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
// We want to keep each test structured the same, even if its contents are tiny
'arrow-body-style': 'off',
strict: 'off',
'more/no-then': 'off',
},
};

View File

@ -1,89 +0,0 @@
/* global chai, Whisper, _, Backbone */
mocha
.setup('bdd')
.fullTrace()
.timeout(10000);
window.assert = chai.assert;
window.PROTO_ROOT = '../protos';
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);
// Override the database id.
window.Whisper = window.Whisper || {};
window.Whisper.Database = window.Whisper.Database || {};
Whisper.Database.id = 'test';
/*
* global helpers for tests
*/
window.assertEqualArrayBuffers = (ab1, ab2) => {
assert.deepEqual(new Uint8Array(ab1), new Uint8Array(ab2));
};
window.hexToArrayBuffer = str => {
const ret = new ArrayBuffer(str.length / 2);
const array = new Uint8Array(ret);
for (let i = 0; i < str.length / 2; i += 1) {
array[i] = parseInt(str.substr(i * 2, 2), 16);
}
return ret;
};
function deleteIndexedDB() {
return new Promise((resolve, reject) => {
const idbReq = indexedDB.deleteDatabase('test');
idbReq.onsuccess = resolve;
idbReq.error = reject;
});
}
/* Delete the database before running any tests */
before(async () => {
await deleteIndexedDB();
await window.Signal.Data.removeAll();
await window.storage.fetch();
});
window.clearDatabase = async () => {
await window.Signal.Data.removeAll();
await window.storage.fetch();
};
window.Whisper = window.Whisper || {};
window.Whisper.events = _.clone(Backbone.Events);

View File

@ -1,12 +0,0 @@
// For reference: https://github.com/airbnb/javascript
module.exports = {
env: {
mocha: true,
browser: false,
},
parserOptions: {
sourceType: 'module',
},
};

View File

@ -1,170 +0,0 @@
[
{
"label": "Session",
"submenu": [
{
"label": "About",
"click": null
},
{
"type": "separator"
},
{
"type": "separator"
},
{
"label": "Hide",
"role": "hide"
},
{
"label": "Hide Others",
"role": "hideothers"
},
{
"label": "Show All",
"role": "unhide"
},
{
"type": "separator"
},
{
"label": "Quit Session",
"role": "quit"
}
]
},
{
"label": "&File"
},
{
"label": "&Edit",
"submenu": [
{
"label": "Undo",
"role": "undo"
},
{
"label": "Redo",
"role": "redo"
},
{
"type": "separator"
},
{
"label": "Cut",
"role": "cut"
},
{
"label": "Copy",
"role": "copy"
},
{
"label": "Paste",
"role": "paste"
},
{
"label": "Paste and Match Style",
"role": "pasteandmatchstyle"
},
{
"label": "Delete",
"role": "delete"
},
{
"label": "Select all",
"role": "selectall"
}
]
},
{
"label": "&View",
"submenu": [
{
"label": "Actual Size",
"role": "resetzoom"
},
{
"accelerator": "Command+=",
"label": "Zoom In",
"role": "zoomin"
},
{
"label": "Zoom Out",
"role": "zoomout"
},
{
"type": "separator"
},
{
"label": "Toggle Full Screen",
"role": "togglefullscreen"
},
{
"type": "separator"
},
{
"label": "Debug Log",
"click": null
},
{
"type": "separator"
},
{
"label": "Toggle Developer Tools",
"role": "toggledevtools"
}
]
},
{
"label": "&Window",
"role": "window",
"submenu": [
{
"label": "Close Window",
"accelerator": "CmdOrCtrl+W",
"role": "close"
},
{
"label": "Minimize",
"accelerator": "CmdOrCtrl+M",
"role": "minimize"
},
{
"label": "Zoom",
"role": "zoom"
},
{
"label": "Show",
"click": null
},
{
"type": "separator"
},
{
"label": "Bring All to Front",
"role": "front"
}
]
},
{
"label": "&Help",
"role": "help",
"submenu": [
{
"label": "Go to Release Notes",
"click": null
},
{
"type": "separator"
},
{
"label": "Go to Support Page",
"click": null
},
{
"label": "Report an Issue",
"click": null
}
]
}
]

View File

@ -1,167 +0,0 @@
[
{
"label": "Session",
"submenu": [
{
"label": "About",
"click": null
},
{
"type": "separator"
},
{
"type": "separator"
},
{
"label": "Hide",
"role": "hide"
},
{
"label": "Hide Others",
"role": "hideothers"
},
{
"label": "Show All",
"role": "unhide"
},
{
"type": "separator"
},
{
"label": "Quit Session",
"role": "quit"
}
]
},
{
"label": "&Edit",
"submenu": [
{
"label": "Undo",
"role": "undo"
},
{
"label": "Redo",
"role": "redo"
},
{
"type": "separator"
},
{
"label": "Cut",
"role": "cut"
},
{
"label": "Copy",
"role": "copy"
},
{
"label": "Paste",
"role": "paste"
},
{
"label": "Paste and Match Style",
"role": "pasteandmatchstyle"
},
{
"label": "Delete",
"role": "delete"
},
{
"label": "Select all",
"role": "selectall"
}
]
},
{
"label": "&View",
"submenu": [
{
"label": "Actual Size",
"role": "resetzoom"
},
{
"accelerator": "Command+=",
"label": "Zoom In",
"role": "zoomin"
},
{
"label": "Zoom Out",
"role": "zoomout"
},
{
"type": "separator"
},
{
"label": "Toggle Full Screen",
"role": "togglefullscreen"
},
{
"type": "separator"
},
{
"label": "Debug Log",
"click": null
},
{
"type": "separator"
},
{
"label": "Toggle Developer Tools",
"role": "toggledevtools"
}
]
},
{
"label": "&Window",
"role": "window",
"submenu": [
{
"label": "Close Window",
"accelerator": "CmdOrCtrl+W",
"role": "close"
},
{
"label": "Minimize",
"accelerator": "CmdOrCtrl+M",
"role": "minimize"
},
{
"label": "Zoom",
"role": "zoom"
},
{
"label": "Show",
"click": null
},
{
"type": "separator"
},
{
"label": "Bring All to Front",
"role": "front"
}
]
},
{
"label": "&Help",
"role": "help",
"submenu": [
{
"label": "Go to Release Notes",
"click": null
},
{
"type": "separator"
},
{
"label": "Go to Support Page",
"click": null
},
{
"label": "Report an Issue",
"click": null
}
]
}
]

View File

@ -1,134 +0,0 @@
[
{
"label": "&File",
"submenu": [
{
"type": "separator"
},
{
"type": "separator"
},
{
"label": "Quit Session",
"role": "quit"
}
]
},
{
"label": "&Edit",
"submenu": [
{
"label": "Undo",
"role": "undo"
},
{
"label": "Redo",
"role": "redo"
},
{
"type": "separator"
},
{
"label": "Cut",
"role": "cut"
},
{
"label": "Copy",
"role": "copy"
},
{
"label": "Paste",
"role": "paste"
},
{
"label": "Paste and Match Style",
"role": "pasteandmatchstyle"
},
{
"label": "Delete",
"role": "delete"
},
{
"label": "Select all",
"role": "selectall"
}
]
},
{
"label": "&View",
"submenu": [
{
"label": "Actual Size",
"role": "resetzoom"
},
{
"accelerator": "Control+Plus",
"label": "Zoom In",
"role": "zoomin"
},
{
"label": "Zoom Out",
"role": "zoomout"
},
{
"type": "separator"
},
{
"label": "Toggle Full Screen",
"role": "togglefullscreen"
},
{
"type": "separator"
},
{
"label": "Debug Log",
"click": null
},
{
"type": "separator"
},
{
"label": "Toggle Developer Tools",
"role": "toggledevtools"
}
]
},
{
"label": "&Window",
"role": "window",
"submenu": [
{
"label": "Minimize",
"role": "minimize"
}
]
},
{
"label": "&Help",
"role": "help",
"submenu": [
{
"label": "Go to Release Notes",
"click": null
},
{
"type": "separator"
},
{
"label": "Go to Support Page",
"click": null
},
{
"label": "Report an Issue",
"click": null
},
{
"type": "separator"
},
{
"label": "About",
"click": null
}
]
}
]

View File

@ -1,131 +0,0 @@
[
{
"label": "&File",
"submenu": [
{
"type": "separator"
},
{
"label": "Quit Session",
"role": "quit"
}
]
},
{
"label": "&Edit",
"submenu": [
{
"label": "Undo",
"role": "undo"
},
{
"label": "Redo",
"role": "redo"
},
{
"type": "separator"
},
{
"label": "Cut",
"role": "cut"
},
{
"label": "Copy",
"role": "copy"
},
{
"label": "Paste",
"role": "paste"
},
{
"label": "Paste and Match Style",
"role": "pasteandmatchstyle"
},
{
"label": "Delete",
"role": "delete"
},
{
"label": "Select all",
"role": "selectall"
}
]
},
{
"label": "&View",
"submenu": [
{
"label": "Actual Size",
"role": "resetzoom"
},
{
"accelerator": "Control+Plus",
"label": "Zoom In",
"role": "zoomin"
},
{
"label": "Zoom Out",
"role": "zoomout"
},
{
"type": "separator"
},
{
"label": "Toggle Full Screen",
"role": "togglefullscreen"
},
{
"type": "separator"
},
{
"label": "Debug Log",
"click": null
},
{
"type": "separator"
},
{
"label": "Toggle Developer Tools",
"role": "toggledevtools"
}
]
},
{
"label": "&Window",
"role": "window",
"submenu": [
{
"label": "Minimize",
"role": "minimize"
}
]
},
{
"label": "&Help",
"role": "help",
"submenu": [
{
"label": "Go to Release Notes",
"click": null
},
{
"type": "separator"
},
{
"label": "Go to Support Page",
"click": null
},
{
"label": "Report an Issue",
"click": null
},
{
"type": "separator"
},
{
"label": "About",
"click": null
}
]
}
]

View File

@ -1,287 +0,0 @@
// NOTE: Temporarily allow `then` until we convert the entire file to `async` / `await`:
/* eslint-disable more/no-then */
const fs = require('fs');
const path = require('path');
const tmp = require('tmp');
const { expect } = require('chai');
const {
eliminateOutOfDateFiles,
eliminateOldEntries,
isLineAfterDate,
fetchLog,
fetch,
} = require('../../app/logging');
describe('app/logging', () => {
let basePath;
let tmpDir;
beforeEach(() => {
tmpDir = tmp.dirSync({
unsafeCleanup: true,
});
basePath = tmpDir.name;
});
afterEach(done => {
// we need the unsafe option to recursively remove the directory
try {
tmpDir.removeCallback(done);
} catch (e) {
// eslint-disable-next-line no-console
console.error('removeCallback failed with ', e);
done();
}
});
describe('#isLineAfterDate', () => {
it('returns false if falsy', () => {
const actual = isLineAfterDate('', new Date());
expect(actual).to.equal(false);
});
it('returns false if invalid JSON', () => {
const actual = isLineAfterDate('{{}', new Date());
expect(actual).to.equal(false);
});
it('returns false if date is invalid', () => {
const line = JSON.stringify({ time: '2018-01-04T19:17:05.014Z' });
const actual = isLineAfterDate(line, new Date('try6'));
expect(actual).to.equal(false);
});
it('returns false if log time is invalid', () => {
const line = JSON.stringify({ time: 'try7' });
const date = new Date('2018-01-04T19:17:00.000Z');
const actual = isLineAfterDate(line, date);
expect(actual).to.equal(false);
});
it('returns false if date before provided date', () => {
const line = JSON.stringify({ time: '2018-01-04T19:17:00.000Z' });
const date = new Date('2018-01-04T19:17:05.014Z');
const actual = isLineAfterDate(line, date);
expect(actual).to.equal(false);
});
it('returns true if date is after provided date', () => {
const line = JSON.stringify({ time: '2018-01-04T19:17:05.014Z' });
const date = new Date('2018-01-04T19:17:00.000Z');
const actual = isLineAfterDate(line, date);
expect(actual).to.equal(true);
});
});
describe('#eliminateOutOfDateFiles', () => {
it('deletes an empty file', () => {
const date = new Date();
const log = '\n';
const target = path.join(basePath, 'log.log');
fs.writeFileSync(target, log);
return eliminateOutOfDateFiles(basePath, date).then(() => {
expect(fs.existsSync(target)).to.equal(false);
});
});
it('deletes a file with invalid JSON lines', () => {
const date = new Date();
const log = '{{}\n';
const target = path.join(basePath, 'log.log');
fs.writeFileSync(target, log);
return eliminateOutOfDateFiles(basePath, date).then(() => {
expect(fs.existsSync(target)).to.equal(false);
});
});
it('deletes a file with all dates before provided date', () => {
const date = new Date('2018-01-04T19:17:05.014Z');
const contents = [
JSON.stringify({ time: '2018-01-04T19:17:00.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
].join('\n');
const target = path.join(basePath, 'log.log');
fs.writeFileSync(target, contents);
return eliminateOutOfDateFiles(basePath, date).then(() => {
expect(fs.existsSync(target)).to.equal(false);
});
});
it('keeps a file with first line date before provided date', () => {
const date = new Date('2018-01-04T19:16:00.000Z');
const contents = [
JSON.stringify({ time: '2018-01-04T19:17:00.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
].join('\n');
const target = path.join(basePath, 'log.log');
fs.writeFileSync(target, contents);
return eliminateOutOfDateFiles(basePath, date).then(() => {
expect(fs.existsSync(target)).to.equal(true);
});
});
it('keeps a file with last line date before provided date', () => {
const date = new Date('2018-01-04T19:17:01.000Z');
const contents = [
JSON.stringify({ time: '2018-01-04T19:17:00.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
].join('\n');
const target = path.join(basePath, 'log.log');
fs.writeFileSync(target, contents);
return eliminateOutOfDateFiles(basePath, date).then(() => {
expect(fs.existsSync(target)).to.equal(true);
});
});
});
describe('#eliminateOldEntries', () => {
it('eliminates all non-parsing entries', () => {
const date = new Date('2018-01-04T19:17:01.000Z');
const contents = [
'random line',
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
].join('\n');
const expected = [
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
].join('\n');
const target = path.join(basePath, 'log.log');
const files = [
{
path: target,
},
];
fs.writeFileSync(target, contents);
return eliminateOldEntries(files, date).then(() => {
expect(fs.readFileSync(target, 'utf8')).to.equal(`${expected}\n`);
});
});
it('preserves all lines if before target date', () => {
const date = new Date('2018-01-04T19:17:03.000Z');
const contents = [
'random line',
JSON.stringify({ time: '2018-01-04T19:17:01.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:02.014Z' }),
JSON.stringify({ time: '2018-01-04T19:17:03.014Z' }),
].join('\n');
const expected = [JSON.stringify({ time: '2018-01-04T19:17:03.014Z' })].join('\n');
const target = path.join(basePath, 'log.log');
const files = [
{
path: target,
},
];
fs.writeFileSync(target, contents);
return eliminateOldEntries(files, date).then(() => {
expect(fs.readFileSync(target, 'utf8')).to.equal(`${expected}\n`);
});
});
});
describe('#fetchLog', () => {
it('returns error if file does not exist', () => {
const target = 'random_file';
return fetchLog(target).then(
() => {
throw new Error('Expected an error!');
},
error => {
expect(error)
.to.have.property('message')
.that.match(/random_file/);
}
);
});
it('returns empty array if file has no valid JSON lines', () => {
const contents = 'line 1\nline2\n';
const expected = [];
const target = path.join(basePath, 'test.log');
fs.writeFileSync(target, contents);
return fetchLog(target).then(result => {
expect(result).to.deep.equal(expected);
});
});
it('returns just three fields in each returned line', () => {
const contents = [
JSON.stringify({
one: 1,
two: 2,
level: 1,
time: 2,
msg: 3,
}),
JSON.stringify({
one: 1,
two: 2,
level: 2,
time: 3,
msg: 4,
}),
'',
].join('\n');
const expected = [
{
level: 1,
time: 2,
msg: 3,
},
{
level: 2,
time: 3,
msg: 4,
},
];
const target = path.join(basePath, 'test.log');
fs.writeFileSync(target, contents);
return fetchLog(target).then(result => {
expect(result).to.deep.equal(expected);
});
});
});
describe('#fetch', () => {
it('returns single entry if no files', () => {
return fetch(basePath).then(results => {
expect(results).to.have.length(1);
expect(results[0].msg).to.match(/Loaded this list/);
});
});
it('returns sorted entries from all files', () => {
const first = [JSON.stringify({ msg: 2, time: '2018-01-04T19:17:05.014Z' }), ''].join('\n');
const second = [
JSON.stringify({ msg: 1, time: '2018-01-04T19:17:00.014Z' }),
JSON.stringify({ msg: 3, time: '2018-01-04T19:18:00.014Z' }),
'',
].join('\n');
fs.writeFileSync(path.join(basePath, 'first.log'), first);
fs.writeFileSync(path.join(basePath, 'second.log'), second);
return fetch(basePath).then(results => {
expect(results).to.have.length(4);
expect(results[0].msg).to.equal(1);
expect(results[1].msg).to.equal(2);
expect(results[2].msg).to.equal(3);
});
});
});
});

View File

@ -1,73 +0,0 @@
const { assert } = require('chai');
const SignalMenu = require('../../app/menu');
const { load: loadLocale } = require('../../app/locale');
const PLATFORMS = [
{
label: 'macOS',
platform: 'darwin',
fixtures: {
default: './fixtures/menu-mac-os',
setup: './fixtures/menu-mac-os-setup',
},
},
{
label: 'Windows',
platform: 'win32',
fixtures: {
default: './fixtures/menu-windows-linux',
setup: './fixtures/menu-windows-linux-setup',
},
},
{
label: 'Linux',
platform: 'linux',
fixtures: {
default: './fixtures/menu-windows-linux',
setup: './fixtures/menu-windows-linux-setup',
},
},
];
const INCLUDE_SETUP_OPTIONS = [false, true];
describe('SignalMenu', () => {
describe('createTemplate', () => {
PLATFORMS.forEach(({ label, platform, fixtures }) => {
context(label, () => {
INCLUDE_SETUP_OPTIONS.forEach(includeSetup => {
const prefix = includeSetup ? 'with' : 'without';
context(`${prefix} setup options`, () => {
it('should return correct template', () => {
const logger = {
error(message) {
throw new Error(message);
},
};
const options = {
openNewBugForm: null,
openReleaseNotes: null,
openSupportPage: null,
platform,
includeSetup,
showAbout: null,
showDebugLog: null,
showSettings: null,
showWindow: null,
};
const appLocale = 'en';
const { messages } = loadLocale({ appLocale, logger });
const actual = SignalMenu.createTemplate(options, messages);
const fixturePath = includeSetup ? fixtures.setup : fixtures.default;
// eslint-disable-next-line global-require, import/no-dynamic-require
const fixture = require(fixturePath);
assert.deepEqual(actual, fixture);
});
});
});
});
});
});
});

View File

@ -1,85 +0,0 @@
const { expect } = require('chai');
const { _urlToPath } = require('../../app/protocol_filter');
describe('Protocol Filter', () => {
describe('_urlToPath', () => {
it('returns proper file path for unix style file URI with hash', () => {
const path = 'file:///Users/someone/Development/signal/electron/background.html#first-page';
const expected = '/Users/someone/Development/signal/electron/background.html';
const actual = _urlToPath(path);
expect(actual).to.equal(expected);
});
it('returns proper file path for unix style file URI with querystring', () => {
const path =
'file:///Users/someone/Development/signal/electron/background.html?name=Signal&locale=en&version=2.4.0';
const expected = '/Users/someone/Development/signal/electron/background.html';
const actual = _urlToPath(path);
expect(actual).to.equal(expected);
});
it('returns proper file path for unix style file URI with hash and querystring', () => {
const path =
'file:///Users/someone/Development/signal/electron/background.html#somewhere?name=Signal';
const expected = '/Users/someone/Development/signal/electron/background.html';
const actual = _urlToPath(path);
expect(actual).to.equal(expected);
});
it('returns proper file path for file URI on windows', () => {
const path =
'file:///C:/Users/Someone/dev/desktop/background.html?name=Signal&locale=en&version=2.4.0';
const expected = 'C:/Users/Someone/dev/desktop/background.html';
const isWindows = true;
const actual = _urlToPath(path, { isWindows });
expect(actual).to.equal(expected);
});
it('translates from URL format to filesystem format', () => {
const path = 'file:///Users/someone/Development%20Files/signal/electron/background.html';
const expected = '/Users/someone/Development Files/signal/electron/background.html';
const actual = _urlToPath(path);
expect(actual).to.equal(expected);
});
it('translates from URL format to filesystem format', () => {
const path = 'file:///Users/someone/Development%20Files/signal/electron/background.html';
const expected = '/Users/someone/Development Files/signal/electron/background.html';
const actual = _urlToPath(path);
expect(actual).to.equal(expected);
});
// this seems to be the only way to get a relative path through Electron
it('handles SMB share path', () => {
const path = 'file://relative/path';
const expected = 'relative/path';
const actual = _urlToPath(path);
expect(actual).to.equal(expected);
});
it('handles SMB share path on windows', () => {
const path = 'file://relative/path';
const expected = 'elative/path';
const isWindows = true;
const actual = _urlToPath(path, { isWindows });
expect(actual).to.equal(expected);
});
it('hands back a path with .. in it', () => {
const path = 'file://../../..';
const expected = '../../..';
const actual = _urlToPath(path);
expect(actual).to.equal(expected);
});
});
});

File diff suppressed because one or more lines are too long

View File

@ -1,112 +0,0 @@
/* global Signal, textsecure, libsignal */
'use strict';
describe('Crypto', () => {
describe('symmetric encryption', () => {
it('roundtrips', async () => {
const message = 'this is my message';
const plaintext = dcodeIO.ByteBuffer.wrap(message, 'binary').toArrayBuffer();
const key = textsecure.crypto.getRandomBytes(32);
const encrypted = await Signal.Crypto.encryptSymmetric(key, plaintext);
const decrypted = await Signal.Crypto.decryptSymmetric(key, encrypted);
const equal = Signal.Crypto.constantTimeEqual(plaintext, decrypted);
if (!equal) {
throw new Error('The output and input did not match!');
}
});
it('roundtrip fails if nonce is modified', async () => {
const message = 'this is my message';
const plaintext = dcodeIO.ByteBuffer.wrap(message, 'binary').toArrayBuffer();
const key = textsecure.crypto.getRandomBytes(32);
const encrypted = await Signal.Crypto.encryptSymmetric(key, plaintext);
const uintArray = new Uint8Array(encrypted);
uintArray[2] += 2;
try {
await Signal.Crypto.decryptSymmetric(key, uintArray.buffer);
} catch (error) {
assert.strictEqual(
error.message,
'decryptSymmetric: Failed to decrypt; MAC verification failed'
);
return;
}
throw new Error('Expected error to be thrown');
});
it('roundtrip fails if mac is modified', async () => {
const message = 'this is my message';
const plaintext = dcodeIO.ByteBuffer.wrap(message, 'binary').toArrayBuffer();
const key = textsecure.crypto.getRandomBytes(32);
const encrypted = await Signal.Crypto.encryptSymmetric(key, plaintext);
const uintArray = new Uint8Array(encrypted);
uintArray[uintArray.length - 3] += 2;
try {
await Signal.Crypto.decryptSymmetric(key, uintArray.buffer);
} catch (error) {
assert.strictEqual(
error.message,
'decryptSymmetric: Failed to decrypt; MAC verification failed'
);
return;
}
throw new Error('Expected error to be thrown');
});
it('roundtrip fails if encrypted contents are modified', async () => {
const message = 'this is my message';
const plaintext = dcodeIO.ByteBuffer.wrap(message, 'binary').toArrayBuffer();
const key = textsecure.crypto.getRandomBytes(32);
const encrypted = await Signal.Crypto.encryptSymmetric(key, plaintext);
const uintArray = new Uint8Array(encrypted);
uintArray[35] += 9;
try {
await Signal.Crypto.decryptSymmetric(key, uintArray.buffer);
} catch (error) {
assert.strictEqual(
error.message,
'decryptSymmetric: Failed to decrypt; MAC verification failed'
);
return;
}
throw new Error('Expected error to be thrown');
});
});
describe('attachment encryption', () => {
it('roundtrips', async () => {
const staticKeyPair = await libsignal.KeyHelper.generateIdentityKeyPair();
const message = 'this is my message';
const plaintext = Signal.Crypto.bytesFromString(message);
const path = 'fa/facdf99c22945b1c9393345599a276f4b36ad7ccdc8c2467f5441b742c2d11fa';
const encrypted = await Signal.Crypto.encryptAttachment(
staticKeyPair.pubKey.slice(1),
path,
plaintext
);
const decrypted = await Signal.Crypto.decryptAttachment(
staticKeyPair.privKey,
path,
encrypted
);
const equal = Signal.Crypto.constantTimeEqual(plaintext, decrypted);
if (!equal) {
throw new Error('The output and input did not match!');
}
});
});
});

View File

@ -1,36 +0,0 @@
/* global Whisper */
'use strict';
describe('Database', () => {
describe('handleDOMException', () => {
it('handles null, still calls reject', () => {
let called = 0;
const reject = () => {
called += 1;
};
const error = null;
const prefix = 'something';
Whisper.Database.handleDOMException(prefix, error, reject);
assert.strictEqual(called, 1);
});
it('handles object code and message', () => {
let called = 0;
const reject = () => {
called += 1;
};
const error = {
code: 4,
message: 'some cryptic error',
};
const prefix = 'something';
Whisper.Database.handleDOMException(prefix, error, reject);
assert.strictEqual(called, 1);
});
});
});

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
/* global $, textsecure, Whisper */
'use strict';
describe('Fixtures', () => {
before(async () => {
// NetworkStatusView checks this method every five seconds while showing
await clearDatabase();
await textsecure.storage.user.setNumberAndDeviceId(
'05123456789abcdef05123456789abcdef05123456789abcdef05123456789abcd',
2,
'testDevice'
);
await window
.getConversationController()
.getOrCreateAndWait(window.libsession.Utils.UserUtils.getOurPubKeyStrFromCache(), 'private');
});
it('renders', async () => {
await Whisper.Fixtures().saveAll();
window.getConversationController().reset();
await window.getConversationController().load();
let view = new Whisper.InboxView({ window });
view.$el.prependTo($('#render-light-theme'));
view = new Whisper.InboxView({ window });
view.$el.removeClass('light-theme').addClass('dark-theme');
view.$el.prependTo($('#render-dark-theme'));
});
});

View File

@ -1,27 +0,0 @@
/* global i18n */
describe('i18n', () => {
describe('i18n', () => {
it('returns empty string for unknown string', () => {
assert.strictEqual(i18n('random'), '');
});
it('returns message for given string', () => {
assert.equal(i18n('reportIssue'), 'Report an issue');
});
it('returns message with single substitution', () => {
const actual = i18n('attemptingReconnection', 5);
assert.equal(actual, 'Attempting reconnect in 5 seconds');
});
it('returns message with multiple substitutions', () => {
const actual = i18n('theyChangedTheTimer', ['Someone', '5 minutes']);
assert.equal(actual, 'Someone set the disappearing message timer to 5 minutes');
});
});
describe('getLocale', () => {
it('returns a string with length two or greater', () => {
const locale = i18n.getLocale();
assert.isAtLeast(locale.trim().length, 2);
});
});
});

View File

@ -1,63 +0,0 @@
<html>
<head>
<meta charset="utf-8">
<title>TextSecure test runner</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<link rel="stylesheet" href="../stylesheets/manifest.css" />
</head>
<body>
<div id="mocha">
</div>
<div id="tests">
</div>
<div id="render-light-theme" class="index" style="width: 800; height: 500; margin:10px; border: solid 1px black;">
</div>
<div id="render-dark-theme" class="index" style="width: 800; height: 500; margin:10px; border: solid 1px black;">
</div>
</div>
<script type="text/javascript" src="../js/components.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="../js/registration.js" data-cover></script>
<script type="text/javascript" src="../js/chromium.js" data-cover></script>
<script type="text/javascript" src="../js/database.js" data-cover></script>
<script type="text/javascript" src="../js/storage.js" data-cover></script>
<script type="text/javascript" src="../js/libtextsecure.js" data-cover></script>
<script type="text/javascript" src="../js/expiring_messages.js" data-cover></script>
<script type="text/javascript" src="../js/notifications.js" data-cover></script>
<script type="text/javascript" src="../js/focus_listener.js"></script>
<script type="text/javascript" src="../js/chromium.js" data-cover></script>
<script type="text/javascript" src="../js/views/react_wrapper_view.js"></script>
<script type="text/javascript" src="../js/views/whisper_view.js"></script>
<script type='text/javascript' src='../js/views/session_inbox_view.js'></script>
<script type="text/javascript" src="../js/views/identicon_svg_view.js"></script>
<script type="text/javascript" src="../js/views/session_registration_view.js"></script>
<script type="text/javascript" src="../js/views/app_view.js"></script>
<!-- DIALOGS-->
<script type="text/javascript" src="views/whisper_view_test.js"></script>
<script type="text/javascript" src="models/conversations_test.js"></script>
<script type="text/javascript" src="models/messages_test.js"></script>
<script type="text/javascript" src="database_test.js"></script>
<script type="text/javascript" src="i18n_test.js"></script>
<script type="text/javascript" src="fixtures.js"></script>
<script type="text/javascript" src="fixtures_test.js"></script>
<script type="text/javascript">
mocha.run();
</script>
</body>
</html>

View File

@ -1,51 +0,0 @@
Manual test script
Some things are very difficult to test programmatically. Also, if you don't have adequate test coverage, a good first step is a comprehensive manual test script! https://blog.scottnonnenberg.com/web-application-test-strategy/
Conversation view:
Last seen indicator:
(dismissed three ways: 1. sending a message 2. switching away from conversation and back again 3. clicking scroll down button when last seen indicator is off-screen above)
- Switch away from Signal app, but keep it visible
- Receive messages to conversation out of focus, and the last seen indicator should move up the screen with each new message. When the number of new messages can no longer fit on the screen, the last seen indicator should stay at the top of the screen, and new messages will appear below. The scroll down button will turn blue to indicate new messages out of view.
- Switch back to Signal app, and the last seen indicator and scroll down button should stay where they are.
- Click the scroll down button to go to the bottom of the window, and the button should disappear.
- Send a message, then scroll up. The last seen indicator should be gone.
- Switch to a different conversation, then receive messages on original conversation
- Switch back to original conversation, and the last seen indicator should be visible
- Switch away from conversation and back. The last seen indicator should be gone.
- Switch to a different conversation, then receive a lot of messages on original conversation
- Switch back to original conversation, and the last seen indicator should be visible, along with the scroll down button.
- Click the scroll down button to be taken to the newest message in the conversation
- Scroll up on a conversation then switch to another application, keeping the Signal application visible. Receive new messages on that conversation. Switch back to application. The scroll down button should be blue, and the conversation scroll location should stay where it was. There should be a last seen indicator visible above the new messages.
- Scroll to bottom of a conversation, then switch to another application, keeping Signal application visible. Receive new messages on that conversation. As new messages come in, the last seen indicator should march up the screen. Before it reaches the top, switch back to the application. This will mark those messages as read. Switch away from the application again, and receive new messages. The last seen indicator will scroll off the top of the screen as more and more new messages come in.
- ADVANCED: Set up an automated script (or friend) to send you repeated messages. You should see the right number of unread upon entry of the conversation, along with with the last seen indicator. While the conversation is focused, new messages should increment the last seen indicator until it is offscreen above. Click the scroll down button to eliminate the last seen indicator, then scroll up. New messages received while scrolled up should not scroll the conversation, but will add a new last seen indicator and scroll down button.
- ADVANCED: Set fetch limit to a low number, like 3 (in models/messages.js, fetchConversation function). Load the application, and don't select the conversation. Receive more than four new messages in that conversation. Select the conversation. The last seen indicator should reflect the total number of new messages and all of them should be visible.
Marking messages as unread:
- Switch to a different conversation, then receive lots of messages on original conversation, more than would fill the screen
- Note the count before clicking into the conversation. Count the number of visible messages and ensure that the conversation's unread count is decremented by the right amount.
- Slowly scroll down so that one more message is visible. The conversation unread count should go down by one.
- Click the scroll down button. All messages should be marked read - even if you skipped a couple screens to get to the bottom.
Scrolling:
- If scrolled to bottom of a conversation, should stay there when a new message comes in
- If scrolled to the middle of a conversation, should stay there when a new message comes in
- When you've scrolled up an entire screen's worth, a scroll down button in the bottom right should appear.
Scroll-down button:
- Clicking it takes you to the bottom of the conversation, makes the button disappear
- If a new message comes in while it is already showing, it turns blue
- If a new message comes in while not at the bottom of the conversation (but button is not already showing), it should appear, already blue.
- If you've scrolled up higher than the last seen indicator, then clicking the scroll down button should take you to the last seen indicator. Once there, clicking the button will take you to the bottom of the conversation, at which point the button will disappear.
Electron window locations
- Load app, move and resize window, close app. Start app. Window should be in the same place, with the same size.
- (OSX) Load app, full-screen window, close app. Start app. Window should be full screen.
- (Windows) Load app, maximize window, close app. Start app. Window should be maximized.

View File

@ -1,129 +0,0 @@
// /* global textsecure, Whisper */
// 'use strict';
// FIXME audric enable back those test
describe('ConversationCollection', () => {
// textsecure.messaging = true;
// before(clearDatabase);
// after(clearDatabase);
// it('should be ordered newest to oldest', () => {
// const conversations = new window.models.Conversation.ConversationCollection();
// // Timestamps
// const today = new Date();
// const tomorrow = new Date();
// tomorrow.setDate(today.getDate() + 1);
// // Add convos
// conversations.add({ active_at: today });
// conversations.add({ active_at: tomorrow });
// const { models } = conversations;
// const firstTimestamp = models[0].get('active_at').getTime();
// const secondTimestamp = models[1].get('active_at').getTime();
// // Compare timestamps
// assert(firstTimestamp > secondTimestamp);
// });
// });
// describe('Conversation', () => {
// const attributes = {
// type: 'private',
// id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// };
// before(async () => {
// const convo = new window.models.Conversation.ConversationCollection().add(attributes);
// await window.Signal.Data.saveConversation(convo.attributes, {
// Conversation: window.models.Conversation.ConversationModel,
// });
// // const message = convo.messageCollection.add({
// // body: 'hello world',
// // conversationId: convo.id,
// // type: 'outgoing',
// // sent_at: Date.now(),
// // received_at: Date.now(),
// // });
// // await message.commit(false);
// });
// after(clearDatabase);
// it('contains its own messages', async () => {
// const convo = new window.models.Conversation.ConversationCollection().add({
// id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// });
// await convo.fetchMessages();
// assert.notEqual(convo.messageCollection.length, 0);
// });
// it('contains only its own messages', async () => {
// const convo = new window.models.Conversation.ConversationCollection().add({
// id: '052d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// });
// await convo.fetchMessages();
// assert.strictEqual(convo.messageCollection.length, 0);
// });
// it('adds conversation to message collection upon leaving group', async () => {
// const convo = new window.models.Conversation.ConversationCollection().add({
// type: 'group',
// id: '052d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// });
// await convo.leaveClosedGroup();
// assert.notEqual(convo.messageCollection.length, 0);
// });
// it('has a title', () => {
// const convos = new window.models.Conversation.ConversationCollection();
// let convo = convos.add(attributes);
// assert.equal(
// convo.getTitle(),
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab'
// );
// convo = convos.add({ type: '' });
// assert.equal(convo.getTitle(), 'Unknown group');
// convo = convos.add({ name: 'name' });
// assert.equal(convo.getTitle(), 'name');
// });
// it('returns the number', () => {
// const convos = new window.models.Conversation.ConversationCollection();
// let convo = convos.add(attributes);
// assert.equal(
// convo.getNumber(),
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab'
// );
// convo = convos.add({ type: '' });
// assert.equal(convo.getNumber(), '');
// });
// describe('when set to private', () => {
// it('correctly validates hex numbers', () => {
// const regularId = new window.models.Conversation.ConversationModel({
// type: 'private',
// id:
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// });
// const invalidId = new window.models.Conversation.ConversationModel({
// type: 'private',
// id:
// 'j71d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// });
// assert.ok(regularId.isValid());
// assert.notOk(invalidId.isValid());
// });
// it('correctly validates length', () => {
// const regularId33 = new window.models.Conversation.ConversationModel({
// type: 'private',
// id:
// '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// });
// const regularId32 = new window.models.Conversation.ConversationModel({
// type: 'private',
// id: '1d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',
// });
// const shortId = new window.models.Conversation.ConversationModel({
// type: 'private',
// id: '771d11d',
// });
// const longId = new window.models.Conversation.ConversationModel({
// type: 'private',
// id:
// '771d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94abaa',
// });
// assert.ok(regularId33.isValid());
// assert.ok(regularId32.isValid());
// assert.notOk(shortId.isValid());
// assert.notOk(longId.isValid());
// });
// });
});

View File

@ -1,154 +0,0 @@
'use strict';
const attributes = {
type: 'outgoing',
body: 'hi',
conversationId: 'foo',
attachments: [],
received_at: new Date().getTime(),
};
const source = '+14155555555';
describe('MessageCollection', () => {
before(async () => {
await clearDatabase();
window.getConversationController().reset();
window.textsecure.storage.user.getNumber = () =>
'051111111111111111111111111111111111111111111111111111111111111111';
await window.getConversationController().load();
});
after(() => {
return clearDatabase();
});
it('gets outgoing contact', () => {
const messages = new window.models.Message.MessageCollection();
const message = messages.add(attributes);
message.getContact();
});
it('gets incoming contact', () => {
const messages = new window.models.Message.MessageCollection();
const message = messages.add({
type: 'incoming',
source,
conversationId: 'conversationId',
});
message.getContact();
});
it('should be ordered oldest to newest', () => {
const messages = new window.models.Message.MessageCollection();
// Timestamps
const today = new Date();
const tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
// Add threads
messages.add({ received_at: today, conversationId: 'conversationId' });
messages.add({ received_at: tomorrow, conversationId: 'conversationId' });
const { models } = messages;
const firstTimestamp = models[0].get('received_at').getTime();
const secondTimestamp = models[1].get('received_at').getTime();
// Compare timestamps
assert(firstTimestamp < secondTimestamp);
});
// it('checks if is incoming message', () => {
// const messages = new window.models.Message.MessageCollection();
// let message = messages.add(attributes);
// assert.notOk(message.isIncoming());
// message = messages.add({
// type: 'incoming',
// conversationId: 'conversationId',
// });
// assert.ok(message.isIncoming());
// });
// it('checks if is outgoing message', () => {
// const messages = new window.models.Message.MessageCollection();
// let message = messages.add(attributes);
// assert.ok(message.isOutgoing());
// message = messages.add({
// type: 'incoming',
// conversationId: 'conversationId',
// });
// assert.notOk(message.isOutgoing());
// });
it('checks if is group update', () => {
const messages = new window.models.Message.MessageCollection();
let message = messages.add(attributes);
assert.notOk(message.isGroupUpdate());
message = messages.add({
group_update: true,
conversationId: 'conversationId',
});
assert.ok(message.isGroupUpdate());
});
it('returns an accurate description', () => {
const messages = new window.models.Message.MessageCollection();
let message = messages.add(attributes);
assert.equal(
message.getDescription(),
'hi',
'If no group updates or end session flags, return message body.'
);
message = messages.add({
group_update: { left: 'Alice' },
conversationId: 'conversationId',
});
assert.equal(
message.getDescription(),
'Alice has left the group.',
'Notes one person leaving the group.'
);
message = messages.add({
group_update: { name: 'blerg' },
conversationId: 'conversationId',
});
assert.equal(
message.getDescription(),
"Group name is now 'blerg'.",
'Returns a single notice if only group_updates.name changes.'
);
message = messages.add({
group_update: { joined: ['Bob'] },
conversationId: 'conversationId',
});
assert.equal(
message.getDescription(),
'Bob joined the group.',
'Returns a single notice if only group_updates.joined changes.'
);
message = messages.add({
group_update: { joined: ['Bob', 'Alice', 'Eve'] },
conversationId: 'conversationId',
});
assert.equal(
message.getDescription(),
'Bob, Alice, Eve joined the group.',
'Notes when >1 person joins the group.'
);
message = messages.add({
group_update: { joined: ['Bob'], name: 'blerg' },
conversationId: 'conversationId',
});
assert.equal(
message.getDescription(),
"Group name is now 'blerg'. Bob joined the group.",
'Notes when there are multiple changes to group_updates properties.'
);
});
});

View File

@ -1,30 +0,0 @@
// For reference: https://github.com/airbnb/javascript
module.exports = {
env: {
mocha: true,
browser: true,
},
globals: {
check: true,
gen: true,
},
parserOptions: {
sourceType: 'module',
},
rules: {
// We still get the value of this rule, it just allows for dev deps
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
// We want to keep each test structured the same, even if its contents are tiny
'arrow-body-style': 'off',
},
};

View File

@ -1,161 +0,0 @@
const path = require('path');
const { assert } = require('chai');
const Privacy = require('../../js/modules/privacy');
const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
describe('Privacy', () => {
describe('redactSessionID', () => {
it('should redact all session IDs', () => {
const text =
'This is a log line with a session ID 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 and another one 05766049a70e725ad02f7fe61b10e461380a4d7433f98096b3cacbf0362d5cab62';
const actual = Privacy.redactSessionID(text);
const expected = 'This is a log line with a session ID [REDACTED] and another one [REDACTED]';
assert.equal(actual, expected);
});
it('should not redact non session IDS', () => {
const text =
'This is a log line with a non-session ID sadsad0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827888 and another one 766049a70e725ad02f7fe61b10e461380a4d7433f98096b3cacbf0362d5cab6234';
const actual = Privacy.redactSessionID(text);
assert.equal(actual, text);
});
});
describe('redactGroupIds', () => {
it('should redact all group IDs', () => {
const text = 'This is a log line with two group IDs: group(123456789) and group(abcdefghij)';
const actual = Privacy.redactGroupIds(text);
const expected =
'This is a log line with two group IDs: group([REDACTED]789) and group([REDACTED]hij)';
assert.equal(actual, expected);
});
it('should remove newlines from redacted group IDs', () => {
const text =
'This is a log line with two group IDs: group(12345678\n9)\nand group(abc\ndefghij)';
const actual = Privacy.redactGroupIds(text);
const expected =
'This is a log line with two group IDs: group([REDACTED]789)\n' +
'and group([REDACTED]hij)';
assert.equal(actual, expected);
});
});
describe('redactAll', () => {
it('should redact all sensitive information', () => {
const encodedAppRootPath = APP_ROOT_PATH.replace(/ /g, '%20');
const text =
'This is a log line with sensitive information:\n' +
`path1 ${APP_ROOT_PATH}/main.js\n` +
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n' +
'group 31032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 eeee\n' +
'group1 group(123456789) doloret\n' +
`path2 file:///${encodedAppRootPath}/js/background.js.` +
'phone2 0531033dc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 lorem\n' +
'group2 group(abcdefghij) doloret\n' +
'url1 https://you-have-to-hide.me aaa\n' +
'url1 http://you-have-to-hide.me bbb\n' +
'url1 127.0.0.1:22021 ccc\n';
const actual = Privacy.redactAll(text);
const expected =
'This is a log line with sensitive information:\n' +
'path1 [REDACTED]/main.js\n' +
'phone1 [REDACTED] ipsum\n' +
'group [REDACTED] eeee\n' +
'group1 group([REDACTED]789) doloret\n' +
'path2 file:///[REDACTED]/js/background.js.' +
'phone2 [REDACTED] lorem\n' +
'group2 group([REDACTED]hij) doloret\n' +
'url1 [REDACTED] aaa\n' +
'url1 [REDACTED] bbb\n' +
'url1 [REDACTED]:22021 ccc\n';
assert.equal(actual, expected);
});
});
describe('_redactPath', () => {
it('should redact file paths', () => {
const testPath = '/Users/meow/Library/Application Support/Signal Beta';
const text =
'This is a log line with sensitive information:\n' +
`path1 ${testPath}/main.js\n` +
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n';
const actual = Privacy._redactPath(testPath)(text);
const expected =
'This is a log line with sensitive information:\n' +
'path1 [REDACTED]/main.js\n' +
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n';
assert.equal(actual, expected);
});
it('should redact URL-encoded paths', () => {
const testPath = '/Users/meow/Library/Application Support/Signal Beta';
const encodedTestPath = encodeURI(testPath);
const text =
'This is a log line with sensitive information:\n' +
`path1 ${testPath}/main.js\n` +
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n' +
'group1 group(123456789) doloret\n' +
`path2 file:///${encodedTestPath}/js/background.js.`;
const actual = Privacy._redactPath(testPath)(text);
const expected =
'This is a log line with sensitive information:\n' +
'path1 [REDACTED]/main.js\n' +
'phone1 0531032fc7415b7cc1b7516480ad121d391eddce3cfb2cee27dd5b215609c32827 ipsum\n' +
'group1 group(123456789) doloret\n' +
'path2 file:///[REDACTED]/js/background.js.';
assert.equal(actual, expected);
});
it('should redact stack traces with both forward and backslashes', () => {
const testPath = 'C:/Users/Meow/AppData/Local/Programs/loki-messenger-beta';
const modifiedTestPath = 'C:\\Users\\Meow\\AppData\\Local\\Programs\\loki-messenger-beta';
const text =
'This is a log line with sensitive information:\n' +
`path1 ${testPath}\\main.js\n` +
'phone1 +12223334455 ipsum\n' +
'group1 group(123456789) doloret\n' +
`path2 ${modifiedTestPath}\\js\\background.js.`;
const actual = Privacy._redactPath(testPath)(text);
const expected =
'This is a log line with sensitive information:\n' +
'path1 [REDACTED]\\main.js\n' +
'phone1 +12223334455 ipsum\n' +
'group1 group(123456789) doloret\n' +
'path2 [REDACTED]\\js\\background.js.';
assert.equal(actual, expected);
});
it('should redact stack traces with escaped backslashes', () => {
const testPath = 'C:\\Users\\Meow\\AppData\\Local\\Programs\\loki-messenger-beta';
const modifiedTestPath =
'C:\\\\Users\\\\Meow\\\\AppData\\\\Local\\\\Programs\\\\loki-messenger-beta';
const text =
'This is a log line with sensitive information:\n' +
`path1 ${testPath}\\main.js\n` +
'phone1 +12223334455 ipsum\n' +
'group1 group(123456789) doloret\n' +
`path2 ${modifiedTestPath}\\js\\background.js.`;
const actual = Privacy._redactPath(testPath)(text);
const expected =
'This is a log line with sensitive information:\n' +
'path1 [REDACTED]\\main.js\n' +
'phone1 +12223334455 ipsum\n' +
'group1 group(123456789) doloret\n' +
'path2 [REDACTED]\\js\\background.js.';
assert.equal(actual, expected);
});
});
});

View File

@ -1,226 +0,0 @@
require('mocha-testcheck').install();
const { assert } = require('chai');
const Attachment = require('../../../js/modules/types/attachment');
const { stringToArrayBuffer } = require('../../../js/modules/string_to_array_buffer');
describe('Attachment', () => {
describe('replaceUnicodeOrderOverrides', () => {
it('should sanitize left-to-right order override character', async () => {
const input = {
contentType: 'image/jpeg',
fileName: 'test\u202Dfig.exe',
size: 1111,
};
const expected = {
contentType: 'image/jpeg',
fileName: 'test\uFFFDfig.exe',
size: 1111,
};
const actual = await Attachment.replaceUnicodeOrderOverrides(input);
assert.deepEqual(actual, expected);
});
it('should sanitize right-to-left order override character', async () => {
const input = {
contentType: 'image/jpeg',
fileName: 'test\u202Efig.exe',
size: 1111,
};
const expected = {
contentType: 'image/jpeg',
fileName: 'test\uFFFDfig.exe',
size: 1111,
};
const actual = await Attachment.replaceUnicodeOrderOverrides(input);
assert.deepEqual(actual, expected);
});
it('should sanitize multiple override characters', async () => {
const input = {
contentType: 'image/jpeg',
fileName: 'test\u202e\u202dlol\u202efig.exe',
size: 1111,
};
const expected = {
contentType: 'image/jpeg',
fileName: 'test\uFFFD\uFFFDlol\uFFFDfig.exe',
size: 1111,
};
const actual = await Attachment.replaceUnicodeOrderOverrides(input);
assert.deepEqual(actual, expected);
});
const hasNoUnicodeOrderOverrides = value =>
!value.includes('\u202D') && !value.includes('\u202E');
check.it(
'should ignore non-order-override characters',
gen.string.suchThat(hasNoUnicodeOrderOverrides),
fileName => {
const input = {
contentType: 'image/jpeg',
fileName,
size: 1111,
};
const actual = Attachment._replaceUnicodeOrderOverridesSync(input);
assert.deepEqual(actual, input);
}
);
});
describe('replaceUnicodeV2', () => {
it('should remove all bad characters', async () => {
const input = {
size: 1111,
fileName:
'file\u202A\u202B\u202C\u202D\u202E\u2066\u2067\u2068\u2069\u200E\u200F\u061C.jpeg',
};
const expected = {
fileName:
'file\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD.jpeg',
size: 1111,
};
const actual = await Attachment.replaceUnicodeV2(input);
assert.deepEqual(actual, expected);
});
it('should should leave normal filename alone', async () => {
const input = {
fileName: 'normal.jpeg',
size: 1111,
};
const expected = {
fileName: 'normal.jpeg',
size: 1111,
};
const actual = await Attachment.replaceUnicodeV2(input);
assert.deepEqual(actual, expected);
});
it('should handle missing fileName', async () => {
const input = {
size: 1111,
};
const expected = {
size: 1111,
};
const actual = await Attachment.replaceUnicodeV2(input);
assert.deepEqual(actual, expected);
});
});
describe('removeSchemaVersion', () => {
it('should remove existing schema version', () => {
const input = {
contentType: 'image/jpeg',
fileName: 'foo.jpg',
size: 1111,
schemaVersion: 1,
};
const expected = {
contentType: 'image/jpeg',
fileName: 'foo.jpg',
size: 1111,
};
const actual = Attachment.removeSchemaVersion({
attachment: input,
logger: {
error: () => null,
},
});
assert.deepEqual(actual, expected);
});
});
describe('migrateDataToFileSystem', () => {
it('should write data to disk and store relative path to it', async () => {
const input = {
contentType: 'image/jpeg',
data: stringToArrayBuffer('Above us only sky'),
fileName: 'foo.jpg',
size: 1111,
};
const expected = {
contentType: 'image/jpeg',
path: 'abc/abcdefgh123456789',
fileName: 'foo.jpg',
size: 1111,
};
const expectedAttachmentData = stringToArrayBuffer('Above us only sky');
const writeNewAttachmentData = async attachmentData => {
assert.deepEqual(attachmentData, expectedAttachmentData);
return 'abc/abcdefgh123456789';
};
const actual = await Attachment.migrateDataToFileSystem(input, {
writeNewAttachmentData,
logger: {
warn: () => null,
},
});
assert.deepEqual(actual, expected);
});
it('should skip over (invalid) attachments without data', async () => {
const input = {
contentType: 'image/jpeg',
fileName: 'foo.jpg',
size: 1111,
};
const expected = {
contentType: 'image/jpeg',
fileName: 'foo.jpg',
size: 1111,
};
const writeNewAttachmentData = async () => 'abc/abcdefgh123456789';
const actual = await Attachment.migrateDataToFileSystem(input, {
writeNewAttachmentData,
logger: {
warn: () => null,
},
});
assert.deepEqual(actual, expected);
});
it('should throw error if data is not valid', async () => {
const input = {
contentType: 'image/jpeg',
data: 42,
fileName: 'foo.jpg',
size: 1111,
};
const writeNewAttachmentData = async () => 'abc/abcdefgh123456789';
try {
await Attachment.migrateDataToFileSystem(input, {
writeNewAttachmentData,
logger: {
warn: () => null,
},
});
} catch (error) {
assert.strictEqual(error.message, 'Expected 42 to be an array buffer got: number');
return;
}
assert.fail('Unreachable');
});
});
});

View File

@ -1,37 +0,0 @@
const Path = require('path');
const { assert } = require('chai');
const Errors = require('../../../js/modules/types/errors');
const APP_ROOT_PATH = Path.join(__dirname, '..', '..', '..');
describe('Errors', () => {
describe('toLogFormat', () => {
it('should return error stack trace if present', () => {
const error = new Error('boom');
assert.typeOf(error, 'Error');
const formattedError = Errors.toLogFormat(error);
assert.include(formattedError, 'errors_test.js');
assert.include(formattedError, APP_ROOT_PATH, 'Formatted stack has app path');
});
it('should return error string representation if stack is missing', () => {
const error = new Error('boom');
error.stack = null;
assert.typeOf(error, 'Error');
assert.isNull(error.stack);
const formattedError = Errors.toLogFormat(error);
assert.strictEqual(formattedError, 'Error: boom');
});
[0, false, null, undefined].forEach(value => {
it(`should return \`${value}\` argument`, () => {
const formattedNonError = Errors.toLogFormat(value);
assert.strictEqual(formattedNonError, value);
});
});
});
});

View File

@ -1,581 +0,0 @@
const { assert } = require('chai');
const sinon = require('sinon');
const Message = require('../../../js/modules/types/message');
const { SignalService } = require('../../../ts/protobuf');
const { stringToArrayBuffer } = require('../../../js/modules/string_to_array_buffer');
describe('Message', () => {
const logger = {
warn: () => null,
error: () => null,
};
describe('createAttachmentDataWriter', () => {
it('should ignore messages that didnt go through attachment migration', async () => {
const input = {
body: 'Imagine there is no heaven…',
schemaVersion: 2,
};
const expected = {
body: 'Imagine there is no heaven…',
schemaVersion: 2,
};
const writeExistingAttachmentData = () => {};
const actual = await Message.createAttachmentDataWriter({
writeExistingAttachmentData,
logger,
})(input);
assert.deepEqual(actual, expected);
});
it('should ignore messages without attachments', async () => {
const input = {
body: 'Imagine there is no heaven…',
schemaVersion: 4,
attachments: [],
};
const expected = {
body: 'Imagine there is no heaven…',
schemaVersion: 4,
attachments: [],
};
const writeExistingAttachmentData = () => {};
const actual = await Message.createAttachmentDataWriter({
writeExistingAttachmentData,
logger,
})(input);
assert.deepEqual(actual, expected);
});
it('should write attachments to file system on original path', async () => {
const input = {
body: 'Imagine there is no heaven…',
schemaVersion: 4,
attachments: [
{
path: 'ab/abcdefghi',
data: stringToArrayBuffer('Its easy if you try'),
},
],
};
const expected = {
body: 'Imagine there is no heaven…',
schemaVersion: 4,
attachments: [
{
path: 'ab/abcdefghi',
},
],
preview: [],
};
const writeExistingAttachmentData = attachment => {
assert.equal(attachment.path, 'ab/abcdefghi');
assert.deepEqual(attachment.data, stringToArrayBuffer('Its easy if you try'));
};
const actual = await Message.createAttachmentDataWriter({
writeExistingAttachmentData,
logger,
})(input);
assert.deepEqual(actual, expected);
});
it('should process quote attachment thumbnails', async () => {
const input = {
body: 'Imagine there is no heaven…',
schemaVersion: 4,
attachments: [],
quote: {
attachments: [
{
thumbnail: {
path: 'ab/abcdefghi',
data: stringToArrayBuffer('Its easy if you try'),
},
},
],
},
};
const expected = {
body: 'Imagine there is no heaven…',
schemaVersion: 4,
attachments: [],
quote: {
attachments: [
{
thumbnail: {
path: 'ab/abcdefghi',
},
},
],
},
preview: [],
};
const writeExistingAttachmentData = attachment => {
assert.equal(attachment.path, 'ab/abcdefghi');
assert.deepEqual(attachment.data, stringToArrayBuffer('Its easy if you try'));
};
const actual = await Message.createAttachmentDataWriter({
writeExistingAttachmentData,
logger,
})(input);
assert.deepEqual(actual, expected);
});
});
describe('initializeSchemaVersion', () => {
it('should ignore messages with previously inherited schema', () => {
const input = {
body: 'Imagine there is no heaven…',
schemaVersion: 2,
};
const expected = {
body: 'Imagine there is no heaven…',
schemaVersion: 2,
};
const actual = Message.initializeSchemaVersion({
message: input,
logger,
});
assert.deepEqual(actual, expected);
});
context('for message without attachments', () => {
it('should initialize schema version to zero', () => {
const input = {
body: 'Imagine there is no heaven…',
attachments: [],
};
const expected = {
body: 'Imagine there is no heaven…',
attachments: [],
schemaVersion: 0,
};
const actual = Message.initializeSchemaVersion({
message: input,
logger,
});
assert.deepEqual(actual, expected);
});
});
context('for message with attachments', () => {
it('should inherit existing attachment schema version', () => {
const input = {
body: 'Imagine there is no heaven…',
attachments: [
{
contentType: 'image/jpeg',
fileName: 'lennon.jpg',
schemaVersion: 7,
},
],
};
const expected = {
body: 'Imagine there is no heaven…',
attachments: [
{
contentType: 'image/jpeg',
fileName: 'lennon.jpg',
},
],
schemaVersion: 7,
};
const actual = Message.initializeSchemaVersion({
message: input,
logger,
});
assert.deepEqual(actual, expected);
});
});
});
describe('upgradeSchema', () => {
it('should upgrade an unversioned message to the latest version', async () => {
const input = {
attachments: [
{
contentType: 'audio/aac',
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
data: stringToArrayBuffer('Its easy if you try'),
fileName: 'test\u202Dfig.exe',
size: 1111,
},
],
schemaVersion: 0,
};
const expected = {
attachments: [
{
contentType: 'audio/aac',
flags: 1,
path: 'abc/abcdefg',
fileName: 'test\uFFFDfig.exe',
size: 1111,
},
],
hasAttachments: 1,
hasVisualMediaAttachments: undefined,
hasFileAttachments: undefined,
schemaVersion: Message.CURRENT_SCHEMA_VERSION,
};
const expectedAttachmentData = stringToArrayBuffer('Its easy if you try');
const context = {
writeNewAttachmentData: async attachmentData => {
assert.deepEqual(attachmentData, expectedAttachmentData);
return 'abc/abcdefg';
},
getAbsoluteAttachmentPath: () => 'some/path/on/disk',
makeObjectUrl: () => 'blob://FAKE',
revokeObjectUrl: () => null,
getImageDimensions: () => ({ height: 10, width: 15 }),
makeImageThumbnail: () => new Blob(),
makeVideoScreenshot: () => new Blob(),
logger: {
warn: () => null,
error: () => null,
},
};
const actual = await Message.upgradeSchema(input, context);
assert.deepEqual(actual, expected);
});
context('with multiple upgrade steps', () => {
it('should return last valid message when any upgrade step fails', async () => {
const input = {
attachments: [
{
contentType: 'application/json',
data: null,
fileName: 'test\u202Dfig.exe',
size: 1111,
},
],
schemaVersion: 0,
};
const expected = {
attachments: [
{
contentType: 'application/json',
data: null,
fileName: 'test\u202Dfig.exe',
size: 1111,
},
],
hasUpgradedToVersion1: true,
schemaVersion: 1,
};
const v1 = async message => Object.assign({}, message, { hasUpgradedToVersion1: true });
const v2 = async () => {
throw new Error('boom');
};
const v3 = async message => Object.assign({}, message, { hasUpgradedToVersion3: true });
const toVersion1 = Message._withSchemaVersion({
schemaVersion: 1,
upgrade: v1,
});
const toVersion2 = Message._withSchemaVersion({
schemaVersion: 2,
upgrade: v2,
});
const toVersion3 = Message._withSchemaVersion({
schemaVersion: 3,
upgrade: v3,
});
const context = { logger };
const upgradeSchema = async message =>
toVersion3(await toVersion2(await toVersion1(message, context), context), context);
const actual = await upgradeSchema(input);
assert.deepEqual(actual, expected);
});
it('should skip out-of-order upgrade steps', async () => {
const input = {
attachments: [
{
contentType: 'application/json',
data: null,
fileName: 'test\u202Dfig.exe',
size: 1111,
},
],
schemaVersion: 0,
};
const expected = {
attachments: [
{
contentType: 'application/json',
data: null,
fileName: 'test\u202Dfig.exe',
size: 1111,
},
],
schemaVersion: 2,
hasUpgradedToVersion1: true,
hasUpgradedToVersion2: true,
};
const v1 = async attachment =>
Object.assign({}, attachment, { hasUpgradedToVersion1: true });
const v2 = async attachment =>
Object.assign({}, attachment, { hasUpgradedToVersion2: true });
const v3 = async attachment =>
Object.assign({}, attachment, { hasUpgradedToVersion3: true });
const toVersion1 = Message._withSchemaVersion({
schemaVersion: 1,
upgrade: v1,
});
const toVersion2 = Message._withSchemaVersion({
schemaVersion: 2,
upgrade: v2,
});
const toVersion3 = Message._withSchemaVersion({
schemaVersion: 3,
upgrade: v3,
});
const context = { logger };
// NOTE: We upgrade to 3 before 2, i.e. the pipeline should abort:
const upgradeSchema = async attachment =>
toVersion2(await toVersion3(await toVersion1(attachment, context), context), context);
const actual = await upgradeSchema(input);
assert.deepEqual(actual, expected);
});
});
});
describe('_withSchemaVersion', () => {
it('should require a version number', () => {
const toVersionX = () => {};
assert.throws(
() => Message._withSchemaVersion({ schemaVersion: toVersionX, upgrade: 2 }),
'_withSchemaVersion: schemaVersion is invalid'
);
});
it('should require an upgrade function', () => {
assert.throws(
() => Message._withSchemaVersion({ schemaVersion: 2, upgrade: 3 }),
'_withSchemaVersion: upgrade must be a function'
);
});
it('should skip upgrading if message has already been upgraded', async () => {
const upgrade = async message => Object.assign({}, message, { foo: true });
const upgradeWithVersion = Message._withSchemaVersion({
schemaVersion: 3,
upgrade,
});
const input = {
id: 'guid-guid-guid-guid',
schemaVersion: 4,
};
const expected = {
id: 'guid-guid-guid-guid',
schemaVersion: 4,
};
const actual = await upgradeWithVersion(input, { logger });
assert.deepEqual(actual, expected);
});
it('should return original message if upgrade function throws', async () => {
const upgrade = async () => {
throw new Error('boom!');
};
const upgradeWithVersion = Message._withSchemaVersion({
schemaVersion: 3,
upgrade,
});
const input = {
id: 'guid-guid-guid-guid',
schemaVersion: 0,
};
const expected = {
id: 'guid-guid-guid-guid',
schemaVersion: 0,
};
const actual = await upgradeWithVersion(input, { logger });
assert.deepEqual(actual, expected);
});
it('should return original message if upgrade function returns null', async () => {
const upgrade = async () => null;
const upgradeWithVersion = Message._withSchemaVersion({
schemaVersion: 3,
upgrade,
});
const input = {
id: 'guid-guid-guid-guid',
schemaVersion: 0,
};
const expected = {
id: 'guid-guid-guid-guid',
schemaVersion: 0,
};
const actual = await upgradeWithVersion(input, { logger });
assert.deepEqual(actual, expected);
});
});
describe('_mapQuotedAttachments', () => {
it('handles message with no quote', async () => {
const upgradeAttachment = sinon.stub().throws(new Error("Shouldn't be called"));
const upgradeVersion = Message._mapQuotedAttachments(upgradeAttachment);
const message = {
body: 'hey there!',
};
const result = await upgradeVersion(message);
assert.deepEqual(result, message);
});
it('handles quote with no attachments', async () => {
const upgradeAttachment = sinon.stub().throws(new Error("Shouldn't be called"));
const upgradeVersion = Message._mapQuotedAttachments(upgradeAttachment);
const message = {
body: 'hey there!',
quote: {
text: 'hey!',
},
};
const expected = {
body: 'hey there!',
quote: {
text: 'hey!',
attachments: [],
},
};
const result = await upgradeVersion(message, { logger });
assert.deepEqual(result, expected);
});
it('handles zero attachments', async () => {
const upgradeAttachment = sinon.stub().throws(new Error("Shouldn't be called"));
const upgradeVersion = Message._mapQuotedAttachments(upgradeAttachment);
const message = {
body: 'hey there!',
quote: {
text: 'hey!',
attachments: [],
},
};
const result = await upgradeVersion(message, { logger });
assert.deepEqual(result, message);
});
it('handles attachments with no thumbnail', async () => {
const upgradeAttachment = sinon.stub().throws(new Error("Shouldn't be called"));
const upgradeVersion = Message._mapQuotedAttachments(upgradeAttachment);
const message = {
body: 'hey there!',
quote: {
text: 'hey!',
attachments: [
{
fileName: 'manifesto.txt',
contentType: 'text/plain',
},
],
},
};
const result = await upgradeVersion(message, { logger });
assert.deepEqual(result, message);
});
it('does not eliminate thumbnails with missing data field', async () => {
const upgradeAttachment = sinon.stub().returns({ fileName: 'processed!' });
const upgradeVersion = Message._mapQuotedAttachments(upgradeAttachment);
const message = {
body: 'hey there!',
quote: {
text: 'hey!',
attachments: [
{
fileName: 'cat.gif',
contentType: 'image/gif',
thumbnail: {
fileName: 'not yet downloaded!',
},
},
],
},
};
const expected = {
body: 'hey there!',
quote: {
text: 'hey!',
attachments: [
{
contentType: 'image/gif',
fileName: 'cat.gif',
thumbnail: {
fileName: 'processed!',
},
},
],
},
};
const result = await upgradeVersion(message, { logger });
assert.deepEqual(result, expected);
});
it('calls provided async function for each quoted attachment', async () => {
const upgradeAttachment = sinon.stub().resolves({
path: '/new/path/on/disk',
});
const upgradeVersion = Message._mapQuotedAttachments(upgradeAttachment);
const message = {
body: 'hey there!',
quote: {
text: 'hey!',
attachments: [
{
thumbnail: {
data: 'data is here',
},
},
],
},
};
const expected = {
body: 'hey there!',
quote: {
text: 'hey!',
attachments: [
{
thumbnail: {
path: '/new/path/on/disk',
},
},
],
},
};
const result = await upgradeVersion(message, { logger });
assert.deepEqual(result, expected);
});
});
});

View File

@ -1,28 +0,0 @@
const { assert } = require('chai');
const MIME = require('../../../ts/types/MIME');
describe('MIME', () => {
describe('isJPEG', () => {
it('should return true for `image/jpeg`', () => {
assert.isTrue(MIME.isJPEG('image/jpeg'));
});
[
'jpg',
'jpeg',
'image/jpg', // invalid MIME type: https://stackoverflow.com/a/37266399/125305
'image/gif',
'image/tiff',
'application/json',
0,
false,
null,
undefined,
].forEach(value => {
it(`should return false for \`${value}\``, () => {
assert.isFalse(MIME.isJPEG(value));
});
});
});
});

View File

@ -1,20 +0,0 @@
require('mocha-testcheck').install();
const { assert } = require('chai');
const SchemaVersion = require('../../../js/modules/types/schema_version');
describe('SchemaVersion', () => {
describe('isValid', () => {
check.it('should return true for positive integers', gen.posInt, input => {
assert.isTrue(SchemaVersion.isValid(input));
});
check.it(
'should return false for any other value',
gen.primitive.suchThat(value => typeof value !== 'number' || value < 0),
input => {
assert.isFalse(SchemaVersion.isValid(input));
}
);
});
});

View File

@ -1,38 +0,0 @@
/* global Whisper */
describe('Whisper.View', () => {
it('renders a template with render_attributes', () => {
const ViewClass = Whisper.View.extend({
template: '<div>{{ variable }}</div>',
render_attributes: {
variable: 'value',
},
});
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>value</div>');
});
it('renders a template with no render_attributes', () => {
const ViewClass = Whisper.View.extend({
template: '<div>static text</div>',
});
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>static text</div>');
});
it('renders a template function with render_attributes function', () => {
const ViewClass = Whisper.View.extend({
template() {
return '<div>{{ variable }}</div>';
},
render_attributes() {
return { variable: 'value' };
},
});
const view = new ViewClass();
view.render();
assert.strictEqual(view.$el.html(), '<div>value</div>');
});
});

View File

@ -80,7 +80,7 @@ export async function sendApiV2Request(
throw new Error('Invalid request');
}
if (!window.globalOnlineStatus) {
if (!window.getGlobalOnlineStatus()) {
throw new pRetry.AbortError('Network is not available');
}

View File

@ -12,6 +12,7 @@ const minimumGuardCount = 2;
import { updateOnionPaths } from '../../state/ducks/onion';
import { ERROR_CODE_NO_CONNECT } from '../snode_api/SNodeAPI';
import { getStoragePubKey } from '../types/PubKey';
const ONION_REQUEST_HOPS = 3;
export let onionPaths: Array<Array<Snode>> = [];
@ -175,7 +176,7 @@ export async function incrementBadPathCountOrDrop(snodeEd25519: string) {
);
if (pathWithSnodeIndex === -1) {
(window?.log?.info || console.warn)('Did not find any path containing this snode');
window?.log?.info('Did not find any path containing this snode');
// this can only be bad. throw an abortError so we use another path if needed
throw new pRetry.AbortError(
'incrementBadPathCountOrDrop: Did not find any path containing this snode'
@ -255,7 +256,7 @@ async function testGuardNode(snode: Snode) {
const url = `https://${snode.ip}:${snode.port}${endpoint}`;
const ourPK = UserUtils.getOurPubKeyStrFromCache();
const pubKey = window.getStoragePubKey(ourPK); // truncate if testnet
const pubKey = getStoragePubKey(ourPK); // truncate if testnet
const method = 'get_snodes_for_pubkey';
const params = { pubKey };
@ -331,7 +332,7 @@ export async function selectGuardNodes(): Promise<Array<Snode>> {
// we only want to repeat if the await fails
// eslint-disable-next-line-no-await-in-loop
while (selectedGuardNodes.length < desiredGuardCount) {
if (!window.globalOnlineStatus) {
if (!window.getGlobalOnlineStatus()) {
window?.log?.error('selectedGuardNodes: offline');
throw new Error('selectedGuardNodes: offline');
}

View File

@ -79,7 +79,6 @@ const getSslAgentForSeedNode = (seedNodeHost: string, isSsl = false) => {
const sslOptions = {
// as the seed nodes are using a self signed certificate, we have to provide it here.
ca: crt,
// we might need to selectively disable that for tests on swarm-testing or so.
// we have to reject them, otherwise our errors returned in the checkServerIdentity are simply not making the call fail.
// so in production, rejectUnauthorized must be true.
rejectUnauthorized: true,
@ -91,8 +90,6 @@ const getSslAgentForSeedNode = (seedNodeHost: string, isSsl = false) => {
return err;
}
// we might need to selectively disable that for tests on swarm-testing or so.
// Pin the public key, similar to HPKP pin-sha25 pinning
if (sha256(cert.pubkey) !== pubkey256) {
const msg =

View File

@ -1,5 +1,6 @@
import { default as insecureNodeFetch } from 'node-fetch';
import { Snode } from '../../data/data';
import { getStoragePubKey } from '../types';
import { lokiOnionFetch, snodeHttpsAgent, SnodeResponse } from './onions';
@ -32,7 +33,11 @@ async function lokiFetch(
try {
// Absence of targetNode indicates that we want a direct connection
// (e.g. to connect to a seed node for the first time)
if (window.lokiFeatureFlags.useOnionRequests && targetNode) {
const useOnionRequests =
window.lokiFeatureFlags?.useOnionRequests === undefined
? true
: window.lokiFeatureFlags?.useOnionRequests;
if (useOnionRequests && targetNode) {
const fetchResult = await lokiOnionFetch(targetNode, fetchOptions.body, associatedWith, test);
if (!fetchResult) {
return undefined;
@ -92,7 +97,7 @@ export async function snodeRpc(
// tslint:disable-next-line no-parameter-reassignment
params = {
...params,
pubKey: window.getStoragePubKey(params.pubKey),
pubKey: getStoragePubKey(params.pubKey),
};
}
const body = {

View File

@ -599,7 +599,7 @@ export async function incrementBadSnodeCountOrDrop({
associatedWith?: string;
}) {
if (!guardNodeEd25519) {
console.warn('We need a guardNodeEd25519 at all times');
window?.log?.warn('We need a guardNodeEd25519 at all times');
}
const oldFailureCount = snodeFailureCount[snodeEd25519] || 0;
const newFailureCount = oldFailureCount + 1;
@ -608,7 +608,7 @@ export async function incrementBadSnodeCountOrDrop({
window?.log?.warn(`Failure threshold reached for: ${ed25519Str(snodeEd25519)}; dropping it.`);
if (associatedWith) {
(window?.log?.info || console.warn)(
window?.log?.warn(
`Dropping ${ed25519Str(snodeEd25519)} from swarm of ${ed25519Str(associatedWith)}`
);
await dropSnodeFromSwarmIfNeeded(associatedWith, snodeEd25519);

View File

@ -120,7 +120,6 @@ export class SwarmPolling {
if (currentTimestamp - activeAt <= DURATION.DAYS * 7) {
return SWARM_POLLING_TIMEOUT.MEDIUM_ACTIVE;
}
return SWARM_POLLING_TIMEOUT.INACTIVE;
}
@ -128,7 +127,7 @@ export class SwarmPolling {
* Only public for testing
*/
public async TEST_pollForAllKeys() {
if (!window.globalOnlineStatus) {
if (!window.getGlobalOnlineStatus()) {
window?.log?.error('pollForAllKeys: offline');
// Important to set up a new polling
setTimeout(this.TEST_pollForAllKeys.bind(this), SWARM_POLLING_TIMEOUT.ACTIVE);
@ -150,12 +149,12 @@ export class SwarmPolling {
?.idForLogging() || group.pubkey.key;
if (diff >= convoPollingTimeout) {
(window?.log?.info || console.warn)(
window?.log?.info(
`Polling for ${loggingId}; timeout: ${convoPollingTimeout} ; diff: ${diff}`
);
return this.TEST_pollOnceForKey(group.pubkey, true);
}
(window?.log?.info || console.warn)(
window?.log?.info(
`Not polling for ${loggingId}; timeout: ${convoPollingTimeout} ; diff: ${diff}`
);
@ -190,7 +189,6 @@ export class SwarmPolling {
const COUNT = 1;
let nodesToPoll = _.sampleSize(alreadyPolled, COUNT);
if (nodesToPoll.length < COUNT) {
const notPolled = _.difference(snodes, alreadyPolled);

View File

@ -1,5 +1,8 @@
import { fromHexToArray } from '../utils/String';
export const getStoragePubKey = (key: string) =>
window.isDev?.() || false ? key.substring(2) : key;
export class PubKey {
public static readonly PUBKEY_LEN = 66;
public static readonly HEX = '[0-9a-fA-F]';

View File

@ -1,6 +1,5 @@
import * as sinon from 'sinon';
import * as DataShape from '../../../../ts/data/data';
import { Application } from 'spectron';
const globalAny: any = global;
const sandbox = sinon.createSandbox();
@ -51,21 +50,6 @@ export function stubWindow<K extends keyof Window>(fn: K, value: WindowValue<K>)
};
}
export async function spyMessageQueueSend(app: Application) {
await app.webContents.executeJavaScript(
"var messageQueueSpy = sinon.spy(window.libsession.getMessageQueue(), 'send'); "
);
}
export async function getAllMessagesSent(app: Application) {
const messageQueueSpy = await app.webContents.executeJavaScript('messageQueueSpy.args;');
if (!messageQueueSpy) {
throw new Error('Be sure to call spyMessageQueueSend() on the correct app first.');
}
const messages = await app.webContents.executeJavaScript('messageQueueSpy.args');
return messages;
}
export function restoreStubs() {
globalAny.window = undefined;
sandbox.restore();

View File

@ -144,7 +144,6 @@ const excludedFiles = [
'^node_modules/snapdragon-util/*',
'^node_modules/snapdragon/*',
'^node_modules/sockjs-client/*',
'^node_modules/spectron/*',
'^node_modules/style-loader/*',
'^node_modules/svgo/*',
'^node_modules/text-encoding/*',

4
ts/window.d.ts vendored
View File

@ -63,9 +63,9 @@ declare global {
toggleMenuBar: any;
toggleSpellCheck: any;
setTheme: (newTheme: string) => any;
isDev?: () => boolean;
userConfig: any;
versionInfo: any;
getStoragePubKey: (key: string) => string;
getConversations: () => ConversationCollection;
profileImages: any;
MediaRecorder: any;
@ -78,7 +78,7 @@ declare global {
messageId?: string | undefined;
}) => Promise<void>;
LokiPushNotificationServer: any;
globalOnlineStatus: boolean;
getGlobalOnlineStatus: () => boolean;
confirmationDialog: any;
callWorker: (fnName: string, ...args: any) => Promise<any>;
setStartInTray: (val: boolean) => Promise<void>;

1020
yarn.lock

File diff suppressed because it is too large Load Diff