haikuwebkit/LayoutTests/fast/web-share/share-transient-activation-...

3 lines
182 B
Plaintext
Raw Permalink Normal View History

Using Web Share API preceded by an AJAX call https://bugs.webkit.org/show_bug.cgi?id=197779 <rdar://problem/50708309> Reviewed by Dean Jackson. Source/WebCore: As per the Web Share specification, navigator.share() is supposed to reject the promise with a "NotAllowedError" DOMException if the relevant global object of this does not have transient activation [1]. However, our implementation was stricter and would reject the promise if we are not currently processing a user-gesture. This behavior did not match Chrome and does not appear to be Web compatible. To address the issue, this patch introduces the concept of transient activation [2] in WebKit and uses it in navigator.share() to match the specification more closely. Note that we are still a bit stricter than the specification because calling navigator.share() will currently "consume the activation" [3] to prevent the JS from presenting the share sheet more than once based on a single activation. However, our new behavior is still more permissive and more aligned with Chrome. [1] https://w3c.github.io/web-share/#dom-navigator-share [2] https://html.spec.whatwg.org/multipage/interaction.html#transient-activation [3] https://html.spec.whatwg.org/multipage/interaction.html#consume-user-activation Tests: fast/web-share/share-transient-activation-expired.html fast/web-share/share-transient-activation.html * dom/UserGestureIndicator.cpp: * dom/UserGestureIndicator.h: (WebCore::UserGestureToken::startTime const): * page/DOMWindow.cpp: (WebCore::transientActivationDurationOverrideForTesting): (WebCore::transientActivationDuration): (WebCore::DOMWindow::origin const): (WebCore::DOMWindow::securityOrigin const): (WebCore::DOMWindow::overrideTransientActivationDurationForTesting): (WebCore::DOMWindow::hasTransientActivation const): (WebCore::DOMWindow::consumeTransientActivation): (WebCore::DOMWindow::notifyActivated): * page/DOMWindow.h: * page/Navigator.cpp: (WebCore::Navigator::share): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): (WebCore::Internals::setTransientActivationDuration): * testing/Internals.h: * testing/Internals.idl: LayoutTests: Add layout test coverage. * fast/web-share/share-transient-activation-expected.txt: Added. * fast/web-share/share-transient-activation-expired-expected.txt: Added. * fast/web-share/share-transient-activation-expired.html: Added. * fast/web-share/share-transient-activation.html: Added. Canonical link: https://commits.webkit.org/219037@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254178 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-08 01:07:25 +00:00
PASS: Share promise was rejected: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.