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

Unified Diff: chrome/test/chromedriver/js/call_function.js

Issue 2854823003: [Chromedriver] Fix stack overflow in JavaScript code (Closed)
Patch Set: Created 3 years, 8 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/chromedriver/js/call_function.js
diff --git a/chrome/test/chromedriver/js/call_function.js b/chrome/test/chromedriver/js/call_function.js
index adabdbf616b4847988f57ccdc94952b26b8b3479..923ec317fb95e295af80ea6b5ed9faa24eafa562 100644
--- a/chrome/test/chromedriver/js/call_function.js
+++ b/chrome/test/chromedriver/js/call_function.js
@@ -271,9 +271,16 @@ function wrap(value) {
return wrapped;
}
- var obj = (typeof(value.length) == 'number') ? [] : {};
- for (var prop in value)
- obj[prop] = wrap(value[prop]);
+ var obj;
+ if (typeof(value.length) == 'number') {
+ obj = [];
+ for (var i = 0; i < value.length; i++)
+ obj[i] = wrap(value[i]);
+ } else {
+ obj = {};
+ for (var prop in value)
+ obj[prop] = wrap(value[prop]);
+ }
return obj;
}
return value;
@@ -292,9 +299,16 @@ function unwrap(value, cache) {
if (ELEMENT_KEY in value)
return cache.retrieveItem(value[ELEMENT_KEY]);
- var obj = (typeof(value.length) == 'number') ? [] : {};
- for (var prop in value)
- obj[prop] = unwrap(value[prop], cache);
+ var obj;
+ if (typeof(value.length) == 'number') {
+ obj = [];
+ for (var i = 0; i < value.length; i++)
+ obj[i] = unwrap(value[i], cache);
+ } else {
+ obj = {};
+ for (var prop in value)
+ obj[prop] = unwrap(value[prop], cache);
+ }
return obj;
}
return value;
« 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