Fix errors in external/wpt/RTCDTMFSender-insertDTMF.https.html.

This is in preparation for RTCRtpTransceiver/Unified Plan support.

Updated tests:
  insertDTMF() should throw InvalidStateError if
  transceiver.currentDirection is [recvonly/inactive]

Just like the tests fixed in
https://chromium-review.googlesource.com/c/chromium/src/+/1095275, the
tests were not set up properly.

Fixed the tests so that currentDirection is what it is supposed to be
according to the test description. Also updated the tests to use
async/await.

These tests will pass when we support RTCRtpTransceiver (WIP CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1025771).

Bug: 777617
Change-Id: I59eab4e4a15bb82e2dabe68d56f6d55b0e380e75
Reviewed-on: https://chromium-review.googlesource.com/1097083
Commit-Queue: Henrik Boström <hbos@chromium.org>
Reviewed-by: Henrik Boström <hbos@chromium.org>
Reviewed-by: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566432}
diff --git a/webrtc/RTCDTMFSender-insertDTMF.https.html b/webrtc/RTCDTMFSender-insertDTMF.https.html
index 9c0055b..2e47986 100644
--- a/webrtc/RTCDTMFSender-insertDTMF.https.html
+++ b/webrtc/RTCDTMFSender-insertDTMF.https.html
@@ -107,40 +107,40 @@
     7.2.  insertDTMF
       4.  If transceiver.currentDirection is recvonly or inactive, throw an InvalidStateError.
    */
-  promise_test(t => {
-    const pc = new RTCPeerConnection();
-    t.add_cleanup(() => pc.close());
-    const transceiver = pc.addTransceiver('audio', {
-      direction: 'recvonly'
-    });
+  promise_test(async t => {
+    const caller = new RTCPeerConnection();
+    t.add_cleanup(() => caller.close());
+    const callee = new RTCPeerConnection();
+    t.add_cleanup(() => callee.close());
+    const transceiver =
+        caller.addTransceiver('audio', { direction: 'recvonly' });
     const dtmfSender = transceiver.sender.dtmf;
 
-    return pc.createOffer()
-    .then(offer =>
-      pc.setLocalDescription(offer)
-      .then(() => generateAnswer(offer)))
-    .then(() => {
-      assert_equals(transceiver.currentDirection, 'inactive');
-      assert_throws('InvalidStateError', () => dtmfSender.insertDTMF(''));
-    });
+    const offer = await caller.createOffer();
+    await caller.setLocalDescription(offer);
+    await callee.setRemoteDescription(offer);
+    const track = generateMediaStreamTrack('audio');
+    callee.addTrack(track);
+    const answer = await callee.createAnswer();
+    await callee.setLocalDescription(answer);
+    await caller.setRemoteDescription(answer);
+    assert_equals(transceiver.currentDirection, 'recvonly');
+    assert_throws('InvalidStateError', () => dtmfSender.insertDTMF(''));
   }, 'insertDTMF() should throw InvalidStateError if transceiver.currentDirection is recvonly');
 
-  promise_test(t => {
+  promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const transceiver = pc.addTransceiver('audio', {
-      direction: 'inactive'
-    });
+    const transceiver =
+        pc.addTransceiver('audio', { direction: 'inactive' });
     const dtmfSender = transceiver.sender.dtmf;
 
-    return pc.createOffer()
-    .then(offer =>
-      pc.setLocalDescription(offer)
-      .then(() => generateAnswer(offer)))
-    .then(() => {
-      assert_equals(transceiver.currentDirection, 'inactive');
-      assert_throws('InvalidStateError', () => dtmfSender.insertDTMF(''));
-    });
+    const offer = await pc.createOffer();
+    await pc.setLocalDescription(offer);
+    const answer = await generateAnswer(offer);
+    await pc.setRemoteDescription(answer);
+    assert_equals(transceiver.currentDirection, 'inactive');
+    assert_throws('InvalidStateError', () => dtmfSender.insertDTMF(''));
   }, 'insertDTMF() should throw InvalidStateError if transceiver.currentDirection is inactive');
 
   /*