Commit e27865b7 authored by yukishiino's avatar yukishiino Committed by Commit bot

webrtc: Fixes WebRtcBrowserTest to use DOM attributes correctly.

WebRtcBrowserTest.RunsAudioVideoWebRTCCallInTwoTabs is assuming that DOM attributes are own properties on a JS obejct, which is not correct.  Blink (binding) team is working to move DOM attributes from own properties to properties on prototype chains, and then this test will break.

This CL fixes the test so that it stringifies not only own properties but also attributes on prototype chains.

BUG=43394

Review URL: https://codereview.chromium.org/904823002

Cr-Commit-Position: refs/heads/master@{#315198}
parent b0d2c352
...@@ -57,7 +57,7 @@ function createLocalOffer(constraints) { ...@@ -57,7 +57,7 @@ function createLocalOffer(constraints) {
success_('createOffer'); success_('createOffer');
setLocalDescription(peerConnection, localOffer); setLocalDescription(peerConnection, localOffer);
returnToTest('ok-' + JSON.stringify(localOffer)); returnToTest('ok-' + stringifyDOMObject_(localOffer));
}, },
function(error) { failure_('createOffer', error); }, function(error) { failure_('createOffer', error); },
constraints); constraints);
...@@ -89,7 +89,7 @@ function receiveOfferFromPeer(sessionDescJson, constraints) { ...@@ -89,7 +89,7 @@ function receiveOfferFromPeer(sessionDescJson, constraints) {
function(answer) { function(answer) {
success_('createAnswer'); success_('createAnswer');
setLocalDescription(peerConnection, answer); setLocalDescription(peerConnection, answer);
returnToTest('ok-' + JSON.stringify(answer)); returnToTest('ok-' + stringifyDOMObject_(answer));
}, },
function(error) { failure_('createAnswer', error); }, function(error) { failure_('createAnswer', error); },
constraints); constraints);
...@@ -178,7 +178,7 @@ function getAllIceCandidates() { ...@@ -178,7 +178,7 @@ function getAllIceCandidates() {
return; return;
} }
returnToTest(JSON.stringify(gIceCandidates)); returnToTest(stringifyDOMObject_(gIceCandidates));
} }
/** /**
...@@ -245,7 +245,7 @@ function success_(method) { ...@@ -245,7 +245,7 @@ function success_(method) {
/** @private */ /** @private */
function failure_(method, error) { function failure_(method, error) {
throw failTest(method + '() failed: ' + JSON.stringify(error)); throw failTest(method + '() failed: ' + stringifyDOMObject_(error));
} }
/** @private */ /** @private */
...@@ -279,6 +279,28 @@ function removeStreamCallback_(event) { ...@@ -279,6 +279,28 @@ function removeStreamCallback_(event) {
document.getElementById('remote-view').src = ''; document.getElementById('remote-view').src = '';
} }
/**
* Stringifies a DOM object.
*
* This function stringifies not only own properties but also DOM attributes
* which are on a prototype chain. Note that JSON.stringify only stringifies
* own properties.
* @private
*/
function stringifyDOMObject_(object)
{
function deepCopy(src) {
if (typeof src != "object")
return src;
var dst = Array.isArray(src) ? [] : {};
for (var property in src) {
dst[property] = deepCopy(src[property]);
}
return dst;
}
return JSON.stringify(deepCopy(object));
}
/** /**
* Parses JSON-encoded session descriptions and ICE candidates. * Parses JSON-encoded session descriptions and ICE candidates.
* @private * @private
......
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