test: attempt to unflake vscode highlight tests (#34267)
This commit is contained in:
parent
75d2661497
commit
b32d546159
|
@ -62,10 +62,11 @@ export class DebugController extends SdkObject {
|
||||||
setReportStateChanged(enabled: boolean) {
|
setReportStateChanged(enabled: boolean) {
|
||||||
if (enabled && !this._trackHierarchyListener) {
|
if (enabled && !this._trackHierarchyListener) {
|
||||||
this._trackHierarchyListener = {
|
this._trackHierarchyListener = {
|
||||||
onPageOpen: () => this._emitSnapshot(),
|
onPageOpen: () => this._emitSnapshot(false),
|
||||||
onPageClose: () => this._emitSnapshot(),
|
onPageClose: () => this._emitSnapshot(false),
|
||||||
};
|
};
|
||||||
this._playwright.instrumentation.addListener(this._trackHierarchyListener, null);
|
this._playwright.instrumentation.addListener(this._trackHierarchyListener, null);
|
||||||
|
this._emitSnapshot(true);
|
||||||
} else if (!enabled && this._trackHierarchyListener) {
|
} else if (!enabled && this._trackHierarchyListener) {
|
||||||
this._playwright.instrumentation.removeListener(this._trackHierarchyListener);
|
this._playwright.instrumentation.removeListener(this._trackHierarchyListener);
|
||||||
this._trackHierarchyListener = undefined;
|
this._trackHierarchyListener = undefined;
|
||||||
|
@ -162,24 +163,10 @@ export class DebugController extends SdkObject {
|
||||||
await Promise.all(this.allBrowsers().map(browser => browser.close({ reason: 'Close all browsers requested' })));
|
await Promise.all(this.allBrowsers().map(browser => browser.close({ reason: 'Close all browsers requested' })));
|
||||||
}
|
}
|
||||||
|
|
||||||
private _emitSnapshot() {
|
private _emitSnapshot(initial: boolean) {
|
||||||
const browsers = [];
|
const pageCount = this._playwright.allPages().length;
|
||||||
let pageCount = 0;
|
if (initial && !pageCount)
|
||||||
for (const browser of this._playwright.allBrowsers()) {
|
return;
|
||||||
const b = {
|
|
||||||
contexts: [] as any[]
|
|
||||||
};
|
|
||||||
browsers.push(b);
|
|
||||||
for (const context of browser.contexts()) {
|
|
||||||
const c = {
|
|
||||||
pages: [] as any[]
|
|
||||||
};
|
|
||||||
b.contexts.push(c);
|
|
||||||
for (const page of context.pages())
|
|
||||||
c.pages.push(page.mainFrame().url());
|
|
||||||
pageCount += context.pages().length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.emit(DebugController.Events.StateChanged, { pageCount });
|
this.emit(DebugController.Events.StateChanged, { pageCount });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ export class PollingRecorder implements RecorderDelegate {
|
||||||
const pollPeriod = 1000;
|
const pollPeriod = 1000;
|
||||||
if (this._pollRecorderModeTimer)
|
if (this._pollRecorderModeTimer)
|
||||||
clearTimeout(this._pollRecorderModeTimer);
|
clearTimeout(this._pollRecorderModeTimer);
|
||||||
const state = await this._embedder.__pw_recorderState().catch(() => {});
|
const state = await this._embedder.__pw_recorderState().catch(() => null);
|
||||||
if (!state) {
|
if (!state) {
|
||||||
this._pollRecorderModeTimer = this._recorder.injectedScript.builtinSetTimeout(() => this._pollRecorderMode(), pollPeriod);
|
this._pollRecorderModeTimer = this._recorder.injectedScript.builtinSetTimeout(() => this._pollRecorderMode(), pollPeriod);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue