Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 if (currentDescriptor && !currentDescriptor.configurable) | 514 if (currentDescriptor && !currentDescriptor.configurable) |
515 return false; | 515 return false; |
516 | 516 |
517 Object.defineProperty(object, property, descriptor); | 517 Object.defineProperty(object, property, descriptor); |
518 return true; | 518 return true; |
519 } | 519 } |
520 | 520 |
521 /** | 521 /** |
522 * Patches a property on the window object to abort execution when the | 522 * Patches a property on the window object to abort execution when the |
523 * property is read. | 523 * property is read. |
524 * No error will be printed in the console. | 524 * |
Manish Jethani
2018/10/31 19:54:49
Nit: Again, is the "No error will be printed" part
Manish Jethani
2018/10/31 19:54:49
Nit: Even though it doesn't matter to the generate
hub
2018/10/31 20:44:16
Done.
hub
2018/10/31 20:44:17
Done.
| |
525 * No error is be printed to the console. | |
526 * | |
525 * The idea originates from | 527 * The idea originates from |
Manish Jethani
2018/10/31 19:54:49
Nit: Period at the end of the sentence.
hub
2018/10/31 20:44:16
Done.
| |
526 * {@link https://github.com/uBlockOrigin/uAssets/blob/80b195436f8f8d78ba713237b fc268ecfc9d9d2b/filters/resources.txt#L1703 uBlock Origin} | 528 * {@link https://github.com/uBlockOrigin/uAssets/blob/80b195436f8f8d78ba713237b fc268ecfc9d9d2b/filters/resources.txt#L1703 uBlock Origin}. |
527 * | 529 * |
528 * @param {string} property The name of the property. | 530 * @param {string} property The name of the property. |
529 */ | 531 */ |
530 function abortOnPropertyRead(property) | 532 function abortOnPropertyRead(property) |
531 { | 533 { |
532 if (!property) | 534 if (!property) |
533 return; | 535 return; |
534 | 536 |
535 let rid = randomId(); | 537 let rid = randomId(); |
536 | 538 |
537 function abort() | 539 function abort() |
538 { | 540 { |
539 throw new ReferenceError(rid); | 541 throw new ReferenceError(rid); |
540 } | 542 } |
541 | 543 |
544 let {onerror} = window; | |
542 if (wrapPropertyAccess(window, property, {get: abort, set() {}})) | 545 if (wrapPropertyAccess(window, property, {get: abort, set() {}})) |
543 { | 546 { |
544 let {onerror} = window; | |
Manish Jethani
2018/10/31 19:38:16
Can we move this line outside the if block? In the
hub
2018/10/31 20:44:16
It can be moved.
But it would still bomb if it wa
Manish Jethani
2018/10/31 20:52:22
Alright, fair enough.
| |
545 window.onerror = (message, ...rest) => | 547 window.onerror = (message, ...rest) => |
546 { | 548 { |
547 if (typeof message == "string" && message.includes(rid)) | 549 if (typeof message == "string" && message.includes(rid)) |
548 return true; | 550 return true; |
549 if (typeof onerror == "function") | 551 if (typeof onerror == "function") |
550 return (() => {}).call.call(onerror, this, message, ...rest); | 552 return (() => {}).call.call(onerror, this, message, ...rest); |
551 }; | 553 }; |
552 } | 554 } |
553 } | 555 } |
554 | 556 |
555 exports["abort-on-property-read"] = makeInjector(abortOnPropertyRead, | 557 exports["abort-on-property-read"] = makeInjector(abortOnPropertyRead, |
556 wrapPropertyAccess, | 558 wrapPropertyAccess, |
557 randomId); | 559 randomId); |
LEFT | RIGHT |