I’ve been helping a friend with a Google Chrome extension, which makes use of the Chrome localStorage API. The extension checks for a variable and if it doesn’t exist it writes it to the localStorage database. If you’re note aware, the localStorage database is actually an SQLite database.
For testing he needed a way to change this variable outside the extension to exercise different test cases. The goal was to change the variable and run the Chrome extension to see if it behaved as expected. This was accomplished with the following steps:
1. Download Mike Titlebaum’s nifty SQLite database management tool http://saxmike.com/MySoftware/MySoftware.asp?Menu=MYSOFTWARE
2. Open the localStorage database using this tool. The database is actually a file that exists in the user data directory. For Mac users this is located at ~/Library/Application Support/Google/Chrome/Default/Local Storage. The file will be named something like chrome-extension_[Chrome Extension ID]_0.localStorage. For Windows and Linux you can reference this link.
3. To access this file in Mike’s tool you need to “Connect” and navigate to the file in the file browser. Once the file is opened you need to select the “ItemTable” table. You should see a list of key/value pairs underneath the table.
4. Simply click the key/value you want to change and enter the new value. The new value will automatically update after you hit the enter key.
5. Restart Chrome and test the extension with the changed value.
The alternative was to create a “debug” mode for the extension that would allow the variable to be changed, but for the sake of time this was the easiest path to accomplish the task.
Read More