Search code examples
javascriptgoogle-chromegoogle-chrome-extensionweb-sql

Chrome Extension: WebQL database is not appearing in Inspector


I am trying to create database and tables in background.js file of Chrome but somehow it's not being created. When I see in Chrome Inspector > Resources > WebSQL, I find nothing. Code is given below:

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();
}

Update

I guess it's being created: My Extension ID is bkjajbjnoadlhnhmfekipifehbhgidpg In ~/Library/Application Support/Google/Chrome/Default/databases I find:

chrome-extension_bkjajbjnoadlhnhmfekipifehbhgidpg_0

But it's weird I can't see it in Inspector.

Update #2

Turns out that like pages, WebSQL is not visible across Chrome. It shows Db to the page which is visited. Now I am getting no idea how to excess chrome related Db in Viewer.


Solution

  • To access the inspector for the background page of your app, go to Menu>Settings>Extensions and make sure it's in Developer Mode. It should have a link to inspect the background page of your app in there. It will open up in a new window. enter image description here