| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  351       realSetConfiguration(this, configuration); |  352       realSetConfiguration(this, configuration); | 
|  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  | 
 |  362  | 
|  361     let configuration = protectConfiguration(args[0]); |  363     let configuration = protectConfiguration(args[0]); | 
 |  364  | 
|  362     // Since the old webkitRTCPeerConnection constructor takes an optional |  365     // Since the old webkitRTCPeerConnection constructor takes an optional | 
|  363     // second argument we need to take care to pass that through. Necessary |  366     // second argument we need to take care to pass that through. Necessary | 
|  364     // for older versions of Chrome such as 49. |  367     // for older versions of Chrome such as 49. | 
|  365     let peerconnection = new RealRTCPeerConnection(configuration, args[1]); |  368     let constraints = undefined; | 
 |  369     if (args.length > 1) | 
 |  370       constraints = args[1]; | 
 |  371  | 
 |  372     let peerconnection = new RealRTCPeerConnection(configuration, constraints); | 
|  366     checkConfiguration(peerconnection, configuration); |  373     checkConfiguration(peerconnection, configuration); | 
|  367     return peerconnection; |  374     return peerconnection; | 
|  368   } |  375   } | 
|  369  |  376  | 
|  370   WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype; |  377   WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype; | 
|  371  |  378  | 
|  372   let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind(); |  379   let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind(); | 
|  373   copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection, |  380   copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection, | 
|  374                  ["caller", "generateCertificate", "name", "prototype"]); |  381                  ["caller", "generateCertificate", "name", "prototype"]); | 
|  375   RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection; |  382   RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection; | 
|  376  |  383  | 
|  377   if ("RTCPeerConnection" in window) |  384   if ("RTCPeerConnection" in window) | 
|  378     window.RTCPeerConnection = boundWrappedRTCPeerConnection; |  385     window.RTCPeerConnection = boundWrappedRTCPeerConnection; | 
|  379   if ("webkitRTCPeerConnection" in window) |  386   if ("webkitRTCPeerConnection" in window) | 
|  380     window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection; |  387     window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection; | 
|  381 } |  388 } | 
|  382  |  389  | 
|  383 if (document instanceof HTMLDocument) |  390 if (document instanceof HTMLDocument) | 
|  384 { |  391 { | 
|  385   let script = document.createElement("script"); |  392   let script = document.createElement("script"); | 
|  386   script.type = "application/javascript"; |  393   script.type = "application/javascript"; | 
|  387   script.async = false; |  394   script.async = false; | 
|  388   script.textContent = "(" + injected + ")('" + randomEventName + "');"; |  395   script.textContent = "(" + injected + ")('" + randomEventName + "');"; | 
|  389   document.documentElement.appendChild(script); |  396   document.documentElement.appendChild(script); | 
|  390   document.documentElement.removeChild(script); |  397   document.documentElement.removeChild(script); | 
|  391 } |  398 } | 
| OLD | NEW |