| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* eslint-disable indent */ | 5 /* eslint-disable indent */ |
| 6 (function(window) { | 6 (function(window) { |
| 7 | 7 |
| 8 // DevToolsAPI ---------------------------------------------------------------- | 8 // DevToolsAPI ---------------------------------------------------------------- |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 }); | 985 }); |
| 986 } | 986 } |
| 987 | 987 |
| 988 for (var i = 0; i < properties.length; ++i) | 988 for (var i = 0; i < properties.length; ++i) |
| 989 defineProperty(properties[i]); | 989 defineProperty(properties[i]); |
| 990 } | 990 } |
| 991 | 991 |
| 992 window.Object.observe = objectObserve; | 992 window.Object.observe = objectObserve; |
| 993 } | 993 } |
| 994 | 994 |
| 995 /** | |
| 996 * @suppressGlobalPropertiesCheck | |
| 997 */ | |
| 998 function sanitizeRemoteFrontendUrl() | |
| 999 { | |
| 1000 var remoteBaseRegexp = /^https:\/\/chrome-devtools-frontend\.appspot\.com\/s
erve_file\/@[0-9a-zA-Z]+\/?$/; | |
| 1001 var remoteFrontendUrlRegexp = /^https:\/\/chrome-devtools-frontend\.appspot\
.com\/serve_rev\/@?[0-9a-zA-Z]+\/(devtools|inspector)\.html$/; | |
| 1002 var queryParams = location.search; | |
| 1003 if (!queryParams) | |
| 1004 return; | |
| 1005 var params = queryParams.substring(1).split("&"); | |
| 1006 for (var i = 0; i < params.length; ++i) { | |
| 1007 var pair = params[i].split("="); | |
| 1008 var name = pair.shift(); | |
| 1009 var value = pair.join("="); | |
| 1010 if (name === "remoteFrontendUrl" && !remoteFrontendUrlRegexp.test(value)
) | |
| 1011 location.search = ""; | |
| 1012 if (name === "remoteBase" && !remoteBaseRegexp.test(value)) | |
| 1013 location.search = ""; | |
| 1014 if (name === "settings") | |
| 1015 location.search = ""; | |
| 1016 } | |
| 1017 } | |
| 1018 | |
| 1019 var staticKeyIdentifiers = new Map([ | 995 var staticKeyIdentifiers = new Map([ |
| 1020 [0x12, "Alt"], | 996 [0x12, "Alt"], |
| 1021 [0x11, "Control"], | 997 [0x11, "Control"], |
| 1022 [0x10, "Shift"], | 998 [0x10, "Shift"], |
| 1023 [0x14, "CapsLock"], | 999 [0x14, "CapsLock"], |
| 1024 [0x5b, "Win"], | 1000 [0x5b, "Win"], |
| 1025 [0x5c, "Win"], | 1001 [0x5c, "Win"], |
| 1026 [0x0c, "Clear"], | 1002 [0x0c, "Clear"], |
| 1027 [0x28, "Down"], | 1003 [0x28, "Down"], |
| 1028 [0x23, "End"], | 1004 [0x23, "End"], |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 result += hexString; | 1063 result += hexString; |
| 1088 return result; | 1064 return result; |
| 1089 } | 1065 } |
| 1090 | 1066 |
| 1091 /** | 1067 /** |
| 1092 * @suppressGlobalPropertiesCheck | 1068 * @suppressGlobalPropertiesCheck |
| 1093 * @suppress {checkTypes} | 1069 * @suppress {checkTypes} |
| 1094 */ | 1070 */ |
| 1095 function installBackwardsCompatibility() | 1071 function installBackwardsCompatibility() |
| 1096 { | 1072 { |
| 1097 sanitizeRemoteFrontendUrl(); | |
| 1098 | |
| 1099 if (window.location.search.indexOf("remoteFrontend") === -1) | 1073 if (window.location.search.indexOf("remoteFrontend") === -1) |
| 1100 return; | 1074 return; |
| 1101 | 1075 |
| 1102 // Support for legacy (<M53) frontends. | 1076 // Support for legacy (<M53) frontends. |
| 1103 if (!window.KeyboardEvent.prototype.hasOwnProperty("keyIdentifier")) { | 1077 if (!window.KeyboardEvent.prototype.hasOwnProperty("keyIdentifier")) { |
| 1104 Object.defineProperty(window.KeyboardEvent.prototype, "keyIdentifier", { | 1078 Object.defineProperty(window.KeyboardEvent.prototype, "keyIdentifier", { |
| 1105 get: function() | 1079 get: function() |
| 1106 { | 1080 { |
| 1107 return keyCodeToKeyIdentifier(this.keyCode); | 1081 return keyCodeToKeyIdentifier(this.keyCode); |
| 1108 } | 1082 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 NOT_READABLE_ERR: 0 // No matching DOMException, so code will be 0. | 1137 NOT_READABLE_ERR: 0 // No matching DOMException, so code will be 0. |
| 1164 }; | 1138 }; |
| 1165 } | 1139 } |
| 1166 | 1140 |
| 1167 function windowLoaded() | 1141 function windowLoaded() |
| 1168 { | 1142 { |
| 1169 window.removeEventListener("DOMContentLoaded", windowLoaded, false); | 1143 window.removeEventListener("DOMContentLoaded", windowLoaded, false); |
| 1170 installBackwardsCompatibility(); | 1144 installBackwardsCompatibility(); |
| 1171 } | 1145 } |
| 1172 | 1146 |
| 1173 sanitizeRemoteFrontendUrl(); | |
| 1174 if (window.document.head && (window.document.readyState === "complete" || window
.document.readyState === "interactive")) | 1147 if (window.document.head && (window.document.readyState === "complete" || window
.document.readyState === "interactive")) |
| 1175 installBackwardsCompatibility(); | 1148 installBackwardsCompatibility(); |
| 1176 else | 1149 else |
| 1177 window.addEventListener("DOMContentLoaded", windowLoaded, false); | 1150 window.addEventListener("DOMContentLoaded", windowLoaded, false); |
| 1178 | 1151 |
| 1179 })(window); | |
| 1180 | |
| 1181 if (!DOMTokenList.prototype.__originalDOMTokenListToggle) { | 1152 if (!DOMTokenList.prototype.__originalDOMTokenListToggle) { |
| 1182 DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype
.toggle; | 1153 DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype
.toggle; |
| 1183 DOMTokenList.prototype.toggle = function(token, force) | 1154 DOMTokenList.prototype.toggle = function(token, force) |
| 1184 { | 1155 { |
| 1185 if (arguments.length === 1) | 1156 if (arguments.length === 1) |
| 1186 force = !this.contains(token); | 1157 force = !this.contains(token); |
| 1187 return this.__originalDOMTokenListToggle(token, !!force); | 1158 return this.__originalDOMTokenListToggle(token, !!force); |
| 1188 } | 1159 } |
| 1189 } | 1160 } |
| 1161 |
| 1162 })(window); |
| OLD | NEW |