chromium/chrome/test/data/extensions/declarative_net_request/subresources.html

<html>

<head>
  <script type="text/javascript">

  function testStylesheet() {
    var link = document.createElement('link');
    return new Promise(resolve => {
      link.addEventListener('load', () => {
        var cssLoaded = window.getComputedStyle(document.body)
          .getPropertyValue('background-color') == 'rgb(0, 0, 255)';
        resolve(cssLoaded);
      });
      link.addEventListener('error', () => {
        resolve(false);
      });

      link.rel = 'stylesheet';
      link.href = 'subresources/style.css';
      document.getElementsByTagName('head')[0].appendChild(link)
    });
  }

  function testScript() {
    // Fail if window.scriptExecuted is already set.
    if (window.scriptExecuted) {
      return false;
    }

    return new Promise(resolve => {
      var script = document.createElement('script');
      script.addEventListener('load', () => {
        resolve(window.scriptExecuted);
      });
      script.addEventListener('error', () => {
        resolve(false);
      });

      script.src = 'subresources/script.js';
      document.body.appendChild(script);
    });
  }

  function testImage() {
    var img = document.createElement('img');
    return new Promise(resolve => {
      img.addEventListener('load', () => {
        resolve(true);
      });
      img.addEventListener('error', () => {
        resolve(false);
      });

      img.src = 'subresources/image.png';
      document.body.appendChild(img);
    });
  }

  function testXHR() {
    var xhr = new XMLHttpRequest();
    xhr.responseType = 'text';
    return new Promise(resolve => {
      xhr.addEventListener('load', () => {
        var xhrLoaded = xhr.status == 200 && xhr.responseText == 'Hello World\n';
        resolve(xhrLoaded);
      });
      xhr.addEventListener('error', () => {
        resolve(false);
      });

      xhr.open('GET', 'subresources/xhr_target.txt');
      xhr.send();
    });
  }

  function testMedia() {
    var audio = document.createElement('audio');
    return new Promise(resolve => {
      audio.addEventListener('loadeddata', () => {
        resolve(true);
      });
      audio.addEventListener('error', () => {
        resolve(false);
      });

      audio.src = 'subresources/ping.mp3';
      document.body.appendChild(audio);
    });
  }

  function testWebSocket(url) {
    var ws = new WebSocket(url);
    var message = 'hello world';

    ws.onopen = () => {
      ws.send(message);
    }
    return new Promise(resolve => {
      ws.onmessage = (event) => {
        resolve(message == event.data);
      }
      ws.onerror = () => {
        resolve(false);
      }
    });
  }
  </script>
</head>

<body>
  <!-- Test subframe. -->
  <iframe src="subresources/subframe.html"></iframe>
</body>

</html>