In a Chrome Extension I want to ask the user for full access to pages through a browser_action's popup's link (aka a toolbar popup with a link). When the user clicks the link, I get this error:
runtime.lastError while running permissions.request: This function must be called during a user gesture
Yet the user actually clicked the link and the 'user gesture'. Any ideas of how to debug what is considered a user gesture?
On the button click, I request full access via chrome's chrome.permissions.request
api:
$('#button-requestpermissions').click(function(){
requestAmbientPermission(function(granted) {
if (granted) {
// code never reached as granted === false
}
});
});
function requestAmbientPermission(callback){
// Permissions must be requested from inside a user gesture, like a button's click handler.
chrome.permissions.request({
permissions: ['activeTab'],
origins: ['<all_urls>']
}, callback);
}
The manifest has optional permissions set like so:
"permissions": [
"https://www.meethue.com/",
"https://colorlovers.herokuapp.com/"
],
"optional_permissions": [
"activeTab",
"<all_urls>"
],