<!DOCTYPE html>
<html>
<head>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async function promise_rejects(promise)
{
    return promise.then(() => {
        return "FAIL";
    }, (e) => {
        return e.name === 'TypeError' ? 'PASS' : 'Got error ' + e;
    })  
}

function with_iframe(url) {
  return new Promise(function(resolve) {
      var frame = document.createElement('iframe');
      frame.src = url;
      frame.onload = function() { resolve(frame); };
      document.body.appendChild(frame);
    });
}

promise_test(async (t) => {
  const iframe = await with_iframe('/');
  const pc = iframe.contentWindow.RTCPeerConnection;
  iframe.remove();
  return promise_rejects(pc.generateCertificate({ name: 'ECDSA', namedCurve: 'P-256'}));
});
</script>
Passes if it doesn't crash!
</body>
</html>
