Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Firefox] new content types for nsIContentPolicy #916

Closed
lewisje opened this issue Nov 7, 2015 · 2 comments
Closed

[Firefox] new content types for nsIContentPolicy #916

lewisje opened this issue Nov 7, 2015 · 2 comments

Comments

@lewisje
Copy link

lewisje commented Nov 7, 2015

I noticed in Firefox 42 that there is a new TYPE_EMBED as distinct from TYPE_OBJECT (and the tracking bug also mentioned the long-deprecated APPLET), and that SUBDOCUMENT was split into FRAME and IFRAME (and maybe IMPORT for HTML Imports, I know that was mentioned in the tracking bug): https://developer.mozilla.org/en-US/Firefox/Releases/42#nsIContentPolicy

I realize that you have probably already seen this change, because Firefox 42 Nightly builds started appearing months ago, but I'm surprised to see all the types that have been added to nsIContentPolicy over the years: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy

I wonder whether uBlock Origin for Firefox will support new filter syntax to specially handle these new content types, or maybe just (for consistency with the other platforms) merge them with the existing request-type selectors, like mapping FRAME, IFRAME, and IMPORT to subdocument, EMBED to object, IMAGESET to image, FETCH and BEACON to xmlhttprequest, etc. (or maybe some of these are just mapped to other).

@gorhill
Copy link
Owner

gorhill commented Nov 7, 2015

or maybe just (for consistency with the other platforms) merge them with the existing request-type selectors

It's already done by Firefox, so as far as uBO is concerned, there is no action to be taken, unless one of the new types is worth distinguishing for filtering purpose. Everything which does not translate into a normal type is categorized ultimately as a request of type other.

For example, I did investigate not long ago what was happening on wired.com, as I observed that for every single HTTP request to images, there were two nsIContentPolicy.shouldLoad fired. Eventually found out one shouldLoad was for TYPE_IMAGE, and another for TYPE_IMAGESET -- so Firefox ensure backward compatibility. Ultimately since uBO evaluate at HTTP observer level, only one filtering evaluation is performed (hence why they do not appear twice in the logger), even though shouldLoad may fire multiple times for one single element.

@lewisje
Copy link
Author

lewisje commented Nov 7, 2015

It took a while for me to notice (searching the codebase for IMAGESET found nothing), but I now see how you've merged imageset into image (by mapping the numeric constants 3 and 21, respectively meaning TYPE_IMAGE and TYPE_IMAGESET, to `'image'); also I wasn't aware that websocket and beacon are now request-type options.

I noticed that the ABP source code does not appear to do this with imageset (and it does not treat websocket or beacon specially, so if those type options even work in uBlock Origin, they're not suitable for public filter-lists), and the Firefox source code appears to hide embed, iframe, and frame as internal details, mapping them to the existing content types.

Also, the less accessible and little worked-on code for AdBlock for Firefox hasn't been keeping up to date with the changes in nsIContentPolicy, even going so far as to use a custom "TYPE_CSSIMAGE" constant that is now used by TYPE_INTERNAL_VIDEO (31) and in particular it does not appear to do anything special with imageset.

@gorhill gorhill closed this as completed Nov 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants