Commit e2028bd7 authored by Kristoffer Erlandsson's avatar Kristoffer Erlandsson Committed by Commit Bot

Add test that verifies a particular PeerConnection setup does not deadlock

Does the connection setup in a specific sequence that historically
triggered a deadlock (https://crbug.com/736725). The test simply
verifies this specific sequence completes without errors.

Verified it fails on the deadlock by running the test on the parent commit
(2485344d)of the original bug fix.

BUG=chromium:818584

Change-Id: I3245de0b8f824a83f26a310d8f12bba45aea0958
Reviewed-on: https://chromium-review.googlesource.com/1044196
Commit-Queue: Kristoffer Erlandsson <kerl@google.com>
Reviewed-by: default avatarPatrik Höglund <phoglund@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556359}
parent 63c80f2e
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/command_line.h"
#include "build/build_config.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/webrtc/webrtc_content_browsertest_base.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_utils.h"
namespace content {
#if defined(OS_ANDROID) && defined(ADDRESS_SANITIZER)
// Renderer crashes under Android ASAN: https://crbug.com/408496.
#define MAYBE_WebRtcAddStreamNoDeadlockBrowserTest \
DISABLED_WebRtcAddStreamNoDeadlockBrowserTest
#else
#define MAYBE_WebRtcAddStreamNoDeadlockBrowserTest \
WebRtcAddStreamNoDeadlockBrowserTest
#endif
// This test sets up a peer connection in a specific way which previously
// resulted in a deadlock. The test succeeds if the JavaScript completes
// without errors. If the deadlock is re-introduced the test will time out.
// This is a regression test for https://crbug.com/736725.
class MAYBE_WebRtcAddStreamNoDeadlockBrowserTest
: public WebRtcContentBrowserTestBase {
public:
MAYBE_WebRtcAddStreamNoDeadlockBrowserTest() {}
~MAYBE_WebRtcAddStreamNoDeadlockBrowserTest() override {}
void SetUpCommandLine(base::CommandLine* command_line) override {
WebRtcContentBrowserTestBase::SetUpCommandLine(command_line);
// Automatically grant device permission.
AppendUseFakeUIForMediaStreamFlag();
}
protected:
void MakeTypicalPeerConnectionCall(const std::string& javascript) {
MakeTypicalCall(javascript, "/media/peerconnection-add-stream.html");
}
};
IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAddStreamNoDeadlockBrowserTest,
AddStreamDoesNotCauseDeadlock) {
MakeTypicalPeerConnectionCall("runTest();");
}
} // namespace content
...@@ -1096,6 +1096,7 @@ test("content_browsertests") { ...@@ -1096,6 +1096,7 @@ test("content_browsertests") {
if (enable_webrtc) { if (enable_webrtc) {
sources += [ sources += [
"../browser/webrtc/webrtc_add_stream_no_deadlock_browsertest.cc",
"../browser/webrtc/webrtc_audio_browsertest.cc", "../browser/webrtc/webrtc_audio_browsertest.cc",
"../browser/webrtc/webrtc_audio_debug_recordings_browsertest.cc", "../browser/webrtc/webrtc_audio_debug_recordings_browsertest.cc",
"../browser/webrtc/webrtc_browsertest.cc", "../browser/webrtc/webrtc_browsertest.cc",
......
<html>
<body id="body">
<h1>PeerConnection add stream test</h1>
</body>
<script type="text/javascript" src="webrtc_test_utilities.js"></script>
<script type="text/javascript">
function runTest() {
let pc1 = new RTCPeerConnection();
var stream;
navigator.mediaDevices.getUserMedia({audio: true, video: true})
.then(theStream => {
stream = theStream;
pc1.addStream(stream);
return pc1.createOffer({offerToReceiveAudio: true, offerToReceiveVideo: true});
}).then(offer => {
pc1.setLocalDescription(offer);
return offer;
}).then(offer => {
const pc2 = new RTCPeerConnection();
pc2.setRemoteDescription(pc1.localDescription);
pc2.addStream(stream);
pc2.createAnswer();
}).then(() => {
reportTestSuccess();
}).catch(e => {
console.error(`Unexpected error: ${e}`);
failTest(`Unexpected error: ${e}`);
});
}
</script>
</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