Last active
May 17, 2016 17:42
-
-
Save kzar/f455d61db57628578367962b8c888d17 to your computer and use it in GitHub Desktop.
Safari bug 26322821 - safari.extension.setContentBlocker breaks when passed callback function when rules aren't converted to JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: | |
safari.extension.setContentBlocker does not appear to work at all when passed a callback function except if the rules are first converted to JSON. If the rules are not converted to JSON the callback is performed twice, first with an empty string and then with an Error "Extension compilation failed: Failed to parse the JSON String.". Further calls to the function with anything but JSON also causes two callbacks first an empty string and then null. | |
If the callback is not passed, or if the rules are converted to JSON things seem to work as I expect. | |
Steps to Reproduce: | |
safari.extension.setContentBlocker([{ | |
"trigger": { | |
"url-filter": "evil-tracker\\.js" | |
}, | |
"action": { | |
"type": "block" | |
} | |
}], function (result) { console.log("Callback", result); }); | |
Expected Results: | |
Callback performed once with the result of null. Content blocking to work. | |
Actual Results: | |
Callback performed twice, firstly with an empty string "" and then with an Error "Extension compilation failed: Failed to parse the JSON String.". | |
Version: | |
OS X 10.11 | |
Safari 9.0 (11601.1.56) | |
Notes: | |
This is hindering us supporting the content blocking API in Adblock Plus for Safari https://codereview.adblockplus.org/29340571/ | |
Configuration: | |
Attachments: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also reproduced with Safari Version 9.1 (11601.5.17.1)