DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 673 forks source link

Event still bubbles even if the event target was deleted #7277

Closed AlexKamaev closed 1 year ago

AlexKamaev commented 2 years ago

What is your Scenario?

see example

What is the Current behavior?

see example

What is the Expected behavior?

event should not bubble if the target was deleted

What is your public website URL? (or attach your complete example)

<!DOCTYPE html>
<html>
<head>
    <title>TestCafe Tests Container</title>

    <style>
        body {
            height: 400px;
            width: 400px;
            border: 1px solid black;
        }

        #container {
            display: inline-block;
            height: 200px;
            width: 200px;
            background-color: red;
        }
    </style>
</head>
<body>
<div id="container"></div>

<script>
    document.querySelector('#container').addEventListener('pointerdown', (e) => { e.target.parentNode.removeChild(e.target); });

    document.addEventListener('click', () => {
        window.bubbled = true;
    });
</script>
</body>
</html>

What is your TestCafe test code?

import { Selector, ClientFunction } from 'testcafe';

fixture `Test`
    .page('./index.html');

const container = Selector('#container');
const body = Selector('body');

const isBubbled = ClientFunction(() => {
   return window.bubbled;
});

test('Test', async (t) => {
    await t.click(container);

    await t.expect(isBubbled()).notOk();
});

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

see example

TestCafe version

2.0.0

Node.js version

does not matter

Command-line arguments

does not matter

Browser name(s) and version(s)

Chrome

Platform(s) and version(s)

Windows 10

Other

No response

AlexKamaev commented 1 year ago

Fun fact 1: if you remove the body styles everything will work as expected. Fun fact 2: it works in proxyless mode

miherlosev commented 1 year ago

This issue is not reproduced with combination of testcafe@3.0.1 and the Google Chrome browser. Feel free to reopen this issue if you encounter it in other browsers.