tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_media.js (2698B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /* import-globals-from ../../mochitest/role.js */
      7 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
      8 
      9 /**
     10 * Test the accessibility tree for video elements with captions.
     11 */
     12 addAccessibleTask(
     13  `
     14 <video id="video" controls>
     15 </video>
     16  `,
     17  async function testVideoCaptions(browser, docAcc) {
     18    const videoAcc = findAccessibleChildByID(docAcc, "video");
     19    let ready = waitForEvent(
     20      EVENT_SHOW,
     21      evt => evt.accessible.name == "test caption"
     22    );
     23    await invokeContentTask(browser, [], () => {
     24      const video = content.document.getElementById("video");
     25      video.src =
     26        "https://example.com/tests/dom/media/test/shorter_audio_than_video_3s.webm";
     27      const track = video.addTextTrack("captions");
     28      track.mode = "showing";
     29      track.addCue(new content.VTTCue(0, 3, "test caption"));
     30      video.currentTime = 1;
     31    });
     32    await ready;
     33    testAccessibleTree(videoAcc, {
     34      role: ROLE_GROUPING,
     35      interfaces: [nsIAccessibleHyperText],
     36      children: [
     37        {
     38          // start/stop button
     39          role: ROLE_PUSHBUTTON,
     40          name: "Play",
     41          children: [],
     42        },
     43        {
     44          // buffer bar
     45          role: ROLE_STATUSBAR,
     46          children: [
     47            {
     48              role: ROLE_TEXT_LEAF,
     49              name: "Loading:",
     50            },
     51            {
     52              role: ROLE_TEXT_LEAF,
     53              name: " ",
     54            },
     55            {
     56              role: ROLE_TEXT_LEAF,
     57              // The name is the percentage buffered; e.g. "0%", "100%".
     58              // We can't check it here because it might be different
     59              // depending on browser caching.
     60            },
     61          ],
     62        },
     63        {
     64          // slider of progress bar
     65          role: ROLE_SLIDER,
     66          name: "Position",
     67          value: "0:01 / 0:03",
     68          children: [],
     69        },
     70        {
     71          // mute button
     72          role: ROLE_PUSHBUTTON,
     73          name: "Mute",
     74          children: [],
     75        },
     76        {
     77          // slider of volume bar
     78          role: ROLE_SLIDER,
     79          children: [],
     80          name: "Volume",
     81        },
     82        {
     83          role: ROLE_PUSHBUTTON,
     84          name: "Closed Captions",
     85          children: [],
     86        },
     87        {
     88          role: ROLE_PUSHBUTTON,
     89          name: "Full Screen",
     90          children: [],
     91        },
     92        {
     93          // Poster image
     94          role: ROLE_GRAPHIC,
     95          children: [],
     96        },
     97        {
     98          // Caption
     99          role: ROLE_TEXT_LEAF,
    100          name: "test caption",
    101        },
    102      ],
    103    });
    104  }
    105 );