Closed Bug 1112382 Opened 10 years ago Closed 9 years ago

Remove the duplicated code for data channel tests

Categories

(Core :: WebRTC, defect)

36 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: drno, Assigned: drno)

References

Details

Attachments

(1 file, 2 obsolete files)

It is very painful to maintain the two test queues in templates.js as they both do pretty much the same up to the point when the PC's are connected.

We should remove the DataChannelTest Wrapper.
Attachment #8537520 - Flags: review?(docfaraday)
I'll try to get to this tomorrow.
Comment on attachment 8537520 [details] [diff] [review]
refactor_data_channel_tests.patch

Review of attachment 8537520 [details] [diff] [review]:
-----------------------------------------------------------------

You'll have to rebase, since there's a NoBundle DataChannel test now. Also, I'm assuming that this patch is mostly moving stuff around, but I've noticed some problems in the moved code, a couple of which are relatively serious. At least fix the if (_allChannelsAreClosed) bug, and see what happens to the tests.

::: dom/media/tests/mochitest/dataChannel.js
@@ +183,5 @@
> +          }
> +          else {
> +            options.id = sourceChannel2.id;
> +          }
> +          var reliable = !options.ordered ? false : (options.maxRetransmits || options.maxRetransmitTime);

Uh, ordered delivery and reliability are orthogonal... is this from some old version of the spec, or something we've just added on our own?

::: dom/media/tests/mochitest/pc.js
@@ +743,5 @@
> +
> +  function _allChannelsAreClosed() {
> +    var ret = null;
> +    if (localChannel) {
> +      ret = (localChannel.readyState === "closed");

I think this would be much more readable with early returns (eg; if (localChannel && localChannel.readyState !== "closed") { return false; } )

@@ +761,5 @@
> +    if (everythingClosed) {
> +      // safety protection against events firing late
> +      return;
> +    }
> +    if (_allChannelsAreClosed) {

This should be if (_allChannelsAreClosed()); right now this will always be true, since functions themselves are "truthy".

@@ +780,5 @@
> +
> +  if ((localChannel) && (localChannel.readyState !== "closed")) {
> +    // in case of steeplechase there is no far end, so we can only poll
> +    if (remoteChannel) {
> +      remoteChannel.onclose = function () {

I'm not sure I understand why we don't set this if localChannel is already closed. Shouldn't we set both remoteChannel.onclose and localChannel.onclose regardless? Seems simpler that way, and less fragile. (For example, if localChannel is already closed, but remoteChannel is not, remoteChannel.onclose is never set, which is surely not right)
Attachment #8537520 - Flags: review?(docfaraday) → review-
I fixed the missing function call in the if statement. Thx!

For the rest: on purpose I wanted to change as little as possible to not cause any side effects. I would prefer to open new/separate tickets for the issues you found. I think that would make it easier to track them. Would you be OK with that approach?

Try run: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=bf6b4701eb55
Attachment #8537520 - Attachment is obsolete: true
Attachment #8541039 - Flags: review?(docfaraday)
I'm ok with that, just don't forget the NoBundle test.
(In reply to Byron Campen [:bwc] (PTO through Jan 1) from comment #5)
> I'm ok with that, just don't forget the NoBundle test.

I sure did :-( Thanks for the reminder :-)
Blocks: 1115769
Fixed the nobundle data channel test as pointed out by Byron.

Try run: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=8819a710a821

Follow up bug for fixing the issues pointed out in comment #3: 1115769
Attachment #8541039 - Attachment is obsolete: true
Attachment #8541039 - Flags: review?(docfaraday)
Attachment #8541785 - Flags: review?(docfaraday)
Blocks: 1115823
Comment on attachment 8541785 [details] [diff] [review]
refactor_data_channel_tests.patch

Review of attachment 8541785 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm
Attachment #8541785 - Flags: review?(docfaraday) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/0dfb8c9e7e64
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: