Chrome扩展程序:检查器中未显示WebQL数据库

时间:2016-03-31 04:20:14

标签: javascript google-chrome google-chrome-extension web-sql

我正在尝试在Chrome的background.js文件中创建数据库和表格,但不知何故它没有被创建。当我在Chrome Inspector中看到>资源> WebSQL,我一无所获。代码如下:

function fetchData(){

    var xhr = new XMLHttpRequest();
    xhr.open("GET", "http://localhost/php/fetch.php", true);
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
            // JSON.parse does not evaluate the attacker's scripts.
            var resp = xhr.responseText;
            if(resp != null) {
                var json = JSON.parse(resp)
                console.log(resp);
                var data = json['data'];
                if(data != null) {
                    openDatabase('documents', '1.0', 'my storage', 5*1024*1024, function (db) {
                        alert('Called'); //This is not being called. 
                    });
                    //var dbConnection = openDbConnect();
                    //createTable(dbConnection);
                    //Code below is called
                    for(var a=0;a <= data.length;a++) {
                        alert(data[a].title);
                    }
                }

            }

        }
    }
    xhr.send();
}

更新

我猜它正在创建:我的扩展程序ID为bkjajbjnoadlhnhmfekipifehbhgidpg~/Library/Application Support/Google/Chrome/Default/databases我找到了:

chrome-extension_bkjajbjnoadlhnhmfekipifehbhgidpg_0

但我在Inspector中看不到它很奇怪。

更新#2

事实证明,在Chrome浏览器中看不到类似的网页WebSQL。它显示Db到访问的页面。现在我不知道如何在Viewer中过多的铬相关Db。

1 个答案:

答案 0 :(得分:1)

要访问应用背景页面的检查员,请转到菜单&gt;设置&gt;扩展程序,并确保它处于开发者模式。它应该有一个链接来检查应用程序的背景页面。它将在新窗口中打开。 enter image description here

相关问题