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

Delta Between Two Patch Sets: include.preload.js

Issue 29394585: Issue 5027 - Use updated webRequest API for WebSocket blocking (Closed)
Left Patch Set: addresses bad comments, and actually fixes requestBlocker logic Created March 28, 2017, 7:18 p.m.
Right Patch Set: change commit message, add chrome version to include.preload.js comments Created March 29, 2017, 12:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « chrome/ext/background.js ('k') | lib/csp.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 function runInPageContext(fn, arg) 335 function runInPageContext(fn, arg)
336 { 336 {
337 let script = document.createElement("script"); 337 let script = document.createElement("script");
338 script.type = "application/javascript"; 338 script.type = "application/javascript";
339 script.async = false; 339 script.async = false;
340 script.textContent = "(" + fn + ")(" + JSON.stringify(arg) + ");"; 340 script.textContent = "(" + fn + ")(" + JSON.stringify(arg) + ");";
341 document.documentElement.appendChild(script); 341 document.documentElement.appendChild(script);
342 document.documentElement.removeChild(script); 342 document.documentElement.removeChild(script);
343 } 343 }
344 344
345 // Chrome doesn't allow us to intercept WebSockets[1], and therefore 345 // Before Chrome 58 the webRequest API didn't allow us to intercept
346 // some ad networks are misusing them as a way to serve adverts and circumvent 346 // WebSockets[1], and therefore some ad networks are misusing them as a way to
347 // us. As a workaround we wrap WebSocket, preventing blocked WebSocket 347 // serve adverts and circumvent us. As a workaround we wrap WebSocket,
348 // connections from being opened. 348 // preventing blocked WebSocket connections from being opened.
349 // [1] - https://bugs.chromium.org/p/chromium/issues/detail?id=129353 349 // [1] - https://bugs.chromium.org/p/chromium/issues/detail?id=129353
350 function wrapWebSocket() 350 function wrapWebSocket()
351 { 351 {
352 let eventName = "abpws-" + Math.random().toString(36).substr(2); 352 let eventName = "abpws-" + Math.random().toString(36).substr(2);
353 353
354 document.addEventListener(eventName, event => 354 document.addEventListener(eventName, event =>
355 { 355 {
356 ext.backgroundPage.sendMessage({ 356 ext.backgroundPage.sendMessage({
357 type: "request.websocket", 357 type: "request.websocket",
358 url: event.detail.url 358 url: event.detail.url
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 checkCollapse(event.target); 583 checkCollapse(event.target);
584 }, true); 584 }, true);
585 585
586 document.addEventListener("load", event => 586 document.addEventListener("load", event =>
587 { 587 {
588 let element = event.target; 588 let element = event.target;
589 if (/^i?frame$/.test(element.localName)) 589 if (/^i?frame$/.test(element.localName))
590 checkCollapse(element); 590 checkCollapse(element);
591 }, true); 591 }, true);
592 } 592 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld