tor-browser

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

muted.html (4653B)


      1 <!doctype html>
      2 <title>muted</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/media.js"></script>
      6 <style>video { display: none; }</style>
      7 <div id=log></div>
      8 
      9 <script>
     10 function test_setting(e, muted, hasAttribute) {
     11  assert_equals(e.muted, muted);
     12  assert_equals(e.hasAttribute('muted'), hasAttribute);
     13 
     14  e.muted = !e.muted;
     15  assert_equals(e.muted, !muted);
     16  assert_equals(e.hasAttribute('muted'), hasAttribute);
     17 
     18  e.muted = !e.muted;
     19  assert_equals(e.muted, muted);
     20  assert_equals(e.hasAttribute('muted'), hasAttribute);
     21 }
     22 </script>
     23 
     24 <!-- These tests are inside <audio>/<video> so that the steps for updating the
     25     muted IDL attribute cannot be delayed until the end tag is parsed. -->
     26 
     27 <audio id=a1>
     28 <script>
     29 var a1 = document.getElementById('a1');
     30 
     31 test(function() {
     32  assert_false(a1.muted);
     33 }, 'getting audio.muted (parser-created)');
     34 
     35 test(function() {
     36  test_setting(a1, false, false);
     37 }, 'setting audio.muted (parser-created)');
     38 </script>
     39 </audio>
     40 
     41 <audio id=a2 muted>
     42 <script>
     43 var a2 = document.getElementById('a2');
     44 
     45 test(function() {
     46  assert_true(a2.muted);
     47 }, 'getting audio.muted with muted="" (parser-created)');
     48 
     49 test(function() {
     50  test_setting(a2, true, true);
     51 }, 'setting audio.muted with muted="" (parser-created)');
     52 </script>
     53 </audio>
     54 
     55 <video id=v1>
     56 <script>
     57 var v1 = document.getElementById('v1');
     58 
     59 test(function() {
     60  assert_false(v1.muted);
     61 }, 'getting video.muted (parser-created)');
     62 
     63 test(function() {
     64  test_setting(v1, false, false);
     65 }, 'setting video.muted (parser-created)');
     66 </script>
     67 </video>
     68 
     69 <video id=v2 muted>
     70 <script>
     71 var v2 = document.getElementById('v2');
     72 
     73 test(function() {
     74  assert_true(v2.muted);
     75 }, 'getting video.muted with muted="" (parser-created)');
     76 
     77 test(function() {
     78  test_setting(v2, true, true);
     79 }, 'setting video.muted with muted="" (parser-created)');
     80 </script>
     81 </video>
     82 
     83 <!-- Negative test to ensure that the load algorithm does not update the
     84     muted IDL attribute to match the content attribute. -->
     85 
     86 <video id=v3 muted></video>
     87 <script>
     88 async_test(function(t) {
     89  var v = document.getElementById('v3');
     90  assert_true(v.muted);
     91  v.muted = false;
     92  v.src = 'data:,'; // invokes load()
     93  v.addEventListener('error', t.step_func(function() {
     94    assert_false(v.muted);
     95    t.done();
     96  }));
     97 }, 'getting video.muted with muted="" after load (parser-created)');
     98 </script>
     99 
    100 <script>
    101 ['audio', 'video'].forEach(function(tagName) {
    102  test(function() {
    103    var m = document.createElement(tagName);
    104    assert_false(m.muted);
    105  }, 'getting ' + tagName + '.muted (script-created)');
    106 
    107  test(function() {
    108    var m = document.createElement(tagName);
    109    test_setting(m, false, false);
    110  }, 'setting ' + tagName + '.muted (script-created)');
    111 
    112  test(function() {
    113    var m = document.createElement(tagName);
    114    m.setAttribute('muted', '');
    115    assert_false(m.muted);
    116  }, 'getting ' + tagName + '.muted with muted="" (script-created)');
    117 
    118  test(function() {
    119    var m = document.createElement(tagName);
    120    m.setAttribute('muted', '');
    121    test_setting(m, false, true);
    122  }, 'setting ' + tagName + '.muted with muted="" (script-created)');
    123 
    124  // Spec bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=25153
    125  /*
    126  test(function() {
    127    var m = document.createElement(tagName);
    128    m.setAttribute('muted', '');
    129    m = m.cloneNode(false);
    130    assert_true(m.hasAttribute('muted'));
    131    assert_false(m.muted);
    132  }, 'getting ' + tagName + '.muted with muted="" (cloneNode-created)');
    133  */
    134 
    135  test(function() {
    136    var div = document.createElement('div');
    137    div.innerHTML = '<' + tagName + ' muted>';
    138    m = div.firstChild;
    139    assert_true(m.hasAttribute('muted'));
    140    assert_true(m.muted);
    141  }, 'getting ' + tagName + '.muted with muted="" (innerHTML-created)');
    142 
    143  test(function() {
    144    var id = tagName;
    145    assert_equals(document.getElementById(id), null);
    146    document.write('<' + tagName + ' id=' + id + ' muted>');
    147    m = document.getElementById(id);
    148    assert_true(m.hasAttribute('muted'));
    149    assert_true(m.muted);
    150  }, 'getting ' + tagName + '.muted with muted="" (document.write-created)');
    151 
    152  test(function() {
    153    var m = document.createElement(tagName);
    154    m.setAttribute('muted', '');
    155 
    156    var c = m.cloneNode(true);
    157    assert_true(c.muted);
    158  }, 'cloning ' + tagName + ' propagates muted (script-created)');
    159 
    160  test(function() {
    161    var div = document.createElement('div');
    162    div.innerHTML = '<' + tagName + ' muted>';
    163    m = div.firstChild;
    164 
    165    var c = m.cloneNode(true);
    166    assert_true(c.muted);
    167  }, 'cloning ' + tagName + ' propagates muted (innerHTML-created)');
    168 });
    169 </script>