config to replace performAction with recordAction
This commit is contained in:
parent
9122972570
commit
569ace65e0
|
|
@ -208,9 +208,11 @@ class RecordActionTool implements RecorderTool {
|
||||||
private _hoveredElement: HTMLElement | null = null;
|
private _hoveredElement: HTMLElement | null = null;
|
||||||
private _activeModel: HighlightModel | null = null;
|
private _activeModel: HighlightModel | null = null;
|
||||||
private _expectProgrammaticKeyUp = false;
|
private _expectProgrammaticKeyUp = false;
|
||||||
|
private _performActions: boolean;
|
||||||
|
|
||||||
constructor(recorder: Recorder) {
|
constructor(recorder: Recorder, performActions: boolean) {
|
||||||
this._recorder = recorder;
|
this._recorder = recorder;
|
||||||
|
this._performActions = performActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor() {
|
cursor() {
|
||||||
|
|
@ -261,21 +263,21 @@ class RecordActionTool implements RecorderTool {
|
||||||
onPointerDown(event: PointerEvent) {
|
onPointerDown(event: PointerEvent) {
|
||||||
if (this._shouldIgnoreMouseEvent(event))
|
if (this._shouldIgnoreMouseEvent(event))
|
||||||
return;
|
return;
|
||||||
if (!this._performingAction)
|
if (this._performActions && !this._performingAction)
|
||||||
consumeEvent(event);
|
consumeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPointerUp(event: PointerEvent) {
|
onPointerUp(event: PointerEvent) {
|
||||||
if (this._shouldIgnoreMouseEvent(event))
|
if (this._shouldIgnoreMouseEvent(event))
|
||||||
return;
|
return;
|
||||||
if (!this._performingAction)
|
if (this._performActions && !this._performingAction)
|
||||||
consumeEvent(event);
|
consumeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseDown(event: MouseEvent) {
|
onMouseDown(event: MouseEvent) {
|
||||||
if (this._shouldIgnoreMouseEvent(event))
|
if (this._shouldIgnoreMouseEvent(event))
|
||||||
return;
|
return;
|
||||||
if (!this._performingAction)
|
if (this._performActions && !this._performingAction)
|
||||||
consumeEvent(event);
|
consumeEvent(event);
|
||||||
this._activeModel = this._hoveredModel;
|
this._activeModel = this._hoveredModel;
|
||||||
}
|
}
|
||||||
|
|
@ -283,7 +285,7 @@ class RecordActionTool implements RecorderTool {
|
||||||
onMouseUp(event: MouseEvent) {
|
onMouseUp(event: MouseEvent) {
|
||||||
if (this._shouldIgnoreMouseEvent(event))
|
if (this._shouldIgnoreMouseEvent(event))
|
||||||
return;
|
return;
|
||||||
if (!this._performingAction)
|
if (this._performActions && !this._performingAction)
|
||||||
consumeEvent(event);
|
consumeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -398,7 +400,7 @@ class RecordActionTool implements RecorderTool {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Only allow programmatic keyups, ignore user input.
|
// Only allow programmatic keyups, ignore user input.
|
||||||
if (!this._expectProgrammaticKeyUp) {
|
if (this._performActions && !this._expectProgrammaticKeyUp) {
|
||||||
consumeEvent(event);
|
consumeEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -439,25 +441,33 @@ class RecordActionTool implements RecorderTool {
|
||||||
if (this._performingAction)
|
if (this._performingAction)
|
||||||
return true;
|
return true;
|
||||||
// Consume as the first thing.
|
// Consume as the first thing.
|
||||||
consumeEvent(event);
|
if (this._performActions)
|
||||||
|
consumeEvent(event);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _consumedDueToNoModel(event: Event, model: HighlightModel | null): boolean {
|
private _consumedDueToNoModel(event: Event, model: HighlightModel | null): boolean {
|
||||||
if (model)
|
if (model)
|
||||||
return false;
|
return false;
|
||||||
consumeEvent(event);
|
if (this._performActions)
|
||||||
|
consumeEvent(event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _consumedDueWrongTarget(event: Event): boolean {
|
private _consumedDueWrongTarget(event: Event): boolean {
|
||||||
if (this._activeModel && this._activeModel.elements[0] === this._recorder.deepEventTarget(event))
|
if (this._activeModel && this._activeModel.elements[0] === this._recorder.deepEventTarget(event))
|
||||||
return false;
|
return false;
|
||||||
consumeEvent(event);
|
if (this._performActions)
|
||||||
|
consumeEvent(event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _performAction(action: actions.Action) {
|
private async _performAction(action: actions.Action) {
|
||||||
|
if (!this._performActions) {
|
||||||
|
await this._recorder.delegate.recordAction?.(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._hoveredElement = null;
|
this._hoveredElement = null;
|
||||||
this._hoveredModel = null;
|
this._hoveredModel = null;
|
||||||
this._activeModel = null;
|
this._activeModel = null;
|
||||||
|
|
@ -947,7 +957,8 @@ export class Recorder {
|
||||||
readonly document: Document;
|
readonly document: Document;
|
||||||
delegate: RecorderDelegate = {};
|
delegate: RecorderDelegate = {};
|
||||||
|
|
||||||
constructor(injectedScript: InjectedScript) {
|
constructor(injectedScript: InjectedScript, performActions?: boolean) {
|
||||||
|
performActions = performActions === undefined || performActions === null ? true : performActions;
|
||||||
this.document = injectedScript.document;
|
this.document = injectedScript.document;
|
||||||
this.injectedScript = injectedScript;
|
this.injectedScript = injectedScript;
|
||||||
this.highlight = injectedScript.createHighlight();
|
this.highlight = injectedScript.createHighlight();
|
||||||
|
|
@ -955,7 +966,7 @@ export class Recorder {
|
||||||
'none': new NoneTool(),
|
'none': new NoneTool(),
|
||||||
'standby': new NoneTool(),
|
'standby': new NoneTool(),
|
||||||
'inspecting': new InspectTool(this, false),
|
'inspecting': new InspectTool(this, false),
|
||||||
'recording': new RecordActionTool(this),
|
'recording': new RecordActionTool(this, performActions),
|
||||||
'recording-inspecting': new InspectTool(this, false),
|
'recording-inspecting': new InspectTool(this, false),
|
||||||
'assertingText': new TextAssertionTool(this, 'text'),
|
'assertingText': new TextAssertionTool(this, 'text'),
|
||||||
'assertingVisibility': new InspectTool(this, true),
|
'assertingVisibility': new InspectTool(this, true),
|
||||||
|
|
@ -1292,8 +1303,8 @@ export class PollingRecorder implements RecorderDelegate {
|
||||||
private _embedder: Embedder;
|
private _embedder: Embedder;
|
||||||
private _pollRecorderModeTimer: NodeJS.Timeout | undefined;
|
private _pollRecorderModeTimer: NodeJS.Timeout | undefined;
|
||||||
|
|
||||||
constructor(injectedScript: InjectedScript) {
|
constructor(injectedScript: InjectedScript, performActions?: boolean) {
|
||||||
this._recorder = new Recorder(injectedScript);
|
this._recorder = new Recorder(injectedScript, performActions);
|
||||||
this._embedder = injectedScript.window as any;
|
this._embedder = injectedScript.window as any;
|
||||||
|
|
||||||
injectedScript.onGlobalListenersRemoved.add(() => this._recorder.installListeners());
|
injectedScript.onGlobalListenersRemoved.add(() => this._recorder.installListeners());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue