Left: | ||
Right: |
OLD | NEW |
---|---|
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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 if (wrapPropertyAccess(window, property, {get: abort, set() {}})) | 752 if (wrapPropertyAccess(window, property, {get: abort, set() {}})) |
753 overrideOnError(rid); | 753 overrideOnError(rid); |
754 } | 754 } |
755 | 755 |
756 exports["abort-on-property-read"] = makeInjector(abortOnPropertyRead, | 756 exports["abort-on-property-read"] = makeInjector(abortOnPropertyRead, |
757 wrapPropertyAccess, | 757 wrapPropertyAccess, |
758 overrideOnError, | 758 overrideOnError, |
759 randomId); | 759 randomId); |
760 | 760 |
761 /** | 761 /** |
762 * Patches a property on the window object to abort execution when the | |
763 * property is written (set). | |
Manish Jethani
2019/01/15 14:13:29
Nit: I don't think "(set)" is necessary, but it's
hub
2019/01/15 16:40:29
I ought it clarify, but then I don't for "read" so
| |
764 * | |
765 * No error is be printed to the console. | |
Manish Jethani
2019/01/15 14:13:30
Correction: No error is printed to the console.
W
hub
2019/01/15 16:40:29
Done.
BTW it is a cut&paste error that is found i
| |
766 * | |
767 * The idea originates from | |
768 * {@link https://github.com/uBlockOrigin/uAssets/blob/80b195436f8f8d78ba713237b fc268ecfc9d9d2b/filters/resources.txt#L1671 uBlock Origin}. | |
769 * | |
770 * @param {string} property The name of the property. | |
771 */ | |
772 function abortOnPropertyWrite(property) | |
773 { | |
774 if (!property) | |
775 return; | |
776 | |
777 let rid = randomId(); | |
778 | |
779 function abort() | |
780 { | |
781 throw new ReferenceError(rid); | |
782 } | |
783 | |
784 if (wrapPropertyAccess(window, property, {set: abort})) | |
Manish Jethani
2019/01/15 14:13:29
Do we need a getter here?
hub
2019/01/15 16:40:30
We don't.
Manish Jethani
2019/01/15 17:24:16
Acknowledged.
| |
785 overrideOnError(rid); | |
786 } | |
787 | |
788 exports["abort-on-property-write"] = makeInjector(abortOnPropertyWrite, | |
789 wrapPropertyAccess, | |
790 overrideOnError, | |
791 randomId); | |
792 | |
793 /** | |
762 * Aborts the execution of an inline script. | 794 * Aborts the execution of an inline script. |
763 * | 795 * |
764 * @param {string} api API function or property name to anchor on. | 796 * @param {string} api API function or property name to anchor on. |
765 * @param {?string} [search] If specified, only scripts containing the given | 797 * @param {?string} [search] If specified, only scripts containing the given |
766 * string are prevented from executing. If the string begins and ends with a | 798 * string are prevented from executing. If the string begins and ends with a |
767 * slash (<code>/</code>), the text in between is treated as a regular | 799 * slash (<code>/</code>), the text in between is treated as a regular |
768 * expression. | 800 * expression. |
769 */ | 801 */ |
770 function abortCurrentInlineScript(api, search = null) | 802 function abortCurrentInlineScript(api, search = null) |
771 { | 803 { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 } | 844 } |
813 }; | 845 }; |
814 | 846 |
815 if (wrapPropertyAccess(object, name, descriptor)) | 847 if (wrapPropertyAccess(object, name, descriptor)) |
816 overrideOnError(rid); | 848 overrideOnError(rid); |
817 } | 849 } |
818 | 850 |
819 exports["abort-current-inline-script"] = | 851 exports["abort-current-inline-script"] = |
820 makeInjector(abortCurrentInlineScript, wrapPropertyAccess, toRegExp, | 852 makeInjector(abortCurrentInlineScript, wrapPropertyAccess, toRegExp, |
821 overrideOnError, regexEscape, randomId); | 853 overrideOnError, regexEscape, randomId); |
OLD | NEW |