Skip to content

Commit e7db54f

Browse files
committed
Smoke: only signal restored phase when contributions have executed (fix microsoft#199577)
1 parent 8c55ad1 commit e7db54f

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/vs/workbench/common/contributions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export interface IWorkbenchContributionsRegistry {
4444
* Starts the registry by providing the required services.
4545
*/
4646
start(accessor: ServicesAccessor): void;
47+
48+
/**
49+
* A promise that resolves when all contributions up to the `Restored`
50+
* phase have been instantiated.
51+
*/
52+
readonly whenRestored: Promise<void>;
4753
}
4854

4955
class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry {
@@ -54,7 +60,9 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
5460
private environmentService: IEnvironmentService | undefined;
5561

5662
private readonly contributions = new Map<LifecyclePhase, IConstructorSignature<IWorkbenchContribution>[]>();
63+
5764
private readonly pendingRestoredContributions = new DeferredPromise<void>();
65+
readonly whenRestored = this.pendingRestoredContributions.p;
5866

5967
registerWorkbenchContribution(contribution: IConstructorSignature<IWorkbenchContribution>, phase: LifecyclePhase = LifecyclePhase.Starting): void {
6068

src/vs/workbench/services/driver/browser/driver.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { IFileService } from 'vs/platform/files/common/files';
1212
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1313
import localizedStrings from 'vs/platform/languagePacks/common/localizedStrings';
1414
import { ILogFile, getLogs } from 'vs/platform/log/browser/log';
15+
import { ILogService } from 'vs/platform/log/common/log';
16+
import { Registry } from 'vs/platform/registry/common/platform';
17+
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
1518
import { IWindowDriver, IElement, ILocaleInfo, ILocalizedStrings } from 'vs/workbench/services/driver/common/driver';
1619
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
1720

@@ -21,15 +24,20 @@ export class BrowserWindowDriver implements IWindowDriver {
2124
@IFileService private readonly fileService: IFileService,
2225
@IEnvironmentService private readonly environmentService: IEnvironmentService,
2326
@ILifecycleService private readonly lifecycleService: ILifecycleService,
27+
@ILogService private readonly logService: ILogService
2428
) {
2529
}
2630

2731
async getLogs(): Promise<ILogFile[]> {
2832
return getLogs(this.fileService, this.environmentService);
2933
}
3034

31-
whenWorkbenchRestored(): Promise<void> {
32-
return this.lifecycleService.when(LifecyclePhase.Restored);
35+
async whenWorkbenchRestored(): Promise<void> {
36+
this.logService.info('[driver] Waiting for restored lifecycle phase...');
37+
await this.lifecycleService.when(LifecyclePhase.Restored);
38+
this.logService.info('[driver] Restored lifecycle phase reached. Waiting for contributions...');
39+
await Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).whenRestored;
40+
this.logService.info('[driver] Workbench contributions created.');
3341
}
3442

3543
async setValue(selector: string, text: string): Promise<void> {

src/vs/workbench/services/driver/electron-sandbox/driver.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { mainWindow } from 'vs/base/browser/window';
77
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
88
import { IFileService } from 'vs/platform/files/common/files';
99
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
10+
import { ILogService } from 'vs/platform/log/common/log';
1011
import { BrowserWindowDriver } from 'vs/workbench/services/driver/browser/driver';
1112
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
1213

@@ -20,9 +21,10 @@ class NativeWindowDriver extends BrowserWindowDriver {
2021
private readonly helper: INativeWindowDriverHelper,
2122
@IFileService fileService: IFileService,
2223
@IEnvironmentService environmentService: IEnvironmentService,
23-
@ILifecycleService lifecycleService: ILifecycleService
24+
@ILifecycleService lifecycleService: ILifecycleService,
25+
@ILogService logService: ILogService
2426
) {
25-
super(fileService, environmentService, lifecycleService);
27+
super(fileService, environmentService, lifecycleService, logService);
2628
}
2729

2830
override exitApplication(): Promise<void> {

0 commit comments

Comments
 (0)