Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests failing for trusted-set-cookie #453

Closed
scripthunter7 opened this issue Sep 11, 2024 · 2 comments
Closed

Tests failing for trusted-set-cookie #453

scripthunter7 opened this issue Sep 11, 2024 · 2 comments
Assignees

Comments

@scripthunter7
Copy link
Member

After running tests, we need to open tests/dist/scriptlets-trusted-set-cookie.html directly, because old node-qunit-puppeteer doesn't detect the error

@scripthunter7 scripthunter7 added the bug Something isn't working label Sep 11, 2024
@scripthunter7
Copy link
Member Author

probably #448 caused by the same reason

@AdamWr
Copy link
Member

AdamWr commented Sep 11, 2024

I have also noticed recently that in Chrome Set cookie with expires in trusted-set-cookie tests failing, but when running yarn test command it's okay (I thought that it was always like that).

If I'm not wrong, it looks like that in Chrome, document.cookie is cached, maybe related to this - https://blog.chromium.org/2024/06/introducing-shared-memory-versioning-to.html
For example:

document.cookie = "q=w;";
document.cookie = "foo=bar; Max-Age=2";
setInterval(()=>{console.log(document.cookie)},1000);
setTimeout(()=>document.cookie='a=1',5000);

In Chrome foo cookie is logged until there is change in document.cookie (so in this case for 5 seconds) but in Firefox it's not logged immediately when it's removed.

Changing this part:

setTimeout(() => {
assert.strictEqual(document.cookie.includes(cName), false, 'Cookie name has been deleted');
assert.strictEqual(document.cookie.includes(cValue), false, 'Cookie value has been deleted');
clearCookie(cName);
done();
}, expiresSec * 1000);

to something like:

setTimeout(() => {
    // It looks like Chrome is caching document.cookie and value is not updated,
    // so as a workaround we remove dummy cookie to force update of document.cookie
    clearCookie('dummyCookie');
    assert.strictEqual(document.cookie.includes(cName), false, 'Cookie name has been deleted');
    assert.strictEqual(document.cookie.includes(cValue), false, 'Cookie value has been deleted');
    clearCookie(cName);
    done();
}, expiresSec * 1000);

should fixes it.

adguard pushed a commit that referenced this issue Sep 11, 2024
Merge in ADGUARD-FILTERS/scriptlets from fix/AG-35894 to fix/AG-35891

Squashed commit of the following:

commit e7e730f
Merge: 43546c1 98ed01b
Author: Maxim Topciu <mtopciu@adguard.com>
Date:   Wed Sep 11 15:59:15 2024 +0300

    Merge branch 'fix/AG-35891' into fix/AG-35894

commit 43546c1
Author: Dávid Tóta <d.tota@adguard.com>
Date:   Wed Sep 11 15:44:43 2024 +0300

    tests/scriptlets/trusted-set-cookie.test.js edited online with Bitbucket

commit 78e2215
Author: Dávid Tóta <d.tota@adguard.com>
Date:   Wed Sep 11 15:44:35 2024 +0300

    tests/scriptlets/trusted-set-cookie.test.js edited online with Bitbucket

commit 870e257
Merge: 83ca0fa d17a55b
Author: Adam Wróblewski <adam@adguard.com>
Date:   Wed Sep 11 14:42:33 2024 +0200

    Merge branch 'fix/AG-35891' into fix/AG-35894

commit 83ca0fa
Author: Adam Wróblewski <adam@adguard.com>
Date:   Wed Sep 11 14:25:33 2024 +0200

    Fix cookie with expires test
adguard pushed a commit that referenced this issue Sep 11, 2024
Merge in ADGUARD-FILTERS/scriptlets from fix/AG-35891 to master

Squashed commit of the following:

commit a9bdb98
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 15:07:45 2024 +0200

    fix nit

commit 9e6d950
Author: Adam Wróblewski <adam@adguard.com>
Date:   Wed Sep 11 16:03:51 2024 +0300

    AG-35894 Tests failing for trusted-set-cookie. #453

    Merge in ADGUARD-FILTERS/scriptlets from fix/AG-35894 to fix/AG-35891

    Squashed commit of the following:

    commit e7e730f
    Merge: 43546c1 98ed01b
    Author: Maxim Topciu <mtopciu@adguard.com>
    Date:   Wed Sep 11 15:59:15 2024 +0300

        Merge branch 'fix/AG-35891' into fix/AG-35894

    commit 43546c1
    Author: Dávid Tóta <d.tota@adguard.com>
    Date:   Wed Sep 11 15:44:43 2024 +0300

        tests/scriptlets/trusted-set-cookie.test.js edited online with Bitbucket

    commit 78e2215
    Author: Dávid Tóta <d.tota@adguard.com>
    Date:   Wed Sep 11 15:44:35 2024 +0300

        tests/scriptlets/trusted-set-cookie.test.js edited online with Bitbucket

    commit 870e257
    Merge: 83ca0fa d17a55b
    Author: Adam Wróblewski <adam@adguard.com>
    Date:   Wed Sep 11 14:42:33 2024 +0200

        Merge branch 'fix/AG-35891' into fix/AG-35894

    commit 83ca0fa
    Author: Adam Wróblewski <adam@adguard.com>
    Date:   Wed Sep 11 14:25:33 2024 +0200

        Fix cookie with expires test

commit 98ed01b
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 14:50:52 2024 +0200

    update gh workflows

commit d17a55b
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 14:31:24 2024 +0200

    accept jsdoc defaults in eslint

commit 6660562
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 14:19:03 2024 +0200

    fix eslint warnings

commit 73242c9
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 14:18:44 2024 +0200

    disable tests temporarily

commit eb39027
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 12:39:53 2024 +0200

    fix install for node 20

commit 0213b99
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 12:34:17 2024 +0200

    test

commit 0173470
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 12:33:43 2024 +0200

    test

commit a18a90a
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 12:27:43 2024 +0200

    update puppeteer

commit c672bfa
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 12:09:32 2024 +0200

    update packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants