Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8882)

Unified Diff: chrome/test/data/webrtc/peerconnection.js

Issue 904823002: webrtc: Fixes WebRtcBrowserTest to use DOM attributes correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed a review comment. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..78d63cff84cbcdc54b7d7b667c6abdc3d8040abb 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;
+ 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
*/
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698