chromium/third_party/blink/web_tests/fast/peerconnection/RTCPeerConnection-createOffer-promise.html

<!DOCTYPE html>
<html>
  <head>
    <title>RTCPeerConnection.createOffer</title>
    <script src="../../resources/testharness.js"></script>
    <script src="../../resources/testharnessreport.js"></script>
  </head>
  <body>
    <script>
      pc = new RTCPeerConnection();

      // Test some combinations of parameters to createOffer.
      promise_test(function() {
        return pc.createOffer({voiceActivityDetection:true, iceRestart:true, offerToReceiveAudio:1, offerToReceiveVideo:1})
      }, 'createOffer({voiceActivityDetection:true, iceRestart:true})');

      promise_test(function() {
        return pc.createOffer({iceRestart:true, offerToReceiveAudio:1, offerToReceiveVideo:1})
      }, 'createOffer({iceRestart:true})');

      // Test type error
      promise_test(function() {
        return promise_rejects_js(this, TypeError, pc.createOffer(1));
      }, 'createOffer(1)' );

      // Test closed connection
      closedPC = new RTCPeerConnection();
      closedPC.close();
      promise_test(function() {
        return promise_rejects_dom(this, 'InvalidStateError', closedPC.createOffer({iceRestart:true}));
      }, 'createOffer() with closed peer connection' );
    </script>
  </body>
</html>