From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../narrate/test/browser_narrate_toggle.js | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'toolkit/components/narrate/test') diff --git a/toolkit/components/narrate/test/browser_narrate_toggle.js b/toolkit/components/narrate/test/browser_narrate_toggle.js index 54de276001..a7713f01b1 100644 --- a/toolkit/components/narrate/test/browser_narrate_toggle.js +++ b/toolkit/components/narrate/test/browser_narrate_toggle.js @@ -4,6 +4,8 @@ // This test verifies that the keyboard shortcut "n" will Start/Stop the // narration of an article in readermode when the article is in focus. +// This test also verifies that the keyboard shortcut "←" (left arrow) will +// skip the narration backward, while "→" (right arrow) skips it forward. registerCleanupFunction(teardown); @@ -11,18 +13,39 @@ add_task(async function testToggleNarrate() { setup(); await spawnInNewReaderTab(TEST_ARTICLE, async function () { + let TEST_VOICE = "urn:moz-tts:fake:teresa"; let $ = content.document.querySelector.bind(content.document); + let prefChanged = NarrateTestUtils.waitForPrefChange("narrate.voice"); + NarrateTestUtils.selectVoice(content, TEST_VOICE); + await prefChanged; + await NarrateTestUtils.waitForNarrateToggle(content); let eventUtils = NarrateTestUtils.getEventUtils(content); NarrateTestUtils.isStoppedState(content, ok); + let promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphstart"); $(NarrateTestUtils.TOGGLE).focus(); eventUtils.synthesizeKey("n", {}, content); + let speechinfo = (await promiseEvent).detail; + let paragraph = speechinfo.paragraph; + + NarrateTestUtils.isStartedState(content, ok); + + promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphstart"); + eventUtils.synthesizeKey("KEY_ArrowRight", {}, content); + speechinfo = (await promiseEvent).detail; + isnot(speechinfo.paragraph, paragraph, "next paragraph is being spoken"); + + NarrateTestUtils.isStartedState(content, ok); + + promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphstart"); + eventUtils.synthesizeKey("KEY_ArrowLeft", {}, content); + speechinfo = (await promiseEvent).detail; + is(speechinfo.paragraph, paragraph, "first paragraph being spoken"); - await ContentTaskUtils.waitForEvent(content, "paragraphstart"); NarrateTestUtils.isStartedState(content, ok); $(NarrateTestUtils.TOGGLE).focus(); -- cgit v1.2.3