| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 window.abpTest5 = 42; | 102 window.abpTest5 = 42; |
| 103 await runSnippet(test, "abort-on-property-read", "abpTest5.prop4.bar"); | 103 await runSnippet(test, "abort-on-property-read", "abpTest5.prop4.bar"); |
| 104 | 104 |
| 105 testProperty("abpTest5.prop4.bar", true, "TypeError"); | 105 testProperty("abpTest5.prop4.bar", true, "TypeError"); |
| 106 | 106 |
| 107 window.abpTest5 = {prop4: 42}; | 107 window.abpTest5 = {prop4: 42}; |
| 108 testProperty("abpTest5.prop4.bar", false); | 108 testProperty("abpTest5.prop4.bar", false); |
| 109 window.abpTest5 = {prop4: {}}; | 109 window.abpTest5 = {prop4: {}}; |
| 110 testProperty("abpTest5.prop4.bar"); | 110 testProperty("abpTest5.prop4.bar"); |
| 111 | 111 |
| 112 // Check that it works on properties that are functions. |
| 113 // https://issues.adblockplus.org/ticket/7419 |
| 114 |
| 115 // Existing function (from the API). |
| 116 await runSnippet(test, "abort-on-property-read", "Object.keys"); |
| 117 testProperty("Object.keys"); |
| 118 |
| 119 // Function properties. |
| 120 window.abpTest6 = function() {}; |
| 121 window.abpTest6.prop1 = function() {}; |
| 122 await runSnippet(test, "abort-on-property-read", "abpTest6.prop1"); |
| 123 testProperty("abpTest6.prop1"); |
| 124 |
| 125 // Function properties, with sub-property set afterwards. |
| 126 window.abpTest7 = function() {}; |
| 127 await runSnippet(test, "abort-on-property-read", "abpTest7.prop1"); |
| 128 window.abpTest7.prop1 = function() {}; |
| 129 testProperty("abpTest7.prop1"); |
| 130 |
| 131 // Function properties, with base property as function set afterwards. |
| 132 await runSnippet(test, "abort-on-property-read", "abpTest8.prop1"); |
| 133 window.abpTest8 = function() {}; |
| 134 window.abpTest8.prop1 = function() {}; |
| 135 testProperty("abpTest8.prop1"); |
| 136 |
| 137 // Arrow function properties. |
| 138 window.abpTest9 = () => {}; |
| 139 await runSnippet(test, "abort-on-property-read", "abpTest9"); |
| 140 testProperty("abpTest9"); |
| 141 |
| 142 // Class function properties. |
| 143 window.abpTest10 = class {}; |
| 144 await runSnippet(test, "abort-on-property-read", "abpTest10"); |
| 145 testProperty("abpTest10"); |
| 146 |
| 147 // Class function properties with prototype function properties. |
| 148 window.abpTest11 = class {}; |
| 149 window.abpTest11.prototype.prop1 = function() {}; |
| 150 await runSnippet(test, "abort-on-property-read", "abpTest11.prototype.prop1"); |
| 151 testProperty("abpTest11.prototype.prop1"); |
| 152 |
| 153 // Class function properties with prototype function properties, with |
| 154 // prototype property set afterwards. |
| 155 window.abpTest12 = class {}; |
| 156 await runSnippet(test, "abort-on-property-read", "abpTest12.prototype.prop1"); |
| 157 window.abpTest12.prototype.prop1 = function() {}; |
| 158 testProperty("abpTest12.prototype.prop1"); |
| 159 |
| 112 test.done(); | 160 test.done(); |
| 113 }; | 161 }; |
| 114 | 162 |
| 115 exports.testAbortCurrentInlineScriptSnippet = async function(test) | 163 exports.testAbortCurrentInlineScriptSnippet = async function(test) |
| 116 { | 164 { |
| 117 function injectInlineScript(doc, script) | 165 function injectInlineScript(doc, script) |
| 118 { | 166 { |
| 119 let scriptElement = doc.createElement("script"); | 167 let scriptElement = doc.createElement("script"); |
| 120 scriptElement.type = "application/javascript"; | 168 scriptElement.type = "application/javascript"; |
| 121 scriptElement.async = false; | 169 scriptElement.async = false; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 231 |
| 184 if (e && msg) | 232 if (e && msg) |
| 185 { | 233 { |
| 186 test.equals(e.textContent, "", "result element should be empty"); | 234 test.equals(e.textContent, "", "result element should be empty"); |
| 187 test.equals(msg.textContent, "ReferenceError", | 235 test.equals(msg.textContent, "ReferenceError", |
| 188 "There should have been an error"); | 236 "There should have been an error"); |
| 189 } | 237 } |
| 190 | 238 |
| 191 test.done(); | 239 test.done(); |
| 192 }; | 240 }; |
| OLD | NEW |