Chromium Code Reviews| Index: chrome/test/data/webrtc/peerconnection.js |
| diff --git a/chrome/test/data/webrtc/peerconnection.js b/chrome/test/data/webrtc/peerconnection.js |
| index 96d3c8dac24c416200213b91ef737865bebf0423..bb5ed8b149c8eadec160ac6cb81560a3128e34aa 100644 |
| --- a/chrome/test/data/webrtc/peerconnection.js |
| +++ b/chrome/test/data/webrtc/peerconnection.js |
| @@ -57,7 +57,7 @@ function createLocalOffer(constraints) { |
| success_('createOffer'); |
| setLocalDescription(peerConnection, localOffer); |
| - returnToTest('ok-' + JSON.stringify(localOffer)); |
| + returnToTest('ok-' + stringifyDOMObject_(localOffer)); |
| }, |
| function(error) { failure_('createOffer', error); }, |
| constraints); |
| @@ -89,7 +89,7 @@ function receiveOfferFromPeer(sessionDescJson, constraints) { |
| function(answer) { |
| success_('createAnswer'); |
| setLocalDescription(peerConnection, answer); |
| - returnToTest('ok-' + JSON.stringify(answer)); |
| + returnToTest('ok-' + stringifyDOMObject_(answer)); |
| }, |
| function(error) { failure_('createAnswer', error); }, |
| constraints); |
| @@ -178,7 +178,7 @@ function getAllIceCandidates() { |
| return; |
| } |
| - returnToTest(JSON.stringify(gIceCandidates)); |
| + returnToTest(stringifyDOMObject_(gIceCandidates)); |
| } |
| /** |
| @@ -245,7 +245,7 @@ function success_(method) { |
| /** @private */ |
| function failure_(method, error) { |
| - throw failTest(method + '() failed: ' + JSON.stringify(error)); |
| + throw failTest(method + '() failed: ' + stringifyDOMObject_(error)); |
| } |
| /** @private */ |
| @@ -280,6 +280,28 @@ function removeStreamCallback_(event) { |
| } |
| /** |
| + * 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; |
|
phoglund_chromium
2015/02/06 09:46:29
Nit: indent 2
Yuki
2015/02/07 11:25:44
Done.
|
| + 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. |
| * @private |
| */ |