Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate risk of panic on parse of remote object during console.log #1129

Merged
merged 14 commits into from
Dec 15, 2023

Commits on Dec 11, 2023

  1. Add parse console values

    These new functions are to be used when parsing the console message
    which is being printed by the website under test when it used
    console.log. Since these are string values that will be parsed and
    reprinted to stdout, we don't necessarily need to parse a json string
    into a go object (which is the main motivation for this change). This
    will avoid situations where k6 browser panics and causes the test run
    to end due to not being able to parse a json string.
    
    Other areas of the implementation (e.g. toJSON or eval) still require
    a go representation of the object and they will work with the existing
    parse functions.
    ankur22 committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    a597741 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    393eccd View commit details
    Browse the repository at this point in the history
  3. Add a new log formatter

    Since a string is already a string, we don't need to marshal it back to
    a string. This will be used when working with console messages which
    are printed by the website under test.
    ankur22 committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    a877ade View commit details
    Browse the repository at this point in the history
  4. Refactor frameSession onConsoleAPICalled

    Work with parseConsoleRemoteObject so that the browser module avoids
    trying to unmarshal objects from json to a go object. This doesn't feel
    like a worthwhile operation since the string will be printed to stdout.
    ankur22 committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    5a8e0ab View commit details
    Browse the repository at this point in the history
  5. Refactor page's onConsoleAPICalled

    Work with parseConsoleRemoteObject and strings rather than any types.
    The page.on API works with strings so there's no need to try to parse
    a json object to a go object and then back to a js object.
    ankur22 committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    456b277 View commit details
    Browse the repository at this point in the history
  6. Remove unused function

    ankur22 committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    b8d899e View commit details
    Browse the repository at this point in the history
  7. Add clarifying comment

    ankur22 committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    51f987a View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2b028d3 View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2023

  1. Apply suggestions from code review

    Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com>
    ankur22 and inancgumus authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    48833c8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ac18621 View commit details
    Browse the repository at this point in the history
  3. Update log from warn to info

    This log is notifying the user of something that can't be changed or
    actioned on, so it's better represented as info rather than a warn.
    ankur22 committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    a13e10d View commit details
    Browse the repository at this point in the history

Commits on Dec 14, 2023

  1. Update comment on parseConsoleRemoteObjectValue

    This is just to clarify why these empty cases are there.
    ankur22 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    0139348 View commit details
    Browse the repository at this point in the history
  2. Remove objects formatter

    It's no longer being used.
    ankur22 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    167d447 View commit details
    Browse the repository at this point in the history
  3. Refactor page.on test

    This particular test may run slower on other machines, so accounting
    for that scenario -- specifically in the CI.
    ankur22 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    1a76aec View commit details
    Browse the repository at this point in the history