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

Side by Side Diff: include.preload.js

Issue 29349749: Issue 4191 - Check shadowRoot getter exists before wrapping (Closed)
Patch Set: Created Aug. 11, 2016, 3:32 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // 450 //
451 // Also, using shadow DOM causes issues on some Google websites, 451 // Also, using shadow DOM causes issues on some Google websites,
452 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687). 452 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687).
453 if ("createShadowRoot" in document.documentElement && 453 if ("createShadowRoot" in document.documentElement &&
454 !/\.(?:google|blogger)\.com$/.test(document.domain)) 454 !/\.(?:google|blogger)\.com$/.test(document.domain))
455 { 455 {
456 shadow = document.documentElement.createShadowRoot(); 456 shadow = document.documentElement.createShadowRoot();
457 shadow.appendChild(document.createElement("shadow")); 457 shadow.appendChild(document.createElement("shadow"));
458 458
459 // Stop the website from messing with our shadowRoot 459 // Stop the website from messing with our shadowRoot
460 runInDocument(document, function() 460 if ("shadowRoot" in Element.prototype)
461 { 461 {
462 var ourShadowRoot = document.documentElement.shadowRoot; 462 runInDocument(document, function()
463 var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoot" ); 463 {
464 var shadowRoot = Function.prototype.call.bind(desc.get); 464 var ourShadowRoot = document.documentElement.shadowRoot;
465 var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoo t");
466 var shadowRoot = Function.prototype.call.bind(desc.get);
465 467
466 Object.defineProperty(Element.prototype, "shadowRoot", { 468 Object.defineProperty(Element.prototype, "shadowRoot", {
467 conifgurable: true, enumerable: true, get: function() 469 conifgurable: true, enumerable: true, get: function()
468 { 470 {
469 var shadow = shadowRoot(this); 471 var shadow = shadowRoot(this);
470 return shadow == ourShadowRoot ? null : shadow; 472 return shadow == ourShadowRoot ? null : shadow;
471 } 473 }
472 }); 474 });
473 }, null); 475 }, null);
476 }
474 } 477 }
475 478
476 function addElemHideSelectors(selectors) 479 function addElemHideSelectors(selectors)
477 { 480 {
478 if (selectors.length == 0) 481 if (selectors.length == 0)
479 return; 482 return;
480 483
481 if (!style) 484 if (!style)
482 { 485 {
483 // Create <style> element lazily, only if we add styles. Add it to 486 // Create <style> element lazily, only if we add styles. Add it to
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 }, true); 611 }, true);
609 612
610 return updateStylesheet; 613 return updateStylesheet;
611 } 614 }
612 615
613 if (document instanceof HTMLDocument) 616 if (document instanceof HTMLDocument)
614 { 617 {
615 checkSitekey(); 618 checkSitekey();
616 window.updateStylesheet = init(document); 619 window.updateStylesheet = init(document);
617 } 620 }
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