diff --git a/browser/mapping.go b/browser/mapping.go index 77d539c61..cb89ce69d 100644 --- a/browser/mapping.go +++ b/browser/mapping.go @@ -697,15 +697,6 @@ func mapBrowser(vu moduleVU, wsURL string, isRemoteBrowser bool) mapping { //nol } return b.IsConnected(), nil }, - "on": func(event string) *goja.Promise { - return k6ext.Promise(vu.Context(), func() (result any, reason error) { - b, err := getOrInitBrowser(ctx, bt, vu, wsURL, isRemoteBrowser) - if err != nil { - return nil, err - } - return b.On(event) //nolint:wrapcheck - }) - }, "newContext": func(opts goja.Value) (*goja.Object, error) { b, err := getOrInitBrowser(ctx, bt, vu, wsURL, isRemoteBrowser) if err != nil { diff --git a/browser/mapping_test.go b/browser/mapping_test.go index 7e9bd63d6..5294bca5e 100644 --- a/browser/mapping_test.go +++ b/browser/mapping_test.go @@ -40,6 +40,10 @@ func customMappings() map[string]string { "Frame.loaderID": "", "JSHandle.objectID": "", "Browser.close": "", + // TODO: browser.on method is unexposed until more event + // types other than 'disconnect' are supported. + // See: https://github.com/grafana/xk6-browser/issues/913 + "Browser.on": "", } } diff --git a/examples/browser_on.js b/examples/browser_on.js deleted file mode 100644 index 0ef37839c..000000000 --- a/examples/browser_on.js +++ /dev/null @@ -1,54 +0,0 @@ -import { check } from 'k6'; -import { browser } from 'k6/x/browser'; - -export const options = { - scenarios: { - ui: { - executor: 'shared-iterations', - options: { - browser: { - type: 'chromium', - }, - }, - }, - }, - thresholds: { - checks: ["rate==1.0"] - } -} - -export default function() { - check(browser, { - 'should be connected after launch': browser.isConnected(), - }); - - // TODO: Reset test after browser.on for 'disconnect' issue is - // fixed due to browser lifecycle modifications - - // const handlerCalled = Symbol(); - - // let p = browser.on('disconnected') - // // The promise resolve/success handler - // .then((val) => { - // check(browser, { - // 'should be disconnected on event': !browser.isConnected(), - // }); - // return handlerCalled; - // // The promise reject/failure handler - // }, (val) => { - // console.error(`promise rejected: ${val}`); - // }); - - // p.then((val) => { - // check(val, { - // 'the browser.on success handler should be called': val === handlerCalled, - // }); - // }); - - // check(browser, { - // 'should be connected before ending iteration': browser.isConnected(), - // }); - - // // Disconnect from the browser instance. - // browser.close(); -}