Closed YuyaItagaki closed 1 year ago
Thank you for investigating this and for your detailed bug report. I will put up a commit to fix this.
I assume the button in the test page should trigger an alert call:
<button onclick="alert('test')">Button</button>
I tried pressing a button on a web page that shows an alert dialog in the scenario, but it didn't work and showed an error.
Version
memlab version: 1.1.41 Node.js version: 18.18.2
The current behavior
The scenario is interrupted and an error is displayed.
Error
The expected behavior
The error is not displayed and the scenario continues.
Steps To Reproduce
Install memlab with the command
npm install -g memlab
Create a page with an alert button (index.html).
Start the HTTP server with the command
npx http-server
.Run the scenario with the command
memlab run --scenario scenario.js
.Additional information
Workarounds
The error is worked around by resetting the definition of the dialog process and redefining
dialog.accept()
as follows.However, it should be noted that the info display will also be reset. Because all the contents defined at the three locations described in "Details of Assumed Problem Areas" below is reset.
Assumed Problem Areas
In the testInBrowser function ( https://github.com/facebook/memlab/blob/main/packages/api/src/API.ts#L422 ),
dialog.accept()
is defined twice anddialog.dismiss ()
once. As shown in the error messageCannot accept dialog which is already handled!
, the error is that the dialog cannot be controlled.Details
The three locations where dialog controls such as
dialog.accept()
anddialog.dismiss()
are defined are as follows.dialog.dismiss ()
dialog.accept()
dialog.accept()
The error described in "Error of The current behavior" above corresponds to
dialog.accept()
in the browserInfo.monitorWebConsole function at the third location.By commenting out two of three locations, it is confirmed that the dialog control becomes one, and the scenario continues without error.