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

Side by Side Diff: inject.preload.js

Issue 29807586: Issue 6744 - Fixed wrapper injection on Chrome 67 (Closed)
Patch Set: Created June 14, 2018, 8:53 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 357
358 if (document instanceof HTMLDocument) 358 if (document instanceof HTMLDocument)
359 { 359 {
360 let sandbox = window.frameElement && 360 let sandbox = window.frameElement &&
361 window.frameElement.getAttribute("sandbox"); 361 window.frameElement.getAttribute("sandbox");
362 362
363 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox)) 363 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox))
364 { 364 {
365 let script = document.createElement("script"); 365 let script = document.createElement("script");
366 let code = "(" + injected + ")('" + randomEventName + "');";
367
366 script.type = "application/javascript"; 368 script.type = "application/javascript";
367 script.async = false; 369 script.async = false;
368 // Firefox 58 only bypasses site CSPs when assigning to 'src'. 370
369 let url = URL.createObjectURL(new Blob([ 371 // Firefox 58 only bypasses site CSPs when assigning to 'src',
370 "(" + injected + ")('" + randomEventName + "');" 372 // while Chrome 67 only bypasses site CSPs when using 'textContent'.
371 ])); 373 if (browser.runtime.getURL("").startsWith("chrome-extension://"))
Sebastian Noack 2018/06/14 21:03:09 FWIW, I'm not too happy with this check, but I don
kzar 2018/06/15 07:52:07 Acknowledged.
372 script.src = url; 374 {
373 document.documentElement.appendChild(script); 375 script.textContent = code;
376 document.documentElement.appendChild(script);
377 }
378 else
379 {
380 let url = URL.createObjectURL(new Blob([code]));
381 script.src = url;
382 document.documentElement.appendChild(script);
383 URL.revokeObjectURL(url);
384 }
385
374 document.documentElement.removeChild(script); 386 document.documentElement.removeChild(script);
375 URL.revokeObjectURL(url);
376 } 387 }
377 } 388 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld