Skip to content

Clarifying behavior of multiple simultaneous shares #110

@marcoscaceres

Description

@marcoscaceres

We probably want to clarify what happens when multiple concurrent shares are triggered by user activation. Consider:

var b = document.createElement("button");
document.body.appendChild(b);
b.innerHTML = "hello!";
b.onclick = () => {
    var  p1 =  navigator.share({text: "i am 1", title: "i am 1"});
    var  p2 =  navigator.share({text: "i am 2", title: "i am 2"});
    p1.then(()=>console.log("1 resolved")).catch(err =>  console.error(1, err));
    p2.then(()=>console.log("2 resolved")).catch(err =>  console.error(2, err));
}

Should p1 win and p2 automatically gets rejected with an AbortError? or should p1 get rejected, and p2 wins?

Safari currently shares p1, but rejects both with AbortErrors (even though the share is successful). That seems like a bug.

In any case, seems like if p1 should win and trying to make subsequent calls to share() should reject with an InvalidStateError (i.e., only allow one share at a time per document).

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