This question and
your early question are related to whether localStorage data is shared between top-level frame and iframe.
You can test it by enabling chrome://flags/#third-party-storage-partitioning
1. In old mode (not partitioning storage)
iframes in different websites and itself as a top-level website are shared data in localStorage.
2. In new mode (partitioning storage)
a) for regular websites
localStorage data are not shared. They are different storage instances.
b) for extension pages
there are two cases:
- a website embed an extension page as an iframe
- an extension page embed a website page as an iframe
That article says:
If the extension has host_permissions for the iframe origin, then the iframe will be treated as the top-level frame and not the extension page. If an extension embeds an iframe with an extension URL into a top-level site with host permissions, the iframe will be treated as first-party with the extension rather than partitioned by the top-level site.
That means sharing or not sharing data (partitioning or not partitioning storage) depends on whether the extension has the website's host permission.