Closed Bug 1560580 Opened 5 years ago Closed 4 years ago

Isolate Font Cache by OriginAttributes

Categories

(Core :: Layout: Text and Fonts, task, P3)

task

Tracking

()

RESOLVED DUPLICATE of bug 1647732

People

(Reporter: tjr, Unassigned)

References

(Blocks 3 open bugs)

Details

(Whiteboard: [tor])

Attachments

(1 file)

There is a pref gfx.downloadable_fonts.disable_cache which disables the font cache. Ideally we would isolate this cache by Origin Attributes.

Currently we isolate it with a hash key here: https://searchfox.org/mozilla-central/rev/c0ca77697c6868482f30af873ec8069f2c080a34/gfx/thebes/gfxUserFontSet.h#398-410

But the principal does not, as far as I can tell, take into account OriginAttributes. Isolating by OriginAttributes would also remove the need for the Private Browsing ID

Bugbug thinks this bug is a task, but please change it back in case of error.

Type: defect → task

Can you provide a testcase for this? (This really isn't an area I know much about.) It looks like we could easily add an OriginAttributes comparison to gfxFontSrcPrincipal::Equals to make them compare as unequal if the attrs differ; would that resolve this issue?

Priority: -- → P3
Flags: needinfo?(tom)

Actually, gfxFontSrcPrincipal::Equals() already checks OAs. See here, we use BasePrincipal::FastEquals() to check equality and it also checks the originSuffix, which is the OAs. However, the hash doesn't take the OAs into account because this hash is generated by nsIPrincipal::GetHashValue() and it only respects the domain of the principal.

So, I think we also need to change the hash to include the OAs for isolating the font cache.

Flags: needinfo?(tom)

(In reply to Jonathan Kew (:jfkthame) from comment #2)

Can you provide a testcase for this? (This really isn't an area I know much about.) It looks like we could easily add an OriginAttributes comparison to gfxFontSrcPrincipal::Equals to make them compare as unequal if the attrs differ; would that resolve this issue?

I have a simple WIP patch of this, but I don't know much about how to test it under gfx's world.

My idea is creating a page http://foo.com/custom_font.html containing a custom font embedded by both http://a.com/test_font_cache.html and http://b.com/test_font_cache.html.
The font should be isolated in different cache.

Jonathan, could you give me some idea how to write a test on fonts' side? Is there any existing test for font cache?

Flags: needinfo?(jfkthame)

I don't remember in detail exactly what it's doing, but you might be able to use ideas from layout/style/test/test_redundant_font_download.html, which uses a custom .sjs server to provide a webfont resource and keep track of what requests have been made. That sort of technique should allow you to check whether a resource is being used from cache or requested separately for each origin, I think.

Flags: needinfo?(jfkthame)
See Also: → 1647732

This is my (WIP) patch of adding origin attributes to the hash for the UserFontCache, but I don't have a working test. Anyone is welcome to continue the work.

We're going to isolate network cache of font on bug 1647732.

The patch has landed in bug 1647732.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE

In bug 1647732, I don't see any reference to first party isolation; nor a test for it. When FPI is enabled, is the Font Cache isolated; or is it only when dFPI is enabled?

Flags: needinfo?(xeonchen)

The test was added in here. And it tests originAttributes in general. So, I believe it works for both FPI and dFPI.

Flags: needinfo?(xeonchen)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: