Skip to content

Commit

Permalink
chore: revert
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed May 2, 2024
1 parent 141ec1a commit 2a7319f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 40 deletions.
15 changes: 0 additions & 15 deletions packages/puppeteer-core/src/cdp/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import type {CdpPage} from './Page.js';
export class CdpFrame extends Frame {
#url = '';
#detached = false;
#isBeingSwapped = false;
#client!: CDPSession;
worlds!: IsolatedWorldChart;

Expand Down Expand Up @@ -87,7 +86,6 @@ export class CdpFrame extends Frame {
}

updateClient(client: CDPSession, keepWorlds = false): void {
this.#isBeingSwapped = false;
this.#client = client;
if (!keepWorlds) {
// Clear the current contexts on previous world instances.
Expand Down Expand Up @@ -322,27 +320,23 @@ export class CdpFrame extends Frame {
_navigated(framePayload: Protocol.Page.Frame): void {
this._name = framePayload.name;
this.#url = `${framePayload.url}${framePayload.urlFragment || ''}`;
this.#isBeingSwapped = false;
}

_navigatedWithinDocument(url: string): void {
this.#url = url;
this.#isBeingSwapped = false;
}

_onLifecycleEvent(loaderId: string, name: string): void {
if (name === 'init') {
this._loaderId = loaderId;
this._lifecycleEvents.clear();
}
this.#isBeingSwapped = false;
this._lifecycleEvents.add(name);
}

_onLoadingStopped(): void {
this._lifecycleEvents.add('DOMContentLoaded');
this._lifecycleEvents.add('load');
this.#isBeingSwapped = false;
}

_onLoadingStarted(): void {
Expand All @@ -365,13 +359,4 @@ export class CdpFrame extends Frame {
exposeFunction(): never {
throw new UnsupportedOperation();
}

onFrameSwap(): void {
this.#isBeingSwapped = true;
this.emit(FrameEvent.FrameSwapped, undefined);
}

get isBeingSwapped(): boolean {
return this.#isBeingSwapped;
}
}
6 changes: 2 additions & 4 deletions packages/puppeteer-core/src/cdp/FrameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
}

frames(): CdpFrame[] {
return Array.from(this._frameTree.frames()).filter(frame => {
return !frame.isBeingSwapped;
});
return Array.from(this._frameTree.frames());
}

frame(frameId: string): CdpFrame | null {
Expand Down Expand Up @@ -465,7 +463,7 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
break;
case 'swap':
this.emit(FrameManagerEvent.FrameSwapped, frame);
frame.onFrameSwap();
frame.emit(FrameEvent.FrameSwapped, undefined);
break;
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/puppeteer-core/src/cdp/LifecycleWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ export class LifecycleWatcher {
for (const child of frame.childFrames()) {
if (
child._hasStartedLoading &&
!child.isBeingSwapped &&
!checkLifecycle(child, expectedLifecycle)
) {
return false;
Expand Down
1 change: 1 addition & 0 deletions packages/puppeteer-core/src/node/ChromeLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export class ChromeLauncher extends ProductLauncher {

// Merge default enabled features with user-provided ones, if any.
const enabledFeatures = [
'PdfOopif',
// Add features to enable by default here.
...userEnabledFeatures,
].filter(feature => {
Expand Down
7 changes: 0 additions & 7 deletions test/TestExpectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -2952,13 +2952,6 @@
"expectations": ["SKIP"],
"comment": "Failed previously and currently times out"
},
{
"testIdPattern": "[oopif.spec] OOPIF should load a page with a PDF viewer",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["FAIL"],
"comment": "https://github.com/GoogleChromeLabs/chromium-bidi/issues/2175"
},
{
"testIdPattern": "[oopif.spec] OOPIF should report google.com frame",
"platforms": ["darwin", "linux", "win32"],
Expand Down
16 changes: 5 additions & 11 deletions test/src/cdp/TargetManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('TargetManager', () => {
});

// CDP-specific test.
it.deflake(10, 'should handle targets', async () => {
it('should handle targets', async () => {
const {server, context, browser} = state;

const targetManager = browser._targetManager();
Expand All @@ -64,11 +64,9 @@ describe('TargetManager', () => {
await framePromise;
expect(await context.pages()).toHaveLength(1);
expect(targetManager.getAvailableTargets().size).toBe(5);
await page.waitForFrame(() => {
return page.frames().length === 2;
});
expect(page.frames()).toHaveLength(2);

// attach a remote frame iframe.
// // attach a remote frame iframe.
framePromise = page.waitForFrame(frame => {
return frame.url() === server.CROSS_PROCESS_PREFIX + '/empty.html';
});
Expand All @@ -80,9 +78,7 @@ describe('TargetManager', () => {
await framePromise;
expect(await context.pages()).toHaveLength(1);
expect(targetManager.getAvailableTargets().size).toBe(6);
await page.waitForFrame(() => {
return page.frames().length === 3;
});
expect(page.frames()).toHaveLength(3);

framePromise = page.waitForFrame(frame => {
return frame.url() === server.CROSS_PROCESS_PREFIX + '/empty.html';
Expand All @@ -95,8 +91,6 @@ describe('TargetManager', () => {
await framePromise;
expect(await context.pages()).toHaveLength(1);
expect(targetManager.getAvailableTargets().size).toBe(7);
await page.waitForFrame(() => {
return page.frames().length === 4;
});
expect(page.frames()).toHaveLength(4);
});
});
9 changes: 7 additions & 2 deletions test/src/oopif.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ describe('OOPIF', function () {
).toEqual([true, true, false]);
});

it('should load a page with a PDF viewer', async () => {
it.deflakeOnly(50, 'should load a page with a PDF viewer', async () => {

Check failure on line 428 in test/src/oopif.spec.ts

View workflow job for this annotation

GitHub Actions / [Required] Inspect code

Unexpected debugging mocha test
const {page, server} = state;

await page.goto(server.PREFIX + '/pdf-viewer.html', {
Expand All @@ -440,7 +440,12 @@ describe('OOPIF', function () {
});
})
)
).toEqual(['/pdf-viewer.html', '/sample.pdf']);
).toEqual([
'/pdf-viewer.html',
'/sample.pdf',
'/index.html',
'/sample.pdf',
]);
});

describe('waitForFrame', () => {
Expand Down

0 comments on commit 2a7319f

Please sign in to comment.