Skip to content

Commit

Permalink
Adds debugging utilities in dev/beta environments
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-signal committed Jan 19, 2023
1 parent ac50af5 commit 86488b9
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 146 deletions.
4 changes: 2 additions & 2 deletions ts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ export async function startApp(): Promise<void> {
},

requestChallenge(request) {
if (window.Signal.CI) {
window.Signal.CI.handleEvent('challenge', request);
if (window.SignalCI) {
window.SignalCI.handleEvent('challenge', request);
return;
}
window.sendChallengeRequest(request);
Expand Down
2 changes: 1 addition & 1 deletion ts/components/conversation/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ export class Message extends React.PureComponent<Props, State> {
status === 'viewed')
) {
const delta = Date.now() - timestamp;
window.Signal.CI?.handleEvent('message:send-complete', {
window.SignalCI?.handleEvent('message:send-complete', {
timestamp,
delta,
});
Expand Down
2 changes: 1 addition & 1 deletion ts/messageModifiers/MessageReceipts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export class MessageReceipts extends Collection<MessageReceiptModel> {

// We want the above call to not be delayed when testing with
// CI.
window.Signal.CI
window.SignalCI
? deleteSentProtoBatcher.flushAndWait()
: Promise.resolve(),
]);
Expand Down
2 changes: 1 addition & 1 deletion ts/models/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5529,7 +5529,7 @@ export class ConversationModel extends window.Backbone
const delta = now - startedAt;

log.info(`conversation ${this.idForLogging()} open took ${delta}ms`);
window.Signal.CI?.handleEvent('conversation:open', { delta });
window.SignalCI?.handleEvent('conversation:open', { delta });
}

async flushDebouncedUpdates(): Promise<void> {
Expand Down
12 changes: 6 additions & 6 deletions ts/services/calling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class CallingClass {

private reduxInterface?: CallingReduxInterface;

private sfuUrl?: string;
public _sfuUrl?: string;

private lastMediaDeviceSettings?: MediaDeviceSettings;

Expand Down Expand Up @@ -307,7 +307,7 @@ export class CallingClass {
throw new Error('CallingClass.initialize: Invalid uxActions.');
}

this.sfuUrl = sfuUrl;
this._sfuUrl = sfuUrl;

this.previousAudioDeviceModule = parseAudioDeviceModule(
window.storage.get('previousAudioDeviceModule')
Expand Down Expand Up @@ -610,7 +610,7 @@ export class CallingClass {
return statefulPeekInfo;
}

if (!this.sfuUrl) {
if (!this._sfuUrl) {
throw new Error('Missing SFU URL; not peeking group call');
}

Expand All @@ -633,7 +633,7 @@ export class CallingClass {
const membershipProof = Bytes.fromString(proof);

return RingRTC.peekGroupCall(
this.sfuUrl,
this._sfuUrl,
Buffer.from(membershipProof),
this.getGroupCallMembers(conversationId)
);
Expand Down Expand Up @@ -669,7 +669,7 @@ export class CallingClass {
return existing;
}

if (!this.sfuUrl) {
if (!this._sfuUrl) {
throw new Error('Missing SFU URL; not connecting group call');
}

Expand All @@ -680,7 +680,7 @@ export class CallingClass {

const outerGroupCall = RingRTC.getGroupCall(
groupIdBuffer,
this.sfuUrl,
this._sfuUrl,
Buffer.alloc(0),
AUDIO_LEVEL_INTERVAL_MS,
{
Expand Down
4 changes: 2 additions & 2 deletions ts/services/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1733,8 +1733,8 @@ async function sync(
// We now know that we've successfully completed a storage service fetch
await window.storage.put('storageFetchComplete', true);

if (window.Signal.CI) {
window.Signal.CI.handleEvent('storageServiceComplete', {
if (window.SignalCI) {
window.SignalCI.handleEvent('storageServiceComplete', {
manifestVersion: version,
});
}
Expand Down
4 changes: 2 additions & 2 deletions ts/state/smart/InstallScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export function SmartInstallScreen(): ReactElement {
}
onQrCodeScanned();

if (window.Signal.CI) {
if (window.SignalCI) {
chooseDeviceNamePromiseWrapperRef.current.resolve(
window.Signal.CI.deviceName
window.SignalCI.deviceName
);
}

Expand Down
4 changes: 2 additions & 2 deletions ts/test-mock/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class App {
const window = await this.getWindow();

await window.evaluate(
`window.Signal.CI.solveChallenge(${JSON.stringify(response)})`
`window.SignalCI.solveChallenge(${JSON.stringify(response)})`
);
}

Expand All @@ -105,7 +105,7 @@ export class App {
const window = await this.getWindow();

const result = await window.evaluate(
`window.Signal.CI.waitForEvent(${JSON.stringify(event)})`
`window.SignalCI.waitForEvent(${JSON.stringify(event)})`
);

return result as T;
Expand Down
2 changes: 1 addition & 1 deletion ts/textsecure/AccountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default class AccountManager extends EventTarget {
}
const url = getProvisioningUrl(uuid, pubKey);

window.Signal.CI?.setProvisioningURL(url);
window.SignalCI?.setProvisioningURL(url);

setProvisioningUrl(url);
request.respond(200, 'OK');
Expand Down
24 changes: 13 additions & 11 deletions ts/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ export type IPCType = {
updateTrayIcon: (count: number) => void;
};

export type FeatureFlagType = {
GV2_ENABLE_SINGLE_CHANGE_PROCESSING: boolean;
GV2_ENABLE_CHANGE_PROCESSING: boolean;
GV2_ENABLE_STATE_PROCESSING: boolean;
GV2_ENABLE_PRE_JOIN_FETCH: boolean;
GV2_MIGRATION_DISABLE_ADD: boolean;
GV2_MIGRATION_DISABLE_INVITE: boolean;
};

export type SignalCoreType = {
Crypto: typeof Crypto;
Curve: typeof Curve;
Expand Down Expand Up @@ -128,9 +137,6 @@ export type SignalCoreType = {
};
conversationControllerStart: () => void;
challengeHandler?: ChallengeHandler;

// Test only
CI?: CIType;
};

declare global {
Expand Down Expand Up @@ -214,14 +220,7 @@ declare global {
reduxStore: Store<StateType>;

// Feature Flags
Flags: {
GV2_ENABLE_SINGLE_CHANGE_PROCESSING: boolean;
GV2_ENABLE_CHANGE_PROCESSING: boolean;
GV2_ENABLE_STATE_PROCESSING: boolean;
GV2_ENABLE_PRE_JOIN_FETCH: boolean;
GV2_MIGRATION_DISABLE_ADD: boolean;
GV2_MIGRATION_DISABLE_INVITE: boolean;
};
Flags: FeatureFlagType;

// Paths
BasePaths: {
Expand All @@ -231,6 +230,9 @@ declare global {
temp: string;
};

// Test only
SignalCI?: CIType;

// TODO DESKTOP-4801
SignalContext: SignalContextType;

Expand Down
2 changes: 1 addition & 1 deletion ts/windows/main/phase4-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ if (config.environment === 'test') {
if (config.enableCI) {
console.log('Importing CI infrastructure...');
const { getCI } = require('../../CI');
window.Signal.CI = getCI(window.getTitle());
window.SignalCI = getCI(window.getTitle());
}
4 changes: 4 additions & 0 deletions ts/windows/main/preload_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { sync } from 'fast-glob';
// eslint-disable-next-line import/no-extraneous-dependencies
import { assert } from 'chai';

import { getSignalProtocolStore } from '../../SignalProtocolStore';

window.assert = assert;

// This is a hack to let us run TypeScript tests in the renderer process. See the
Expand All @@ -26,3 +28,5 @@ window.testUtilities = {
}).forEach(require);
},
};

window.getSignalProtocolStore = getSignalProtocolStore;

0 comments on commit 86488b9

Please sign in to comment.