Commit 38d06eb5 authored by Evan Liu's avatar Evan Liu Committed by aborovova@mozilla.com
Browse files

Bug 1965940 [wpt PR 52481] - Fix SpeechRecognition-installOnDevice.https.html WPT,

Automatic update from web-platform-tests
Fix SpeechRecognition-installOnDevice.https.html WPT

This CL fixes the SpeechRecognition-installOnDevice.https.html WPT.
On-device speech recognition in Chromium is not available on Windows
ARM64 devices and some of the test cases should only be run if on-device
speech recognition is available.

Bug: 40286514,407404837
Change-Id: I92ea6d8c6adef81fdda1fc8eceec08036cd21b4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6532288


Commit-Queue: Evan Liu <evliu@google.com>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1459089}

--

wpt-commits: 95df31ed7b5940c55cd916c5fa672cc89c55763b
wpt-pr: 52481

Differential Revision: https://phabricator.services.mozilla.com/D250135
parent 0dde0f99
Loading
Loading
Loading
Loading
+85 −70
Original line number Original line Diff line number Diff line
@@ -8,23 +8,36 @@
promise_test(async (t) => {
promise_test(async (t) => {
  const validLang = "en-US";
  const validLang = "en-US";
  const invalidLang = "invalid language code";
  const invalidLang = "invalid language code";
  const validDownloadableLang = "fr-FR";
  window.SpeechRecognition =
  window.SpeechRecognition =
    window.SpeechRecognition || window.webkitSpeechRecognition;
    window.SpeechRecognition || window.webkitSpeechRecognition;


  // Check the availablility of the on-device language pack.
  const initialAvailabilityPromise =
    SpeechRecognition.availableOnDevice(validLang);
  assert_true(
    initialAvailabilityPromise instanceof Promise,
    "availableOnDevice should return a Promise."
  );

  const initialAvailabilityResult = await initialAvailabilityPromise;
  assert_true(
    typeof initialAvailabilityResult === "string",
    "The resolved value of the availableOnDevice promise should be a string."
  );

  if (initialAvailabilityResult === "downloadable") {
    // Attempt to call installOnDevice directly, without a user gesture with a
    // Attempt to call installOnDevice directly, without a user gesture with a
    // language that is downloadable but not installed.
    // language that is downloadable but not installed.
    const installWithoutUserGesturePromise =
    const installWithoutUserGesturePromise =
    SpeechRecognition.installOnDevice(validDownloadableLang);
      SpeechRecognition.installOnDevice(validLang);


    // Assert that the promise rejects with NotAllowedError.
    // Assert that the promise rejects with NotAllowedError.
    await promise_rejects_dom(
    await promise_rejects_dom(
      t,
      t,
      "NotAllowedError",
      "NotAllowedError",
      window.DOMException,
      window.DOMException,
    installWithoutUserGesturePromise,
      installWithoutUserGesturePromise, "SpeechRecognition.installOnDevice() " +
    "SpeechRecognition.installOnDevice() must reject with NotAllowedError if " +
      "must reject with NotAllowedError if called without a user gesture."
      "called without a user gesture."
    );
    );


    // Test that it returns a promise when called with a valid language.
    // Test that it returns a promise when called with a valid language.
@@ -68,7 +81,8 @@ promise_test(async (t) => {


    assert_true(
    assert_true(
      availableOnDeviceResult === "available",
      availableOnDeviceResult === "available",
    "The resolved value of the availableOnDevice promise should be 'available'."
      "The resolved value of the availableOnDevice promise should be " +
      "'available'."
    );
    );


    // Verify that installing an already installed language resolves to true.
    // Verify that installing an already installed language resolves to true.
@@ -93,6 +107,7 @@ promise_test(async (t) => {
      "installOnDevice should resolve with `true` if the language is already " +
      "installOnDevice should resolve with `true` if the language is already " +
      "installed."
      "installed."
    );
    );
  }


  // Test that it returns a promise and resolves to false for unsupported lang.
  // Test that it returns a promise and resolves to false for unsupported lang.
  const invalidResultPromise = test_driver.bless(
  const invalidResultPromise = test_driver.bless(