【发布时间】:2016-03-31 04:20:13
【问题描述】:
我正在尝试在 Chrome 的 background.js 文件中创建数据库和表,但不知何故它没有被创建。当我在 Chrome Inspector > Resources > 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
事实证明,类似页面,WebSQL 在 Chrome 中不可见。它向访问的页面显示 Db。现在我不知道如何在 Viewer 中增加与 chrome 相关的 Db。
【问题讨论】:
标签: javascript google-chrome google-chrome-extension web-sql