From d04f3168feb2264d2c2fab931cafb7e4fd3e7bec Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Fri, 12 Sep 2014 08:25:41 -0400 Subject: [PATCH 1/2] test($parse): ensure CSP code paths are used when testing Previously, the test suite was not actually taking CSP-mode paths when we were expecting it to. Numerous CSP-mode tests are failing, working on fixing these. --- test/ng/parseSpec.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js index 618149cee2fe..122422d4e302 100644 --- a/test/ng/parseSpec.js +++ b/test/ng/parseSpec.js @@ -210,19 +210,12 @@ describe('parser', function() { forEach([true, false], function(cspEnabled) { describe('csp: ' + cspEnabled, function() { - var originalSecurityPolicy; - - - beforeEach(function() { - originalSecurityPolicy = window.document.securityPolicy; - window.document.securityPolicy = {isActive : cspEnabled}; - }); - - afterEach(function() { - window.document.securityPolicy = originalSecurityPolicy; - }); - - beforeEach(module(provideLog)); + beforeEach(module(function($provide) { + $provide.decorator('$sniffer', function($delegate) { + $delegate.csp = cspEnabled; + return $delegate; + }); + }, provideLog)); beforeEach(inject(function ($rootScope) { scope = $rootScope; From f2f390d9df4d610098336e141220433a34499457 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Fri, 12 Sep 2014 08:56:34 -0400 Subject: [PATCH 2/2] fix($parse): ensure CSP assignable expressions have `assign()` Fixes regression where the `assign()` method was not added to chains of identifiers in CSP mode, introduced originally in b3b476d. Closes #9048 --- src/ng/parse.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ng/parse.js b/src/ng/parse.js index 69e71e201698..e27321a64d97 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -897,7 +897,7 @@ function getterFn(path, options, fullExp) { if (pathKeysLength < 6) { fn = cspSafeGetterFn(pathKeys[0], pathKeys[1], pathKeys[2], pathKeys[3], pathKeys[4], fullExp); } else { - fn = function(scope, locals) { + fn = function cspSafeGetter(scope, locals) { var i = 0, val; do { val = cspSafeGetterFn(pathKeys[i++], pathKeys[i++], pathKeys[i++], pathKeys[i++], @@ -926,14 +926,14 @@ function getterFn(path, options, fullExp) { var evaledFnGetter = new Function('s', 'l', code); // s=scope, l=locals /* jshint +W054 */ evaledFnGetter.toString = valueFn(code); - evaledFnGetter.assign = function(self, value) { - return setter(self, path, value, path); - }; fn = evaledFnGetter; } fn.sharedGetter = true; + fn.assign = function(self, value) { + return setter(self, path, value, path); + }; getterFnCache[path] = fn; return fn; }