Attempting to integrate AngularJS into a Chrome extension, I encountered the following error:
Error: SECURITY_ERR: DOM Exception 18
Error: An attempt was made to break through the security policy of the user agent.
at new listConnection
manifest.json :
{
"name": "Secure Chrome Connection",
"version": "1",
"icons": { "48": "icon.png",
"128": "icon.png" },
"description": "Secure Chrome Connection is an extension for Google Chrome browser. It ensures secure profile connections.",
"background": {
"scripts": [
"chrome_ex_oauthsimple.js",
"chrome_ex_oauth.js",
"background.js"
]
},
"browser_action": {
"default_title": "Secure Chrome Connection",
"default_icon": "icon.png",
"default_popup": "index.html"
},
"permissions": [
"storage"
],
"web_accessible_resources": ["index.html"],
"sandbox": {
"pages": ["index.html","index.js","angular.min.js"]
},
"manifest_version": 2
}
index.js :
function listConnection( $scope) {
$scope.connections = JSON.parse(localStorage['connectionHistory']);
}
The issue seems to be with the JSON.parse() function being blocked by Chrome's Content Security Policy (CSP).
Does anyone have a solution?