Skip to content

Commit 8a96929

Browse files
jhen0409zalmoxisus
authored andcommitted
Add chrome.storage.local.remove mock for Electron (#252)
1 parent ef55fe9 commit 8a96929

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/browser/extension/chromeAPIMock.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if (
3838
}
3939

4040
if (window.isElectron) {
41-
if (!chrome.storage.local) {
41+
if (!chrome.storage.local || !chrome.storage.local.remove) {
4242
chrome.storage.local = {
4343
set(obj, callback) {
4444
Object.keys(obj).forEach(key => {
@@ -56,6 +56,19 @@ if (window.isElectron) {
5656
if (callback) {
5757
callback(result);
5858
}
59+
},
60+
// Electron ~ 1.4.6
61+
remove(items, callback) {
62+
if (!Array.isArray(items)) {
63+
items.forEach(name => {
64+
localStorage.removeItem(name);
65+
});
66+
} else {
67+
localStorage.removeItem(items);
68+
}
69+
if (callback) {
70+
callback();
71+
}
5972
}
6073
};
6174
}

0 commit comments

Comments
 (0)