Skip to content

Commit

Permalink
fix(CSP): update to the latest CSP api
Browse files Browse the repository at this point in the history
window.SecurityPolicy is now window.securityPolicy

since this is available only in Chrome Canary which has already been
updated, we can safely make this change without worrying about
backwards compatilibty.

Closes angular#1577
  • Loading branch information
IgorMinar committed Nov 15, 2012
1 parent bd524fc commit f8f2923
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ng/sniffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function $SnifferProvider() {

return eventSupport[event];
},
csp: document.SecurityPolicy ? document.SecurityPolicy.isActive() : false
csp: ('securityPolicy' in document) ? document.securityPolicy.isActive : false
};
}];
}
6 changes: 3 additions & 3 deletions test/ng/snifferSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ describe('$sniffer', function() {


describe('csp', function() {
it('should be false if document.SecurityPolicy.isActive not available', function() {
it('should be false if document.securityPolicy.isActive not available', function() {
expect(sniffer({}, {}).csp).toBe(false);
});


it('should use document.SecurityPolicy.isActive() if available', function() {
it('should use document.securityPolicy.isActive if available', function() {
var createDocumentWithCSP = function(csp) {
return {SecurityPolicy: {isActive: function() {return csp;}}};
return {securityPolicy: {isActive: csp}};
};

expect(sniffer({}, createDocumentWithCSP(false)).csp).toBe(false);
Expand Down

0 comments on commit f8f2923

Please sign in to comment.