Bug 1604172 [wpt PR 20787] - Add test that datachannels close when connection does., a=testonly

Automatic update from web-platform-tests
Add test that datachannels close when connection does. (#20787)

Bug: chromium:1030631

Change-Id: I322374725ef4a05b0c6d83fc2971061952441718
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1969351
Commit-Queue: Harald Alvestrand <hta@chromium.org>
Reviewed-by: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#725278}

Co-authored-by: Harald Alvestrand <hta+github@alvestrand.no>

--

wpt-commits: 99dac72cb20c21de36483f0e0b56d802075fe24f
wpt-pr: 20787
This commit is contained in:
Blink WPT Bot 2020-01-06 16:08:46 +00:00 коммит произвёл moz-wptsync-bot
Родитель b91c5b27d0
Коммит 0fd69f30e8
1 изменённых файлов: 54 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,54 @@
<!doctype html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>RTCDataChannel.prototype.close</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script>
'use strict';
promise_test(async t => {
let pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
let [channel1, channel2] = await createDataChannelPair(pc1);
let close_handler = new Promise(resolve => {
channel2.onclose = event => {
resolve();
};
});
channel2.addEventListener('error', t.unreached_func());
channel1.close();
await close_handler;
}, 'Close datachannel causes onclose to be called');
promise_test(async t => {
// This is the same test as above, but using addEventListener
// rather than the "onclose" attribute.
let pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
let [channel1, channel2] = await createDataChannelPair(pc1);
let close_handler = new Promise(resolve => {
channel2.addEventListener('close', event => {
resolve();
});
});
channel2.addEventListener('error', t.unreached_func());
channel1.close();
await close_handler;
}, 'Close datachannel causes close event to be called');
promise_test(async t => {
let pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
let [channel1, channel2] = await createDataChannelPair(pc1);
let close_handler = new Promise(resolve => {
channel2.addEventListener('close', event => {
resolve();
});
});
pc1.close();
await close_handler;
}, 'Close peerconnection causes close event to be called');
</script>