Safari iframe storage issue

Explanation

For security issue, browsers will block different main frames to access the same iframe localStorage. However, the same main frame should keep its own iframe localStorage.

Expected

We assume that page X are embedded by site A & site B. There are some steps to do:

  1. Go to site A and do some actions to change localStorage in page X
  2. Close site A (close browser / webview) completely
  3. open site A to see the changes in embedded page X
  4. open site B to see the changes in embedded page X
  5. open page X to see the changes

I expect there are data when revisit the site A.

Actual

In iOS webview, there is no data changes when revisit the site A.

Environment

Safari ~

Playground

Your user agent:

There are 3 pages that you can do experiment.


Result Matrix

save ok, load ok
save ok, load empty
⚠️
throw DOMException
\ A->A A->B A->X X->A X->X
Desktop Firefox non-private
Desktop Firefox private ✅ (revisit tab) ✅ (revisit tab)
Desktop Chromium non-incognito
Desktop Chromium incognito ⚠️ ⚠️ ⚠️ ⚠️ ✅ (revisit tab)
Desktop Safari non-private ✅ (revisit tab) ⭕ (relaunch browser) ✅ (revisit tab) ✅ (relaunch browser)
Desktop Safari private ⭕ (revisit tab)
Mobile Safari non-private ✅ (revisit tab) ⭕ (relaunch browser) ✅ (revisit tab) ✅ (relaunch browser)
Mobile Safari private ⭕ (revisit tab) ⭕ (revisit tab)
Mobile iOS webview (Line) ✅ (revisit page) ✅ (revisit webview) ⭕ (relaunch app) ✅ (revisit page) ✅ (revisit webview) ✅ (relaunch app)