Skip to content

Infinite looping on Cookie Store API with event listener #246

@RupinMittal

Description

@RupinMittal

Consider this code:

function runLoopingCase() {
cookieStore.onchange = (event) => {
printChangeEvent('Cookie got changed\n');
document.cookie="a=b";
};
document.cookie="a=b";
}

The spec says that any time a cookie is set, we should fire an event. This would mean that the above code will loop infinitely.

And indeed, on Chrome and Safari it does. A fix for this would be: "Do not fire the change event if the cookie being set is identical to an already-existing cookie". This makes logical sense and is how Mozilla fixed the issue: https://phabricator.services.mozilla.com/D217573.

Can we modify the spec to enforce that events are not fired when an identical cookie is set?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions