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(); | |
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 if (window[interfaceName] && object instanceof window[interfaceName]) { | |
yurys
2015/03/06 09:55:39
Note that window[interfaceName] may well be overwr
Yuki
2015/03/06 14:15:56
I've enclosed this part with InjectedScriptHost.su
| |
243 return attribute in domAttributesWithObservableSideEffectOnGet[inter faceName]; | |
244 } | |
245 } | |
246 return false; | |
247 } | |
248 | |
249 /** | |
223 * @constructor | 250 * @constructor |
224 */ | 251 */ |
225 var InjectedScript = function() | 252 var InjectedScript = function() |
226 { | 253 { |
227 /** @type {!Object.<string, !Object>} */ | 254 /** @type {!Object.<string, !Object>} */ |
228 this._modules = { __proto__: null }; | 255 this._modules = { __proto__: null }; |
229 } | 256 } |
230 | 257 |
231 /** | 258 /** |
232 * @type {!Object.<string, boolean>} | 259 * @type {!Object.<string, boolean>} |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 var name = property; | 575 var name = property; |
549 if (isSymbol(property)) | 576 if (isSymbol(property)) |
550 name = injectedScript._describe(property); | 577 name = injectedScript._describe(property); |
551 | 578 |
552 try { | 579 try { |
553 propertyProcessed[property] = true; | 580 propertyProcessed[property] = true; |
554 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); | 581 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); |
555 if (descriptor) { | 582 if (descriptor) { |
556 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) | 583 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) |
557 continue; | 584 continue; |
558 if ("get" in descriptor && "set" in descriptor && Inject edScriptHost.isPopularDOMObject(object) && name != "__proto__") { | 585 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 ]); | 586 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [name ]); |
560 delete descriptor.get; | 587 delete descriptor.get; |
561 delete descriptor.set; | 588 delete descriptor.set; |
562 } | 589 } |
563 } else { | 590 } else { |
564 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. | 591 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. |
565 if (accessorPropertiesOnly) | 592 if (accessorPropertiesOnly) |
566 continue; | 593 continue; |
567 try { | 594 try { |
568 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null }; | 595 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) { | 1536 if (middle) { |
1510 var leftHalf = maxLength >> 1; | 1537 var leftHalf = maxLength >> 1; |
1511 var rightHalf = maxLength - leftHalf - 1; | 1538 var rightHalf = maxLength - leftHalf - 1; |
1512 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); | 1539 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); |
1513 } | 1540 } |
1514 return string.substr(0, maxLength) + "\u2026"; | 1541 return string.substr(0, maxLength) + "\u2026"; |
1515 }, | 1542 }, |
1516 | 1543 |
1517 __proto__: null | 1544 __proto__: null |
1518 } | 1545 } |
1546 | |
1519 /** | 1547 /** |
1520 * @constructor | 1548 * @constructor |
1521 * @param {number} ordinal | 1549 * @param {number} ordinal |
1522 * @param {!JavaScriptCallFrame} callFrame | 1550 * @param {!JavaScriptCallFrame} callFrame |
1523 * @param {number} asyncOrdinal | 1551 * @param {number} asyncOrdinal |
1524 */ | 1552 */ |
1525 InjectedScript.CallFrameProxy = function(ordinal, callFrame, asyncOrdinal) | 1553 InjectedScript.CallFrameProxy = function(ordinal, callFrame, asyncOrdinal) |
1526 { | 1554 { |
1527 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + (asyncOrdinal ? ",\"asyncOrdinal\":" + asyncOrdinal : "") + "}" ; | 1555 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + (asyncOrdinal ? ",\"asyncOrdinal\":" + asyncOrdinal : "") + "}" ; |
1528 this.functionName = (callFrame.type === "function" ? callFrame.functionName : ""); | 1556 this.functionName = (callFrame.type === "function" ? callFrame.functionName : ""); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1929 */ | 1957 */ |
1930 _logEvent: function(event) | 1958 _logEvent: function(event) |
1931 { | 1959 { |
1932 inspectedWindow.console.log(event.type, event); | 1960 inspectedWindow.console.log(event.type, event); |
1933 } | 1961 } |
1934 } | 1962 } |
1935 | 1963 |
1936 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1964 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1937 return injectedScript; | 1965 return injectedScript; |
1938 }) | 1966 }) |
OLD | NEW |