Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: inject.preload.js

Issue 29445594: Noissue - Fix some problems Firefox has with our injected code (Closed)
Left Patch Set: Created May 22, 2017, 10:31 a.m.
Right Patch Set: Don't copy the caller property Created May 22, 2017, 11:23 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 let descriptor = Object.getOwnPropertyDescriptor(src, name); 177 Object.defineProperty(dest, name,
178 if (descriptor) 178 Object.getOwnPropertyDescriptor(src, name));
179 Object.defineProperty(dest, name, descriptor);
180 } 179 }
181 } 180 }
182 181
183 /* 182 /*
184 * WebSocket wrapper 183 * WebSocket wrapper
185 * 184 *
186 * Required before Chrome 58, since the webRequest API didn't allow us to 185 * Required before Chrome 58, since the webRequest API didn't allow us to
187 * intercept WebSockets. 186 * intercept WebSockets.
188 * See https://bugs.chromium.org/p/chromium/issues/detail?id=129353 187 * See https://bugs.chromium.org/p/chromium/issues/detail?id=129353
189 */ 188 */
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 realSetConfiguration(this, configuration); 351 realSetConfiguration(this, configuration);
353 checkConfiguration(this, configuration); 352 checkConfiguration(this, configuration);
354 }; 353 };
355 } 354 }
356 355
357 function WrappedRTCPeerConnection(...args) 356 function WrappedRTCPeerConnection(...args)
358 { 357 {
359 if (!(this instanceof WrappedRTCPeerConnection)) 358 if (!(this instanceof WrappedRTCPeerConnection))
360 return WrappedRTCPeerConnection(); 359 return WrappedRTCPeerConnection();
361 360
362
363 let configuration = protectConfiguration(args[0]); 361 let configuration = protectConfiguration(args[0]);
364 362
365 // Since the old webkitRTCPeerConnection constructor takes an optional 363 // Since the old webkitRTCPeerConnection constructor takes an optional
366 // second argument we need to take care to pass that through. Necessary 364 // second argument we need to take care to pass that through. Necessary
367 // for older versions of Chrome such as 49. 365 // for older versions of Chrome such as 49.
368 let constraints = undefined; 366 let constraints = undefined;
369 if (args.length > 1) 367 if (args.length > 1)
370 constraints = args[1]; 368 constraints = args[1];
371 369
372 let peerconnection = new RealRTCPeerConnection(configuration, constraints); 370 let peerconnection = new RealRTCPeerConnection(configuration, constraints);
373 checkConfiguration(peerconnection, configuration); 371 checkConfiguration(peerconnection, configuration);
374 return peerconnection; 372 return peerconnection;
375 } 373 }
376 374
377 WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype; 375 WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype;
378 376
379 let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind(); 377 let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind();
380 copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection, 378 copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection,
381 ["caller", "generateCertificate", "name", "prototype"]); 379 ["generateCertificate", "name", "prototype"]);
382 RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection; 380 RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection;
383 381
384 if ("RTCPeerConnection" in window) 382 if ("RTCPeerConnection" in window)
385 window.RTCPeerConnection = boundWrappedRTCPeerConnection; 383 window.RTCPeerConnection = boundWrappedRTCPeerConnection;
386 if ("webkitRTCPeerConnection" in window) 384 if ("webkitRTCPeerConnection" in window)
387 window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection; 385 window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection;
388 } 386 }
389 387
390 if (document instanceof HTMLDocument) 388 if (document instanceof HTMLDocument)
391 { 389 {
392 let script = document.createElement("script"); 390 let script = document.createElement("script");
393 script.type = "application/javascript"; 391 script.type = "application/javascript";
394 script.async = false; 392 script.async = false;
395 script.textContent = "(" + injected + ")('" + randomEventName + "');"; 393 script.textContent = "(" + injected + ")('" + randomEventName + "');";
396 document.documentElement.appendChild(script); 394 document.documentElement.appendChild(script);
397 document.documentElement.removeChild(script); 395 document.documentElement.removeChild(script);
398 } 396 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld