在 Firefox 的 iframe 中使用 PouchDB 访问本地存储

Accessing local storage using PouchDB from within iframe in firefox

我正在使用 pouchDB,我正在尝试从跨域 iframe 中访问本地存储(同源) 这在 chrome 中运行良好,但在 firefox 中运行不正常。

澄清一下:我在 "foobar.com" 上,我加载了一个包含我的 html 的 iframe,其来源 "test.com" 而这个 html 正试图访问它自己的本地存储即具有相同的来源 "test.com".

举个例子,我从我的服务器

提供了这个HTML
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>test page</title>
</head>
<script type="text/javascript" src="pouchdb-5.1.0.min.js"></script>
<body>    
    <button id="create">create db</button>
    <button id="read">read records</button>
</body>

<script>
       document.getElementById('create').addEventListener('click', createDB, false);
       document.getElementById('read').addEventListener('click', readDB, false);

       function createDB(){
              db = new PouchDB('noobDB');
              console.log(db.adapter);
       }

       function readDB(){
              db = new PouchDB('noobDB');
              db.allDocs({include_docs : true})
                .then(function(result){console.log(result)})
                .catch(function(err){console.log(err)});
       }
</script>

在火狐中;当我在主浏览器 window 中加载此 html 并创建和检索记录时,一切正常,但是当我在 iframe 中加载此 html 页面并尝试读取记录时,它不会工作。

但是在 chrome 中,当我在 iframe 中加载此 HTML 并读取记录时,它工作正常。

无法从 firefox 的 iframe 中读取记录(以及与本地数据库相关的其他操作)的原因是什么

这是 firefox 的一个问题,它无法从 iframe 访问 indexedDB。 此问题已在最新版本的 mozilla firefox 中得到解决,即 v43.0.4