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

Side by Side Diff: inject.preload.js

Issue 29458601: Issue 5315 - Add support for Microsoft Edge (Closed)
Patch Set: Rebase to current tip Created July 27, 2017, 9:45 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 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
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();
381 // NOTE: Edge does not support generateCertificate
kzar 2017/07/28 10:38:57 Nit: Mind removing this comment? I don't think it
378 copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection, 382 copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection,
379 ["generateCertificate", "name", "prototype"]); 383 ["generateCertificate", "name", "prototype"]);
380 RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection; 384 RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection;
381 385
382 if ("RTCPeerConnection" in window) 386 if ("RTCPeerConnection" in window)
383 window.RTCPeerConnection = boundWrappedRTCPeerConnection; 387 window.RTCPeerConnection = boundWrappedRTCPeerConnection;
384 if ("webkitRTCPeerConnection" in window) 388 if ("webkitRTCPeerConnection" in window)
385 window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection; 389 window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection;
386 } 390 }
387 391
388 if (document instanceof HTMLDocument) 392 if (document instanceof HTMLDocument)
389 { 393 {
390 let sandbox = window.frameElement && 394 let sandbox = window.frameElement &&
391 window.frameElement.getAttribute("sandbox"); 395 window.frameElement.getAttribute("sandbox");
392 396
393 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox)) 397 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox))
394 { 398 {
395 let script = document.createElement("script"); 399 let script = document.createElement("script");
396 script.type = "application/javascript"; 400 script.type = "application/javascript";
397 script.async = false; 401 script.async = false;
398 script.textContent = "(" + injected + ")('" + randomEventName + "');"; 402 script.textContent = "(" + injected + ")('" + randomEventName + "');";
399 document.documentElement.appendChild(script); 403 document.documentElement.appendChild(script);
400 document.documentElement.removeChild(script); 404 document.documentElement.removeChild(script);
401 } 405 }
402 } 406 }
OLDNEW

Powered by Google App Engine
This is Rietveld