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

Side by Side Diff: Source/devtools/front_end/emulation/OverridesSupport.js

Issue 1313793005: Fixes a bug where touch device scripts were not cleared on exit of device mode in devtools. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Simplified logic for adding/removing touch emulation scripts for device mode. Created 5 years, 3 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) 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
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
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;
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