Commit 52699cb4 authored by Harald Alvestrand's avatar Harald Alvestrand Committed by Commit Bot

Add tests for PeerConnection being destroyed by page reload.

Bug: chromium:1071327
Change-Id: I902cf55c0463e05c64f8ec0e90f2aaa826e31ec4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2152810
Commit-Queue: Harald Alvestrand <hta@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760005}
parent 6aac6001
<!DOCTYPE html>
<html>
<head>
<title>RTCPeerConnection-crash-tests</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
'use strict;'
promise_test(async t => {
// Note that this test uses location.reload, so there can't be more than
// one test per file with this simple reload-detection scheme.
if (sessionStorage.getItem('test-state') === 'reloading') {
return; // success
}
sessionStorage.setItem('test-state', 'starting');
// Set conditions that will cause OnInterestingUsage to be called.
const pc = new RTCPeerConnection();
pc.addTransceiver('audio');
const offer = await pc.createOffer();
const hasCandidate = new Promise(resolve => {
pc.onicecandidate = (e) => {
resolve();
}
});
await pc.setLocalDescription(offer);
await hasCandidate;
const pc2 = new RTCPeerConnection();
sessionStorage.setItem('test-state', 'reloading');
location.reload();
}, 'Reload with active PC with interesting usage does not crash');
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>RTCPeerConnection-crash-tests</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
'use strict;'
promise_test(async t => {
if (sessionStorage.getItem('test-state') === 'reloading') {
return; // success
}
sessionStorage.setItem('test-state', 'starting');
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
pc1.onicecandidate = (ev) => {
if (ev.candidate) {
pc2.addIceCandidate(ev.candidate);
}
}
pc2.onicecandidate = (ev) => {
if (ev.candidate) {
pc1.addIceCandidate(ev.candidate);
}
}
const dc = pc1.createDataChannel('foo');
const offer = await pc1.createOffer();
racer = pc1.setLocalDescription(offer);
sessionStorage.setItem('test-state', 'reloading');
location.reload();
// Note - execution continues after reload.
await racer;
await pc2.setRemoteDescription(offer);
const answer = await pc2.createAnswer();
await pc2.setLocalDescription(answer);
}, 'Reload while negotiating PC with SCTP connection does not crash');
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment