Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Reusable variables/constants for tab.run() / tab.wait() #43

Open
@ghost

Description

At the moment any variables have to be explicitly passed during tab.run() and tab.wait(). However very often we would like to reuse the same value between multiple invocations of these methods.

We could do something simple as:

tabs.define({ // perhaps also tab.define()
    username: 'foo',
    password: 'bla',
    findAuthFields: async () => wait.selectorAll('input#username, input#password').amount(2),
})

await tab.run(async () => {
    await wait.documentComplete()
    const [usernameField, passwordField] = await findAuthFields()

    await interact.type(usernameField, [...username])
    await interact.type(passwordField, [...password])
})

If we restrict this so that:

  • define() only affects new invocations and not pending invocations
  • content scripts can not define()
  • serialization will occur immediately when define() is called

The implementation should be very simple, and the resulting API and its side-effects will be easy to understand for scripters.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions