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

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

Issue 1906593002: [Extensions] Finish freezing schema (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 13ac7f960ccd89e28d61d7e52ca65baded2c8451..796c26b74d2d8ddb8e20d35cce3928bc853d9dd5 100644
--- a/extensions/renderer/resources/binding.js
+++ b/extensions/renderer/resources/binding.js
@@ -481,7 +481,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