[Representation] Trust template URLs

Trust resource URLs to skip SCE-checking (which profiling
flags as a performance problem) for mct-include and
mct-representation; these URLs are pulled from bundles and
not user-entered, so should be trusted. WTD-1256.
This commit is contained in:
Victor Woeltjen
2015-06-18 14:43:14 -07:00
parent dc85d3c191
commit 275ca01692
5 changed files with 61 additions and 17 deletions

View File

@ -31,6 +31,7 @@ define(
describe("The mct-include directive", function () {
var testTemplates,
mockSce,
mctInclude;
beforeEach(function () {
@ -46,7 +47,14 @@ define(
templateUrl: "z/template.html"
}
];
mctInclude = new MCTInclude(testTemplates);
mockSce = jasmine.createSpyObj(
'$sce',
['trustAsResourceUrl']
);
mockSce.trustAsResourceUrl.andCallFake(function (url) {
return url;
});
mctInclude = new MCTInclude(testTemplates, mockSce);
});
it("has a built-in template, with ng-include src=inclusion", function () {
@ -69,6 +77,12 @@ define(
expect(scope.inclusion).toEqual("x/y/z/template.html");
});
it("trusts template URLs", function () {
mctInclude.controller({ key: "xyz" });
expect(mockSce.trustAsResourceUrl)
.toHaveBeenCalledWith("x/y/z/template.html");
});
});
}
);
);