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

Side by Side Diff: src/inspector/injected-script-source.js

Issue 2770263003: [inspector] nullifyObjectPrototype -> InjectedScriptHost.nullifyPrototype (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 * @return {string} 76 * @return {string}
77 */ 77 */
78 function toStringDescription(obj) 78 function toStringDescription(obj)
79 { 79 {
80 if (typeof obj === "number" && obj === 0 && 1 / obj < 0) 80 if (typeof obj === "number" && obj === 0 && 1 / obj < 0)
81 return "-0"; // Negative zero. 81 return "-0"; // Negative zero.
82 return toString(obj); 82 return toString(obj);
83 } 83 }
84 84
85 /** 85 /**
86 * @param {T} obj
87 * @return {T}
88 * @template T
89 */
90 function nullifyObjectProto(obj)
91 {
92 if (obj && typeof obj === "object")
93 obj.__proto__ = null;
94 return obj;
95 }
96
97 /**
98 * @param {number|string} obj 86 * @param {number|string} obj
99 * @return {boolean} 87 * @return {boolean}
100 */ 88 */
101 function isUInt32(obj) 89 function isUInt32(obj)
102 { 90 {
103 if (typeof obj === "number") 91 if (typeof obj === "number")
104 return obj >>> 0 === obj && (obj > 0 || 1 / obj > 0); 92 return obj >>> 0 === obj && (obj > 0 || 1 / obj > 0);
105 return "" + (obj >>> 0) === obj; 93 return "" + (obj >>> 0) === obj;
106 } 94 }
107 95
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // Silent catch. 436 // Silent catch.
449 continue; 437 continue;
450 } 438 }
451 } 439 }
452 440
453 descriptor.name = name; 441 descriptor.name = name;
454 if (o === object) 442 if (o === object)
455 descriptor.isOwn = true; 443 descriptor.isOwn = true;
456 if (isSymbol(property)) 444 if (isSymbol(property))
457 descriptor.symbol = property; 445 descriptor.symbol = property;
458 descriptor = nullifyObjectProto(descriptor);
459 if (!addPropertyIfNeeded(descriptors, descriptor)) 446 if (!addPropertyIfNeeded(descriptors, descriptor))
460 return false; 447 return false;
461 } 448 }
462 return true; 449 return true;
463 } 450 }
464 451
465 if (propertyNamesOnly) { 452 if (propertyNamesOnly) {
466 for (var i = 0; i < propertyNamesOnly.length; ++i) { 453 for (var i = 0; i < propertyNamesOnly.length; ++i) {
467 var name = propertyNamesOnly[i]; 454 var name = propertyNamesOnly[i];
468 for (var o = object; this._isDefined(o); o = this._objectPrototy pe(/** @type {!Object} */ (o))) { 455 for (var o = object; this._isDefined(o); o = this._objectPrototy pe(/** @type {!Object} */ (o))) {
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 preview.overflow = true; 1027 preview.overflow = true;
1041 return; 1028 return;
1042 } 1029 }
1043 preview.entries = []; 1030 preview.entries = [];
1044 var entriesThreshold = 5; 1031 var entriesThreshold = 5;
1045 for (var i = 0; i < entries.length; ++i) { 1032 for (var i = 0; i < entries.length; ++i) {
1046 if (preview.entries.length >= entriesThreshold) { 1033 if (preview.entries.length >= entriesThreshold) {
1047 preview.overflow = true; 1034 preview.overflow = true;
1048 break; 1035 break;
1049 } 1036 }
1050 var entry = nullifyObjectProto(entries[i]); 1037 var entry = InjectedScriptHost.nullifyPrototype(entries[i]);
kozy 2017/03/24 20:23:04 I couldn't add a test since we return entry with n
1051 var previewEntry = { 1038 var previewEntry = {
1052 value: generateValuePreview(entry.value), 1039 value: generateValuePreview(entry.value),
1053 __proto__: null 1040 __proto__: null
1054 }; 1041 };
1055 if ("key" in entry) 1042 if ("key" in entry)
1056 previewEntry.key = generateValuePreview(entry.key); 1043 previewEntry.key = generateValuePreview(entry.key);
1057 push(preview.entries, previewEntry); 1044 push(preview.entries, previewEntry);
1058 } 1045 }
1059 1046
1060 /** 1047 /**
(...skipping 24 matching lines...) Expand all
1085 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); 1072 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf);
1086 } 1073 }
1087 return string.substr(0, maxLength) + "\u2026"; 1074 return string.substr(0, maxLength) + "\u2026";
1088 }, 1075 },
1089 1076
1090 __proto__: null 1077 __proto__: null
1091 } 1078 }
1092 1079
1093 return injectedScript; 1080 return injectedScript;
1094 }) 1081 })
OLDNEW
« 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