2020-02-03 22:01:10 +00:00
|
|
|
/* global chrome */
|
|
|
|
function testStorageClear (callback) {
|
|
|
|
chrome.storage.sync.clear(function () {
|
|
|
|
chrome.storage.sync.get(null, function (syncItems) {
|
|
|
|
chrome.storage.local.clear(function () {
|
|
|
|
chrome.storage.local.get(null, function (localItems) {
|
2020-03-20 20:28:31 +00:00
|
|
|
callback(syncItems, localItems);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-02-03 22:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testStorageRemove (callback) {
|
|
|
|
chrome.storage.sync.remove('bar', function () {
|
|
|
|
chrome.storage.sync.get({ foo: 'baz' }, function (syncItems) {
|
|
|
|
chrome.storage.local.remove(['hello'], function () {
|
|
|
|
chrome.storage.local.get(null, function (localItems) {
|
2020-03-20 20:28:31 +00:00
|
|
|
callback(syncItems, localItems);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-02-03 22:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testStorageSet (callback) {
|
|
|
|
chrome.storage.sync.set({ foo: 'bar', bar: 'foo' }, function () {
|
|
|
|
chrome.storage.sync.get({ foo: 'baz', bar: 'fooo' }, function (syncItems) {
|
|
|
|
chrome.storage.local.set({ hello: 'world', world: 'hello' }, function () {
|
|
|
|
chrome.storage.local.get(null, function (localItems) {
|
2020-03-20 20:28:31 +00:00
|
|
|
callback(syncItems, localItems);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-02-03 22:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testStorage (callback) {
|
|
|
|
testStorageSet(function (syncForSet, localForSet) {
|
|
|
|
testStorageRemove(function (syncForRemove, localForRemove) {
|
|
|
|
testStorageClear(function (syncForClear, localForClear) {
|
|
|
|
callback(
|
|
|
|
syncForSet, localForSet,
|
|
|
|
syncForRemove, localForRemove,
|
|
|
|
syncForClear, localForClear
|
2020-03-20 20:28:31 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-02-03 22:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testStorage(function (
|
|
|
|
syncForSet, localForSet,
|
|
|
|
syncForRemove, localForRemove,
|
|
|
|
syncForClear, localForClear
|
|
|
|
) {
|
2021-11-04 18:00:28 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
const message = JSON.stringify({
|
|
|
|
runtimeId: chrome.runtime.id,
|
|
|
|
tabId: chrome.devtools.inspectedWindow.tabId,
|
|
|
|
i18nString: chrome.i18n.getMessage('foo', ['bar', 'baz']),
|
|
|
|
storageItems: {
|
|
|
|
local: {
|
|
|
|
set: localForSet,
|
|
|
|
remove: localForRemove,
|
|
|
|
clear: localForClear
|
|
|
|
},
|
|
|
|
sync: {
|
|
|
|
set: syncForSet,
|
|
|
|
remove: syncForRemove,
|
|
|
|
clear: syncForClear
|
|
|
|
}
|
2020-02-03 22:01:10 +00:00
|
|
|
}
|
2021-11-04 18:00:28 +00:00
|
|
|
});
|
2020-02-03 22:01:10 +00:00
|
|
|
|
2021-11-04 18:00:28 +00:00
|
|
|
const sendMessage = `require('electron').ipcRenderer.send('answer', ${message})`;
|
|
|
|
window.chrome.devtools.inspectedWindow.eval(sendMessage, function () {});
|
|
|
|
});
|
2020-03-20 20:28:31 +00:00
|
|
|
});
|