https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 4c581fe88602762273f350d08ccc7371bd1c2c62 authored by Jake Archibald on 10 April 2018, 07:01:54 UTC
Testing "attack 4" & refactoring
Tip revision: 4c581fe
idlharness.html
<!DOCTYPE html>
<html>
<head>
  <meta charset=utf-8>
  <title>Media Recorder IDL test</title>
  <link rel="help" href="https://w3c.github.io/mediacapture-record/MediaRecorder.html">
  <link rel="idl" href="https://w3c.github.io/mediacapture-record/MediaRecorder.html#idl-index">
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="/resources/WebIDLParser.js"></script>
  <script src="/resources/idlharness.js"></script>
</head>
<body>
  <canvas id='canvas' width=10 height=10/>

  <pre id="untested_idl" style="display: none">
    interface Event {};
    interface EventHandler {};
    interface EventTarget {};
    interface MediaStream {};
  </pre>
  <pre id="idl" style="display: none">
    // https://w3c.github.io/mediacapture-record/MediaRecorder.html

    [Constructor(MediaStream stream, optional MediaRecorderOptions options)]
    interface MediaRecorder : EventTarget {
      readonly attribute MediaStream stream;
      readonly attribute DOMString mimeType;
      readonly attribute RecordingState state;
      attribute EventHandler onstart;
      attribute EventHandler onstop;
      attribute EventHandler ondataavailable;
      attribute EventHandler onpause;
      attribute EventHandler onresume;
      attribute EventHandler onerror;
      readonly attribute unsigned long videoBitsPerSecond;
      readonly attribute unsigned long audioBitsPerSecond;

      void start(optional long timeslice);
      void stop();
      void pause();
      void resume();
      void requestData();

      static boolean isTypeSupported(DOMString type);
    };

    dictionary MediaRecorderOptions {
      DOMString mimeType;
      unsigned long audioBitsPerSecond;
      unsigned long videoBitsPerSecond;
      unsigned long bitsPerSecond;
    };

    enum RecordingState {
      "inactive",
      "recording",
      "paused"
    };

    [Constructor(DOMString type, BlobEventInit eventInitDict)]
    interface BlobEvent : Event {
      [SameObject] readonly attribute Blob data;
      readonly attribute DOMHighResTimeStamp timecode;
    };

    dictionary BlobEventInit {
      required Blob data;
      DOMHighResTimeStamp timecode;
    };

    dictionary MediaRecorderErrorEventInit : EventInit {
      required DOMException error;
    };

    [Exposed=Window, Constructor(DOMString type, MediaRecorderErrorEventInit eventInitDict)]
    interface MediaRecorderErrorEvent : Event {
      [SameObject] readonly attribute DOMException error;
    };

  </pre>
  <script>
    promise_test(async function() {
      const dom = await fetch('/interfaces/dom.idl').then(r => r.text());

      var canvas = document.getElementById('canvas');
      var context = canvas.getContext("2d");
      context.fillStyle = "red";
      context.fillRect(0, 0, 10, 10);
      var stream = canvas.captureStream();

      var idl_array = new IdlArray();
      idl_array.add_untested_idls(dom, { only: ['EventInit'] });
      idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
      idl_array.add_idls(document.getElementById("idl").textContent);
      idl_array.add_objects({
          MediaRecorder: [new MediaRecorder(stream)],
        });
      idl_array.test();
    }, 'mediacapture-record interfaces');
  </script>
  <div id="log"></div>
</body>
</html>
back to top