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

Unified Diff: extensions/renderer/resources/binding.js

Issue 1928783005: [Extensions] Finish freezing schema (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 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
Index: extensions/renderer/resources/binding.js
diff --git a/extensions/renderer/resources/binding.js b/extensions/renderer/resources/binding.js
index 0eef6cf9031ce0e3a5fdaa278a1b9f99a2009f94..c5690907f4008ba5ce7492dcac854fcbd7e6e495 100644
--- a/extensions/renderer/resources/binding.js
+++ b/extensions/renderer/resources/binding.js
@@ -484,7 +484,17 @@ Binding.prototype = {
return;
}
- var value = propertyDef.value;
+ // |value| is eventually added to |m|, the exposed API. Make copies
+ // of everything from the schema. (The schema is also frozen, so as long
+ // as we don't make any modifications, shallow copies are fine.)
+ var value;
+ if ($Array.isArray(propertyDef.value))
+ value = $Array.slice(propertyDef.value);
+ else if (typeof propertyDef.value === 'object')
+ value = $Object.assign({}, propertyDef.value);
+ else
+ value = propertyDef.value;
+
if (value) {
// Values may just have raw types as defined in the JSON, such
// as "WINDOW_ID_NONE": { "value": -1 }. We handle this here.
« no previous file with comments | « chrome/test/data/extensions/api_test/stubs_app/background.js ('k') | extensions/renderer/resources/event.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698