tor-browser

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

update-media.html (948B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>img update media</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7    var t = async_test('set media after src updates selected image');
      8 
      9    var img;
     10 
     11    onload = t.step_func(function() {
     12        img = document.querySelector('img');
     13        img.addEventListener('load', t.step_func_done(onImgLoad));
     14 
     15        var source = document.querySelector('source[data-media]');
     16        source.setAttribute('media', source.getAttribute('data-media'));
     17    });
     18 
     19    function onImgLoad() {
     20        img.removeEventListener('load', onImgLoad);
     21 
     22        assert_true(img.currentSrc.indexOf(img.getAttribute('data-expect')) > -1);
     23    }
     24 
     25 </script>
     26 
     27 <div id="log"></div>
     28 <picture>
     29    <source srcset="/images/fail.gif" data-media="(max-width: 1px)" />
     30    <source srcset="/images/smiley.png" />
     31    <img data-expect="/images/smiley.png">
     32 </picture>