grafana / xk6-browser

k6 extension that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol
https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/
GNU Affero General Public License v3.0
337 stars 42 forks source link

Move `launch` and `connect` options parsing to mapping layer #805

Open ka3de opened 1 year ago

ka3de commented 1 year ago

During the work done in #800, there was a proposal for optimization for the browser options parsing, now that this has to be done for both BrowserType.launch and BrowserType.connect methods.

This proposal also references the "global effort" in order to isolate as much as possible any Goja runtime reference and move it to the mapping layer.

Related: https://github.com/grafana/xk6-browser/issues/271.

ka3de commented 1 year ago

I've been experimenting with this a little bit.

If we want to remove references to Goja in our "core implementation", we should define an abstraction for browser [launch] options. And set this as the input for BrowserType.Launch and BrowserType.Connect methods. This abstraction should aim to be compatible with other browsers, not just Chromium.

Then we can transform the goja.Value object received from JS API into this new browser options type/abstraction in the connect and launch handlers in the mapping layer before calling the actual BrowserType method.