summaryrefslogtreecommitdiffstats
path: root/toolkit/components/pictureinpicture/tests/browser_nimbusShowIconOnly.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /toolkit/components/pictureinpicture/tests/browser_nimbusShowIconOnly.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/pictureinpicture/tests/browser_nimbusShowIconOnly.js')
-rw-r--r--toolkit/components/pictureinpicture/tests/browser_nimbusShowIconOnly.js114
1 files changed, 114 insertions, 0 deletions
diff --git a/toolkit/components/pictureinpicture/tests/browser_nimbusShowIconOnly.js b/toolkit/components/pictureinpicture/tests/browser_nimbusShowIconOnly.js
new file mode 100644
index 0000000000..7c6dcea01b
--- /dev/null
+++ b/toolkit/components/pictureinpicture/tests/browser_nimbusShowIconOnly.js
@@ -0,0 +1,114 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const { ExperimentFakes } = ChromeUtils.importESModule(
+ "resource://testing-common/NimbusTestUtils.sys.mjs"
+);
+
+const PIP_EXPERIMENT_MESSAGE = "Hello world message";
+const PIP_EXPERIMENT_TITLE = "Hello world title";
+
+/**
+ * This tests that the original DTD string is shown for the PiP toggle
+ */
+add_task(async function test_experiment_control() {
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url: TEST_PAGE,
+ },
+ async browser => {
+ const l10n = new Localization(
+ ["branding/brand.ftl", "toolkit/global/videocontrols.ftl"],
+ true
+ );
+
+ let pipExplainerMessage = l10n.formatValueSync(
+ "videocontrols-picture-in-picture-explainer3"
+ );
+
+ await SimpleTest.promiseFocus(browser);
+ await ensureVideosReady(browser);
+
+ const PIP_PREF =
+ "media.videocontrols.picture-in-picture.video-toggle.has-used";
+ await SpecialPowers.pushPrefEnv({
+ set: [[PIP_PREF, false]],
+ });
+
+ let videoID = "with-controls";
+ await hoverToggle(browser, videoID);
+
+ await SpecialPowers.spawn(
+ browser,
+ [pipExplainerMessage],
+ async function (pipExplainerMessage) {
+ let video = content.document.getElementById("with-controls");
+ let shadowRoot = video.openOrClosedShadowRoot;
+ let pipButton = shadowRoot.querySelector(".pip-explainer");
+
+ Assert.equal(
+ pipButton.textContent.trim(),
+ pipExplainerMessage,
+ "The PiP explainer is default"
+ );
+ }
+ );
+ }
+ );
+});
+
+/**
+ * This tests that the experiment is showing the icon only
+ */
+add_task(async function test_experiment_iconOnly() {
+ let experimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
+ featureId: "pictureinpicture",
+ value: {
+ showIconOnly: true,
+ },
+ });
+
+ registerCleanupFunction(async function () {
+ await experimentCleanup();
+ });
+
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url: TEST_PAGE,
+ },
+ async browser => {
+ await SimpleTest.promiseFocus(browser);
+ await ensureVideosReady(browser);
+
+ const PIP_PREF =
+ "media.videocontrols.picture-in-picture.video-toggle.has-used";
+ await SpecialPowers.pushPrefEnv({
+ set: [[PIP_PREF, false]],
+ });
+
+ let videoID = "with-controls";
+ await hoverToggle(browser, videoID);
+
+ await SpecialPowers.spawn(browser, [], async function () {
+ let video = content.document.getElementById("with-controls");
+ let shadowRoot = video.openOrClosedShadowRoot;
+ let pipExpanded = shadowRoot.querySelector(".pip-expanded");
+ let pipIcon = shadowRoot.querySelector("div.pip-icon");
+
+ Assert.ok(
+ ContentTaskUtils.isHidden(pipExpanded),
+ "The PiP explainer hidden by the experiment"
+ );
+
+ Assert.ok(
+ ContentTaskUtils.isVisible(pipIcon),
+ "The PiP icon is visible by the experiment"
+ );
+ });
+ }
+ );
+});