OLD | NEW |
---|---|
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 | 213 |
214 while (k < len) { | 214 while (k < len) { |
215 if (str[k] === searchElement) | 215 if (str[k] === searchElement) |
216 return k; | 216 return k; |
217 ++k; | 217 ++k; |
218 } | 218 } |
219 return -1; | 219 return -1; |
220 } | 220 } |
221 | 221 |
222 /** | 222 /** |
223 * DOM Attributes which have observable side effect on getter, in the form of | |
224 * {interfaceName1: {attributeName1: true, | |
225 * attributeName2: true, | |
226 * ...}, | |
227 * interfaceName2: {...}, | |
228 * ...} | |
229 * @type {!Object<string, !Object<string, boolean>>} | |
230 * @const | |
231 */ | |
232 var domAttributesWithObservableSideEffectOnGet = InjectedScriptHost.getDOMAttrib utesWithObservableSideEffectOnGet(); | |
pfeldman
2015/03/09 11:41:41
var domAttributesWithObservableSideEffectOnGet = n
Yuki
2015/03/09 12:48:13
Done.
| |
233 | |
234 /** | |
235 * @param {!Object} object | |
236 * @param {!string} attribute | |
237 * @return {boolean} | |
238 */ | |
239 function doesAttributeHaveObservableSideEffectOnGet(object, attribute) | |
240 { | |
241 for (var interfaceName in domAttributesWithObservableSideEffectOnGet) { | |
242 var isInstance = InjectedScriptHost.suppressWarningsAndCallFunction(func tion(object, interfaceName) { | |
243 return typeof window[interfaceName] === "function" && object instanc eof window[interfaceName]; | |
pfeldman
2015/03/09 11:41:41
This is no better than what it used to be as long
Yuki
2015/03/09 12:48:13
I prefer option 1. I don't think it's worth creat
| |
244 }, null, [object, interfaceName]); | |
245 if (isInstance) { | |
246 return attribute in domAttributesWithObservableSideEffectOnGet[inter faceName]; | |
247 } | |
248 } | |
249 return false; | |
250 } | |
251 | |
252 /** | |
223 * @constructor | 253 * @constructor |
224 */ | 254 */ |
225 var InjectedScript = function() | 255 var InjectedScript = function() |
226 { | 256 { |
227 /** @type {!Object.<string, !Object>} */ | 257 /** @type {!Object.<string, !Object>} */ |
228 this._modules = { __proto__: null }; | 258 this._modules = { __proto__: null }; |
229 } | 259 } |
230 | 260 |
231 /** | 261 /** |
232 * @type {!Object.<string, boolean>} | 262 * @type {!Object.<string, boolean>} |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 var name = property; | 578 var name = property; |
549 if (isSymbol(property)) | 579 if (isSymbol(property)) |
550 name = injectedScript._describe(property); | 580 name = injectedScript._describe(property); |
551 | 581 |
552 try { | 582 try { |
553 propertyProcessed[property] = true; | 583 propertyProcessed[property] = true; |
554 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); | 584 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); |
555 if (descriptor) { | 585 if (descriptor) { |
556 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) | 586 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) |
557 continue; | 587 continue; |
558 if ("get" in descriptor && "set" in descriptor && Inject edScriptHost.isPopularDOMObject(object) && name != "__proto__") { | 588 if ("get" in descriptor && "set" in descriptor && name ! = "__proto__" && InjectedScriptHost.isDOMWrapper(object) && !doesAttributeHaveOb servableSideEffectOnGet(object, name)) { |
559 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [name ]); | 589 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [name ]); |
560 delete descriptor.get; | 590 delete descriptor.get; |
561 delete descriptor.set; | 591 delete descriptor.set; |
562 } | 592 } |
563 } else { | 593 } else { |
564 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. | 594 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. |
565 if (accessorPropertiesOnly) | 595 if (accessorPropertiesOnly) |
566 continue; | 596 continue; |
567 try { | 597 try { |
568 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null }; | 598 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null }; |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1509 if (middle) { | 1539 if (middle) { |
1510 var leftHalf = maxLength >> 1; | 1540 var leftHalf = maxLength >> 1; |
1511 var rightHalf = maxLength - leftHalf - 1; | 1541 var rightHalf = maxLength - leftHalf - 1; |
1512 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); | 1542 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); |
1513 } | 1543 } |
1514 return string.substr(0, maxLength) + "\u2026"; | 1544 return string.substr(0, maxLength) + "\u2026"; |
1515 }, | 1545 }, |
1516 | 1546 |
1517 __proto__: null | 1547 __proto__: null |
1518 } | 1548 } |
1549 | |
1519 /** | 1550 /** |
1520 * @constructor | 1551 * @constructor |
1521 * @param {number} ordinal | 1552 * @param {number} ordinal |
1522 * @param {!JavaScriptCallFrame} callFrame | 1553 * @param {!JavaScriptCallFrame} callFrame |
1523 * @param {number} asyncOrdinal | 1554 * @param {number} asyncOrdinal |
1524 */ | 1555 */ |
1525 InjectedScript.CallFrameProxy = function(ordinal, callFrame, asyncOrdinal) | 1556 InjectedScript.CallFrameProxy = function(ordinal, callFrame, asyncOrdinal) |
1526 { | 1557 { |
1527 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + (asyncOrdinal ? ",\"asyncOrdinal\":" + asyncOrdinal : "") + "}" ; | 1558 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + (asyncOrdinal ? ",\"asyncOrdinal\":" + asyncOrdinal : "") + "}" ; |
1528 this.functionName = (callFrame.type === "function" ? callFrame.functionName : ""); | 1559 this.functionName = (callFrame.type === "function" ? callFrame.functionName : ""); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1929 */ | 1960 */ |
1930 _logEvent: function(event) | 1961 _logEvent: function(event) |
1931 { | 1962 { |
1932 inspectedWindow.console.log(event.type, event); | 1963 inspectedWindow.console.log(event.type, event); |
1933 } | 1964 } |
1934 } | 1965 } |
1935 | 1966 |
1936 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1967 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1937 return injectedScript; | 1968 return injectedScript; |
1938 }) | 1969 }) |
OLD | NEW |