Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 dispatchEvent(new RealCustomEvent(eventName, | 167 dispatchEvent(new RealCustomEvent(eventName, |
168 {detail: {url, requestType}})); | 168 {detail: {url, requestType}})); |
169 }; | 169 }; |
170 } | 170 } |
171 | 171 |
172 // Only to be called before the page's code, not hardened. | 172 // Only to be called before the page's code, not hardened. |
173 function copyProperties(src, dest, properties) | 173 function copyProperties(src, dest, properties) |
174 { | 174 { |
175 for (let name of properties) | 175 for (let name of properties) |
176 { | 176 { |
177 Object.defineProperty(dest, name, | 177 if (src.hasOwnProperty(name)) |
178 Object.getOwnPropertyDescriptor(src, name)); | 178 { |
179 Object.defineProperty(dest, name, | |
180 Object.getOwnPropertyDescriptor(src, name)); | |
181 } | |
179 } | 182 } |
180 } | 183 } |
181 | 184 |
182 /* | 185 /* |
183 * WebSocket wrapper | 186 * WebSocket wrapper |
184 * | 187 * |
185 * Required before Chrome 58, since the webRequest API didn't allow us to | 188 * Required before Chrome 58, since the webRequest API didn't allow us to |
186 * intercept WebSockets. | 189 * intercept WebSockets. |
187 * See https://bugs.chromium.org/p/chromium/issues/detail?id=129353 | 190 * See https://bugs.chromium.org/p/chromium/issues/detail?id=129353 |
188 */ | 191 */ |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 constraints = args[1]; | 371 constraints = args[1]; |
369 | 372 |
370 let peerconnection = new RealRTCPeerConnection(configuration, constraints); | 373 let peerconnection = new RealRTCPeerConnection(configuration, constraints); |
371 checkConfiguration(peerconnection, configuration); | 374 checkConfiguration(peerconnection, configuration); |
372 return peerconnection; | 375 return peerconnection; |
373 } | 376 } |
374 | 377 |
375 WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype; | 378 WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype; |
376 | 379 |
377 let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind(); | 380 let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind(); |
378 // NOTE: Edge does not support generateCertificate | 381 copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection, |
Sebastian Noack
2017/06/19 11:07:02
But what is about the other properties copied here
kzar
2017/06/19 14:13:38
Yea, this is not good. Please instead modify the c
Oleksandr
2017/06/21 23:38:35
Done.
| |
379 if ("generateCertificate" in RealRTCPeerConnection) | 382 ["generateCertificate", "name", "prototype"]); |
380 copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection, | |
381 ["generateCertificate", "name", "prototype"]); | |
382 RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection; | 383 RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection; |
383 | 384 |
384 if ("RTCPeerConnection" in window) | 385 if ("RTCPeerConnection" in window) |
385 window.RTCPeerConnection = boundWrappedRTCPeerConnection; | 386 window.RTCPeerConnection = boundWrappedRTCPeerConnection; |
386 if ("webkitRTCPeerConnection" in window) | 387 if ("webkitRTCPeerConnection" in window) |
387 window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection; | 388 window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection; |
388 } | 389 } |
389 | 390 |
390 if (document instanceof HTMLDocument) | 391 if (document instanceof HTMLDocument) |
391 { | 392 { |
392 let sandbox = window.frameElement && | 393 let sandbox = window.frameElement && |
393 window.frameElement.getAttribute("sandbox"); | 394 window.frameElement.getAttribute("sandbox"); |
394 | 395 |
395 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox)) | 396 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox)) |
396 { | 397 { |
397 let script = document.createElement("script"); | 398 let script = document.createElement("script"); |
398 script.type = "application/javascript"; | 399 script.type = "application/javascript"; |
399 script.async = false; | 400 script.async = false; |
400 script.textContent = "(" + injected + ")('" + randomEventName + "');"; | 401 script.textContent = "(" + injected + ")('" + randomEventName + "');"; |
401 document.documentElement.appendChild(script); | 402 document.documentElement.appendChild(script); |
402 document.documentElement.removeChild(script); | 403 document.documentElement.removeChild(script); |
403 } | 404 } |
404 } | 405 } |
LEFT | RIGHT |