Commit 76a7e9cc authored by Henrik Boström's avatar Henrik Boström Committed by Commit Bot

Use legacy getStats() in browser tests.

This attempts to fix various failures in https://crbug.com/999136 due to
our browser tests expecting non-standard stats even after
chrome://webrtc-internals/ was updated to use standard getStats() by
default.

Bug: 999136, 1004239
Change-Id: Ia22ab8ab36213253801109a23b43838ffa24dc8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1806677Reviewed-by: default avatarMirko Bonadei <mbonadei@chromium.org>
Commit-Queue: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696780}
parent bdbf1141
...@@ -358,6 +358,10 @@ std::string WebRtcTestBase::ExecuteJavascript( ...@@ -358,6 +358,10 @@ std::string WebRtcTestBase::ExecuteJavascript(
return result; return result;
} }
void WebRtcTestBase::ChangeToLegacyGetStats(content::WebContents* tab) const {
content::ExecuteScriptAsync(tab, "changeToLegacyGetStats()");
}
void WebRtcTestBase::SetupPeerconnectionWithLocalStream( void WebRtcTestBase::SetupPeerconnectionWithLocalStream(
content::WebContents* tab, content::WebContents* tab,
const std::string& certificate_keygen_algorithm) const { const std::string& certificate_keygen_algorithm) const {
......
...@@ -116,6 +116,10 @@ class WebRtcTestBase : public InProcessBrowserTest { ...@@ -116,6 +116,10 @@ class WebRtcTestBase : public InProcessBrowserTest {
std::string ExecuteJavascript(const std::string& javascript, std::string ExecuteJavascript(const std::string& javascript,
content::WebContents* tab_contents) const; content::WebContents* tab_contents) const;
// TODO(https://crbug.com/1004239): Remove this function as soon as browser
// tests stop relying on the legacy getStats() API.
void ChangeToLegacyGetStats(content::WebContents* tab) const;
// Sets up a peer connection in the tab and adds the current local stream // Sets up a peer connection in the tab and adds the current local stream
// (which you can prepare by calling one of the GetUserMedia* methods above). // (which you can prepare by calling one of the GetUserMedia* methods above).
// Optionally, |certificate_keygen_algorithm| is JavaScript for an // Optionally, |certificate_keygen_algorithm| is JavaScript for an
......
...@@ -107,6 +107,9 @@ class WebRtcInternalsPerfBrowserTest : public WebRtcTestBase { ...@@ -107,6 +107,9 @@ class WebRtcInternalsPerfBrowserTest : public WebRtcTestBase {
content::WebContents* webrtc_internals_tab = content::WebContents* webrtc_internals_tab =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
// TODO(https://crbug.com/1004239): Stop relying on the legacy getStats()
// API.
ChangeToLegacyGetStats(webrtc_internals_tab);
test::SleepInJavascript(webrtc_internals_tab, duration_msec); test::SleepInJavascript(webrtc_internals_tab, duration_msec);
return std::unique_ptr<base::DictionaryValue>( return std::unique_ptr<base::DictionaryValue>(
......
...@@ -124,6 +124,7 @@ function createStatsSelectionOptionElements() { ...@@ -124,6 +124,7 @@ function createStatsSelectionOptionElements() {
const p = document.createElement('p'); const p = document.createElement('p');
const selectElement = document.createElement('select'); const selectElement = document.createElement('select');
selectElement.setAttribute('id', 'statsSelectElement');
selectElement.onchange = () => { selectElement.onchange = () => {
currentGetStatsMethod = selectElement.value; currentGetStatsMethod = selectElement.value;
Object.keys(peerConnectionDataStore).forEach(id => { Object.keys(peerConnectionDataStore).forEach(id => {
...@@ -176,6 +177,18 @@ function requestLegacyStats() { ...@@ -176,6 +177,18 @@ function requestLegacyStats() {
} }
} }
/*
* Change to use the legacy getStats() API instead. This is used for a
* work-around for https://crbug.com/999136.
* TODO(https://crbug.com/1004239): Delete this method.
*/
function changeToLegacyGetStats() {
currentGetStatsMethod = OPTION_GETSTATS_LEGACY;
const selectElement = $('statsSelectElement');
selectElement.value = currentGetStatsMethod;
requestStats();
}
/** /**
* A helper function for getting a peer connection element id. * A helper function for getting a peer connection element id.
* *
......
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