tor-browser

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

GUM-empty-option-param.https.html (1224B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <title>getUserMedia({}) rejects with TypeError</title>
      5 <link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/>
      6 <link rel="help" href="https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia">
      7 </head>
      8 <body>
      9 <h1 class="instructions">Description</h1>
     10 <p class="instructions">This test checks that getUserMedia with no value in the
     11 options parameter raises a TypeError exception.</p>
     12 
     13 <div id='log'></div>
     14 <script src=/resources/testharness.js></script>
     15 <script src=/resources/testharnessreport.js></script>
     16 <script>
     17 promise_test(async () => {
     18  try {
     19    // Race a settled promise to check that the returned promise is already
     20    // rejected.
     21    await Promise.race([navigator.mediaDevices.getUserMedia({}),
     22                       Promise.resolve()]);
     23  } catch (error) {
     24    assert_throws_js(TypeError, () => { throw error });
     25    assert_false('constraintName' in error,
     26                 "constraintName attribute not set as expected");
     27    return;
     28  }
     29  assert_unreached("should have returned an already-rejected promise.");
     30 }, "Tests that getUserMedia is rejected with a TypeError when used with an empty options parameter");
     31 
     32 </script>
     33 </body>
     34 </html>