diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/webshare | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/webshare')
-rw-r--r-- | dom/webshare/moz.build | 10 | ||||
-rw-r--r-- | dom/webshare/test/mochitest/mochitest.ini | 6 | ||||
-rw-r--r-- | dom/webshare/test/mochitest/test_navigator_share_consume_user_activation.html | 43 |
3 files changed, 59 insertions, 0 deletions
diff --git a/dom/webshare/moz.build b/dom/webshare/moz.build new file mode 100644 index 0000000000..efb701c0f7 --- /dev/null +++ b/dom/webshare/moz.build @@ -0,0 +1,10 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +with Files("**"): + BUG_COMPONENT = ("Core", "DOM: Core & HTML") + +MOCHITEST_MANIFESTS += ["test/mochitest/mochitest.ini"] diff --git a/dom/webshare/test/mochitest/mochitest.ini b/dom/webshare/test/mochitest/mochitest.ini new file mode 100644 index 0000000000..b01bc8d36e --- /dev/null +++ b/dom/webshare/test/mochitest/mochitest.ini @@ -0,0 +1,6 @@ +[DEFAULT] +prefs = + dom.webshare.enabled=true +scheme = https +skip-if = os == 'win' # https://bugzilla.mozilla.org/show_bug.cgi?id=1641280 +[test_navigator_share_consume_user_activation.html] diff --git a/dom/webshare/test/mochitest/test_navigator_share_consume_user_activation.html b/dom/webshare/test/mochitest/test_navigator_share_consume_user_activation.html new file mode 100644 index 0000000000..9cb3f04d96 --- /dev/null +++ b/dom/webshare/test/mochitest/test_navigator_share_consume_user_activation.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<title>Web Share: consume transient activation</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css" /> +<body> + <button id="share">Share</button> +</body> +<script> + // TODO: add a task that tests share() consume the transient user activation. + // Because OS-level prompt can't be cancelled, it's currently not possible to + // test this. We need to add a Web share Mocking service: + // https://bugzilla.mozilla.org/show_bug.cgi?id=1646229 + + // test that share() would be blocked with an already-consumed-activation. + add_task(async function blockedIfAlreadyConsumed() { + const wrappedDoc = SpecialPowers.wrap(document); + const button = document.getElementById("share"); + + // Kick off transient activation + synthesizeMouseAtCenter(button, {}); + + ok( + wrappedDoc.hasValidTransientUserGestureActivation, + "Activated by a gesture" + ); + + wrappedDoc.consumeTransientUserGestureActivation(); + + try { + const sharePromise = navigator.share({ title: "test" }); + await sharePromise; + ok(false, "must throw because activation was already consumed"); + } catch (err) { + is(err.name, "NotAllowedError", "Expected NotAllowedError DOMException"); + } finally { + ok( + !wrappedDoc.hasValidTransientUserGestureActivation, + "share() must consume the activation" + ); + } + }); +</script> |