分享一道今天面试遇到的面试题,前端开发相关

查看 6|回复 0
作者:Zhuzhuchenyan   
给定一个 host.html
host

其中 sandbox.html
sandbox
其中 inner.html
inner
问:试分析localStorage.getItem('no_such_key')的行为
我的回答:这大概率会抛出一个 SecurityError ,我的映像里因为 sandbox 的缘故 iframe 里面的网页浏览器是不会指定 origin 的。没有 origin 的话大概率 localstorage, session storage, index db 这一类都不可用
Follow up
[ol]
  • iframe src 和 iframe origin 的关系
  • sandbox 里哪个属性控制这个行为?
  • 在 inner html 里类似 fetch(..., { credentials: "include" })请求在哪些情况会带上 cookie
    [/ol]
  • 您需要登录后才可以回帖 登录 | 立即注册

    返回顶部