codeGenerator no longer depends on Frame
This commit is contained in:
parent
569ace65e0
commit
e3e5355876
|
|
@ -494,7 +494,7 @@ class ContextRecorder extends EventEmitter {
|
||||||
private async _onPage(page: Page) {
|
private async _onPage(page: Page) {
|
||||||
// First page is called page, others are called popup1, popup2, etc.
|
// First page is called page, others are called popup1, popup2, etc.
|
||||||
const frame = page.mainFrame();
|
const frame = page.mainFrame();
|
||||||
page.on('close', () => {
|
page.on(Page.Events.Close, () => {
|
||||||
this._generator.addAction({
|
this._generator.addAction({
|
||||||
frame: this._describeMainFrame(page),
|
frame: this._describeMainFrame(page),
|
||||||
committed: true,
|
committed: true,
|
||||||
|
|
@ -673,26 +673,28 @@ class ContextRecorder extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onFrameNavigated(frame: Frame, page: Page) {
|
private _onFrameNavigated(frame: Frame, page: Page) {
|
||||||
|
if (frame._page.mainFrame() !== frame)
|
||||||
|
return;
|
||||||
const pageAlias = this._pageAliases.get(page);
|
const pageAlias = this._pageAliases.get(page);
|
||||||
this._generator.signal(pageAlias!, frame, { name: 'navigation', url: frame.url() });
|
this._generator.signal(pageAlias!, { name: 'navigation', url: frame.url() });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onPopup(page: Page, popup: Page) {
|
private _onPopup(page: Page, popup: Page) {
|
||||||
const pageAlias = this._pageAliases.get(page)!;
|
const pageAlias = this._pageAliases.get(page)!;
|
||||||
const popupAlias = this._pageAliases.get(popup)!;
|
const popupAlias = this._pageAliases.get(popup)!;
|
||||||
this._generator.signal(pageAlias, page.mainFrame(), { name: 'popup', popupAlias });
|
this._generator.signal(pageAlias, { name: 'popup', popupAlias });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onDownload(page: Page) {
|
private _onDownload(page: Page) {
|
||||||
const pageAlias = this._pageAliases.get(page)!;
|
const pageAlias = this._pageAliases.get(page)!;
|
||||||
++this._lastDownloadOrdinal;
|
++this._lastDownloadOrdinal;
|
||||||
this._generator.signal(pageAlias, page.mainFrame(), { name: 'download', downloadAlias: this._lastDownloadOrdinal ? String(this._lastDownloadOrdinal) : '' });
|
this._generator.signal(pageAlias, { name: 'download', downloadAlias: this._lastDownloadOrdinal ? String(this._lastDownloadOrdinal) : '' });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onDialog(page: Page) {
|
private _onDialog(page: Page) {
|
||||||
const pageAlias = this._pageAliases.get(page)!;
|
const pageAlias = this._pageAliases.get(page)!;
|
||||||
++this._lastDialogOrdinal;
|
++this._lastDialogOrdinal;
|
||||||
this._generator.signal(pageAlias, page.mainFrame(), { name: 'dialog', dialogAlias: this._lastDialogOrdinal ? String(this._lastDialogOrdinal) : '' });
|
this._generator.signal(pageAlias, { name: 'dialog', dialogAlias: this._lastDialogOrdinal ? String(this._lastDialogOrdinal) : '' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import type { BrowserContextOptions, LaunchOptions } from '../../..';
|
import type { BrowserContextOptions, LaunchOptions } from '../../..';
|
||||||
import type { Frame } from '../frames';
|
|
||||||
import type { LanguageGenerator, LanguageGeneratorOptions } from './language';
|
import type { LanguageGenerator, LanguageGeneratorOptions } from './language';
|
||||||
import type { Action, Signal, FrameDescription } from './recorderActions';
|
import type { Action, Signal, FrameDescription } from './recorderActions';
|
||||||
|
|
||||||
|
|
@ -121,7 +120,7 @@ export class CodeGenerator extends EventEmitter {
|
||||||
action.committed = true;
|
action.committed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
signal(pageAlias: string, frame: Frame, signal: Signal) {
|
signal(pageAlias: string, signal: Signal) {
|
||||||
if (!this._enabled)
|
if (!this._enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -141,7 +140,7 @@ export class CodeGenerator extends EventEmitter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signal.name === 'navigation' && frame._page.mainFrame() === frame) {
|
if (signal.name === 'navigation') {
|
||||||
this.addAction({
|
this.addAction({
|
||||||
frame: {
|
frame: {
|
||||||
pageAlias,
|
pageAlias,
|
||||||
|
|
@ -150,7 +149,7 @@ export class CodeGenerator extends EventEmitter {
|
||||||
committed: true,
|
committed: true,
|
||||||
action: {
|
action: {
|
||||||
name: 'navigate',
|
name: 'navigate',
|
||||||
url: frame.url(),
|
url: signal.url,
|
||||||
signals: [],
|
signals: [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue