fix(codegen): do not forget to reset currentAction in didPerformAction (#5194)

This commit is contained in:
Dmitry Gozman 2021-01-27 17:05:56 -08:00 committed by GitHub
parent e50f11c5b1
commit 2793d14409
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -93,8 +93,10 @@ export class CodeGenerator {
eraseLastAction = true;
}
if (lastAction && action.name === 'navigate' && lastAction.name === 'navigate') {
if (action.url === lastAction.url)
if (action.url === lastAction.url) {
this._currentAction = undefined;
return;
}
}
for (const name of ['check', 'uncheck']) {
if (lastAction && action.name === name && lastAction.name === 'click') {

View file

@ -638,4 +638,22 @@ describe('cli codegen', (test, { browserName, headful }) => {
url: '${otherFrame.url()}'
}).click('text="Hi, I\\'m frame"');`);
});
it('should record navigations after identical pushState', async ({ page, recorder, httpServer }) => {
httpServer.setHandler((req: http.IncomingMessage, res: http.ServerResponse) => {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end('Hello world');
});
await recorder.setContentAndWait(`
<script>
function pushState() {
history.pushState({}, 'title', '${httpServer.PREFIX}');
}
</script>`, httpServer.PREFIX);
for (let i = 1; i < 3; ++i)
await page.evaluate('pushState()');
await page.goto(httpServer.PREFIX + '/page2.html');
await recorder.waitForOutput(`await page.goto('${httpServer.PREFIX}/page2.html');`);
});
});