| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 let descriptor = Object.getOwnPropertyDescriptor(src, name); |
| 178 Object.getOwnPropertyDescriptor(src, name)); | 178 if (descriptor) |
| 179 Object.defineProperty(dest, name, descriptor); | |
| 179 } | 180 } |
| 180 } | 181 } |
| 181 | 182 |
| 182 /* | 183 /* |
| 183 * WebSocket wrapper | 184 * WebSocket wrapper |
| 184 * | 185 * |
| 185 * Required before Chrome 58, since the webRequest API didn't allow us to | 186 * Required before Chrome 58, since the webRequest API didn't allow us to |
| 186 * intercept WebSockets. | 187 * intercept WebSockets. |
| 187 * See https://bugs.chromium.org/p/chromium/issues/detail?id=129353 | 188 * See https://bugs.chromium.org/p/chromium/issues/detail?id=129353 |
| 188 */ | 189 */ |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 checkConfiguration(this, configuration); | 353 checkConfiguration(this, configuration); |
| 353 }; | 354 }; |
| 354 } | 355 } |
| 355 | 356 |
| 356 function WrappedRTCPeerConnection(...args) | 357 function WrappedRTCPeerConnection(...args) |
| 357 { | 358 { |
| 358 if (!(this instanceof WrappedRTCPeerConnection)) | 359 if (!(this instanceof WrappedRTCPeerConnection)) |
| 359 return WrappedRTCPeerConnection(); | 360 return WrappedRTCPeerConnection(); |
| 360 | 361 |
| 361 let configuration = protectConfiguration(args[0]); | 362 let configuration = protectConfiguration(args[0]); |
| 363 | |
| 362 // Since the old webkitRTCPeerConnection constructor takes an optional | 364 // Since the old webkitRTCPeerConnection constructor takes an optional |
| 363 // second argument we need to take care to pass that through. Necessary | 365 // second argument we need to take care to pass that through. Necessary |
| 364 // for older versions of Chrome such as 49. | 366 // for older versions of Chrome such as 49. |
| 365 let peerconnection = new RealRTCPeerConnection(configuration, args[1]); | 367 let constraints = undefined; |
| 368 if (args.length > 1) | |
| 369 constraints = args[1]; | |
| 370 | |
| 371 let peerconnection = new RealRTCPeerConnection(configuration, constraints); | |
| 366 checkConfiguration(peerconnection, configuration); | 372 checkConfiguration(peerconnection, configuration); |
| 367 return peerconnection; | 373 return peerconnection; |
| 368 } | 374 } |
| 369 | 375 |
| 370 WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype; | 376 WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype; |
| 371 | 377 |
| 372 let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind(); | 378 let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind(); |
| 373 copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection, | 379 copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection, |
| 374 ["caller", "generateCertificate", "name", "prototype"]); | 380 ["caller", "generateCertificate", "name", "prototype"]); |
|
Wladimir Palant
2017/05/22 10:55:17
So the issue is being caused by trying to copy the
kzar
2017/05/22 11:25:31
Yea, I just checked and "caller" is indeed the pro
| |
| 375 RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection; | 381 RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection; |
| 376 | 382 |
| 377 if ("RTCPeerConnection" in window) | 383 if ("RTCPeerConnection" in window) |
| 378 window.RTCPeerConnection = boundWrappedRTCPeerConnection; | 384 window.RTCPeerConnection = boundWrappedRTCPeerConnection; |
| 379 if ("webkitRTCPeerConnection" in window) | 385 if ("webkitRTCPeerConnection" in window) |
| 380 window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection; | 386 window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection; |
| 381 } | 387 } |
| 382 | 388 |
| 383 if (document instanceof HTMLDocument) | 389 if (document instanceof HTMLDocument) |
| 384 { | 390 { |
| 385 let script = document.createElement("script"); | 391 let script = document.createElement("script"); |
| 386 script.type = "application/javascript"; | 392 script.type = "application/javascript"; |
| 387 script.async = false; | 393 script.async = false; |
| 388 script.textContent = "(" + injected + ")('" + randomEventName + "');"; | 394 script.textContent = "(" + injected + ")('" + randomEventName + "');"; |
| 389 document.documentElement.appendChild(script); | 395 document.documentElement.appendChild(script); |
| 390 document.documentElement.removeChild(script); | 396 document.documentElement.removeChild(script); |
| 391 } | 397 } |
| OLD | NEW |