feat(core): make execute_javascript honor AbortSignal
Expose the task AbortSignal as `signal` in the script scope so cooperative code can cancel promptly, and re-check signal.throwIfAborted() after the script settles to discard stale results. Closes #537.
This commit is contained in:
@@ -133,8 +133,10 @@ export class RemotePageController {
|
||||
return this.remoteCallDomAction('scroll_horizontally', args)
|
||||
}
|
||||
|
||||
async executeJavascript(...args: any[]): Promise<DomActionReturn> {
|
||||
return this.remoteCallDomAction('execute_javascript', args)
|
||||
async executeJavascript(script: string, _signal?: AbortSignal): Promise<DomActionReturn> {
|
||||
// `AbortSignal` is not structured-cloneable across the messaging boundary.
|
||||
// The remote script runs without it
|
||||
return this.remoteCallDomAction('execute_javascript', [script])
|
||||
}
|
||||
|
||||
/** @note Managed by content script via storage polling. */
|
||||
|
||||
Reference in New Issue
Block a user