Skip to content

Commit af7e0bd

Browse files
committed
fix(CSP): update to the latest CSP api
window.SecurityPolicy.isActive() is now window.securityPolicy.isActive 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
1 parent bd524fc commit af7e0bd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/ng/sniffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function $SnifferProvider() {
4141

4242
return eventSupport[event];
4343
},
44-
csp: document.SecurityPolicy ? document.SecurityPolicy.isActive() : false
44+
csp: document.securityPolicy ? document.securityPolicy.isActive : false
4545
};
4646
}];
4747
}

test/ng/snifferSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ describe('$sniffer', function() {
8282

8383

8484
describe('csp', function() {
85-
it('should be false if document.SecurityPolicy.isActive not available', function() {
85+
it('should be false if document.securityPolicy.isActive not available', function() {
8686
expect(sniffer({}, {}).csp).toBe(false);
8787
});
8888

8989

90-
it('should use document.SecurityPolicy.isActive() if available', function() {
90+
it('should use document.securityPolicy.isActive if available', function() {
9191
var createDocumentWithCSP = function(csp) {
92-
return {SecurityPolicy: {isActive: function() {return csp;}}};
92+
return {securityPolicy: {isActive: csp}};
9393
};
9494

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

0 commit comments

Comments
 (0)