var menuId = 'my_id'
chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason == 'install') {
chrome.contextMenus.create(
{title: 'Extension Item', id: menuId},
function() {
if (!chrome.runtime.lastError) {
chrome.test.notifyPass();
} else {
chrome.test.notifyFail(chrome.runtime.lastError.message);
}
}
);
}
});
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (tab.url != 'chrome://version/')
return;
chrome.contextMenus.update(
menuId, {title: 'Extension Item Updated'},
function() {
if (!chrome.runtime.lastError) {
chrome.test.notifyPass();
} else {
chrome.test.notifyFail(chrome.runtime.lastError.message);
}
}
);
});