Display of blocked embeds inconsistent, size is different from embed that didn't load

NEW
Unassigned

Status

()

Core
Image Blocking
7 years ago
6 years ago

People

(Reporter: Wladimir Palant (for Adblock Plus info Cc bugzilla@adblockplus.org), Unassigned)

Tracking

(Blocks: 1 bug)

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

Created attachment 553699 [details]
Testcase

Users reported that blocking a Flash embed on some sites unexpectedly messes up page layout. Turns out that the size of the embed is set to 0x18 despite width and height attributes being specified - it is treated as an inline element without content rather than an inline block. After looking into this, the problem appears to be that nsObjectLoadingContent::HandleBeingBlockedByContentPolicy() calls UnloadContent() which will not only cancel the load but also reset mType - so the embed is treated like one without a type, not like one where the load failed.

Attaching a testcase with two embeds: one loading from example.com and the other loading from example.info. You should install the test content policy (next attachment) which will block the first embed while the other simply fails to load. Note that the latter keeps its size while the former doesn't.

Tested in Firefox 3.6, 4 and 2011-08-16 nightly build.
Created attachment 553701 [details]
Minimal content policy for testing

This minimal extension should be installed before opening the testcase - all it does is blocking object requests going to http://example.com/ (this is easier than setting up Adblock Plus to test this issue).
> not like one where the load failed.

The difference is that for <embed> in particular we instantiate the plug-in and create an nsObjectFrame before we know whether the load fails, then the plugin code handles the load.  So we end up with an nsObjectFrame no matter what.

Can an nsObjectFrame deal without a plug-in being instantiated and more importantly without _trying_ to instantiate it?  Alternately, I suppose we could treat TYPE_NULL the same as TYPE_LOADING for <embed> in some cases... except it might break the plugin-finder thing.

The simplest solution for this issue from your end is to simply style blocked embeds as inline-block in the UA stylesheet, I'd think, if you actually want to preserve their size in the layout.
(In reply to Boris Zbarsky (:bz) from comment #2)
> The simplest solution for this issue from your end is to simply style
> blocked embeds as inline-block in the UA stylesheet, I'd think, if you
> actually want to preserve their size in the layout.

That isn't something that I can do because a rule like this would be easily detectable by any webpage. With an extension like Adblock Plus, changing the default behavior is not an option.
Web pages can already use CSS to detect whether the <embed> is blocked or not, no?
No, if blocking reason is nsIContentPolicy.REJECT_REQUEST they cannot.
Ah, indeed.

So is this something you just want for <embed> or for <object> too?  Presumably just the former?
Yes, the behavior should be consistent of course.
You need to log in before you can comment on or make changes to this bug.