Skip to content

AppDriver$wait_for_js() does not quote script input #236

Closed

Description

@fproske

The eval() call in the chromote_wait_for_condition function is essentially a NOP instruction as the condition_js script is not quoted:

return eval(", condition_js, ");

This leads to e.g. the input script 'test'==='test'; throwing a Javascript error: SyntaxError: Unexpected token ';'. Expected ')' to end an argument list. as the code to be executed looks like this: eval('test'==='test';) which is obviously invalid syntax.
To fix this, the condition_js needs to be quoted properly.

Activity

  1. added
    bug
    on Aug 18, 2022
  2. added this to the v0.2.0 milestone on Aug 18, 2022
  3. yogat3ch commented on Nov 29, 2022

    @yogat3ch

    Hi @schloerke,
    opening this back up because I found a bug where an object of class glue, character passed as the condition_js argument to wait_for_js will produce an error.

    app$wait_for_js(UU::glue_js("$('#*{ns('highlighted')}* table.dataTable > tbody > tr').length == 1;"))

    produces an error:
    image

    I think this can be resolved by simply wrapping condition_js on the line mentioned above in as.character as the following works:

    app$wait_for_js(as.character(UU::glue_js("$('#*{ns('highlighted')}* table.dataTable > tbody > tr').length == 1;")))

  4. schloerke commented on Nov 29, 2022

    @schloerke
    Collaborator

    {glue} is so weird. lol.

    Thank you for the fix!

  5. added a commit that references this issue on Nov 29, 2022
  6. schloerke commented on Nov 29, 2022

    @schloerke
    Collaborator

    @yogat3ch Hopefully fixed in #288

  7. yogat3ch commented on Nov 29, 2022

    @yogat3ch

    @schloerke Very much appreciated!!! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions