Re: [webrtc-pc] When is negotiation complete? (#2495)

**If this is just for testing...**

Wouldn't the following be able to tell if negotiation was needed in most cases? There might be special cases like when pc closes, if data channels are used or if setCodecPreference or setStreams has happened, but those would probably be separate tests anyway:

```
function isNegotiationNeeded() {
  for (transceiver of pc.getTransceivers()) {
    if (transceiver.currentDirection != transceiver.direction)
      return true;
  }
  return false;
}
```

And at strategic points in WPTs, probably when returning to stable, you could...
```
const wasNegotiationNeeded = isNegotiationNeeded();
let didFireNegotiationNeeded = false;
pc.onnegotiationneeded = () => { didFireNegotiationNeeded = true; }
await new Promise(r => setTimeout(r, 0));
assert_equals(wasNegotiationNeeded, didFireNegotiationNeeded);
```

**With regards to Proposal B (Expose a negotiationneeded boolean attribute) **

> Complication: once set, we MUST fire negotiationneeded event, to meet JS expectations.

Why is this complicated? Why is having to fire the event a problem? Because of "maybe fire" logic...?

-- 
GitHub Notification of comment by henbos
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2495#issuecomment-605998218 using your GitHub account

Received on Monday, 30 March 2020 13:27:17 UTC