OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 */ | 698 */ |
699 const injectedFunction = function() { | 699 const injectedFunction = function() { |
700 const touchEvents = ["ontouchstart", "ontouchend", "ontouchmove", "o
ntouchcancel"]; | 700 const touchEvents = ["ontouchstart", "ontouchend", "ontouchmove", "o
ntouchcancel"]; |
701 var recepients = [window.__proto__, document.__proto__]; | 701 var recepients = [window.__proto__, document.__proto__]; |
702 for (var i = 0; i < touchEvents.length; ++i) { | 702 for (var i = 0; i < touchEvents.length; ++i) { |
703 for (var j = 0; j < recepients.length; ++j) { | 703 for (var j = 0; j < recepients.length; ++j) { |
704 if (!(touchEvents[i] in recepients[j])) | 704 if (!(touchEvents[i] in recepients[j])) |
705 Object.defineProperty(recepients[j], touchEvents[i], { v
alue: null, writable: true, configurable: true, enumerable: true }); | 705 Object.defineProperty(recepients[j], touchEvents[i], { v
alue: null, writable: true, configurable: true, enumerable: true }); |
706 } | 706 } |
707 } | 707 } |
708 } | 708 }; |
709 | 709 |
710 var symbol = WebInspector.OverridesSupport._touchEventsScriptIdSymbol; | 710 var symbol = WebInspector.OverridesSupport._touchEventsScriptIdSymbol; |
711 | 711 |
712 if (emulationEnabled && target[symbol] !== -1) { | 712 if (typeof target[symbol] !== "undefined") { |
713 target[symbol] = -1; | 713 target.pageAgent().removeScriptToEvaluateOnLoad(target[symbol]); |
| 714 delete target[symbol]; |
| 715 } |
| 716 |
| 717 if (emulationEnabled) |
714 target.pageAgent().addScriptToEvaluateOnLoad("(" + injectedFunction.
toString() + ")()", scriptAddedCallback); | 718 target.pageAgent().addScriptToEvaluateOnLoad("(" + injectedFunction.
toString() + ")()", scriptAddedCallback); |
715 } else { | |
716 if (typeof target[symbol] !== "undefined") { | |
717 target.pageAgent().removeScriptToEvaluateOnLoad(target[symbol]); | |
718 delete target[symbol]; | |
719 } | |
720 } | |
721 | 719 |
722 /** | 720 /** |
723 * @param {?Protocol.Error} error | 721 * @param {?Protocol.Error} error |
724 * @param {string} scriptId | 722 * @param {string} scriptId |
725 */ | 723 */ |
726 function scriptAddedCallback(error, scriptId) | 724 function scriptAddedCallback(error, scriptId) |
727 { | 725 { |
728 if (error) | 726 if (error) |
729 delete target[symbol]; | 727 delete target[symbol]; |
730 else | 728 else |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 }, | 816 }, |
819 | 817 |
820 __proto__: WebInspector.Object.prototype | 818 __proto__: WebInspector.Object.prototype |
821 } | 819 } |
822 | 820 |
823 | 821 |
824 /** | 822 /** |
825 * @type {!WebInspector.OverridesSupport} | 823 * @type {!WebInspector.OverridesSupport} |
826 */ | 824 */ |
827 WebInspector.overridesSupport; | 825 WebInspector.overridesSupport; |
OLD | NEW |