Skip to content

Commit 805b2ce

Browse files
chirayukjamesdaily
authored andcommitted
test($sce): ie8 fix for entire file
Ref: angular#4221 Closes angular#4221
1 parent 23cad75 commit 805b2ce

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

test/ng/sceSpecs.js

+14-17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
describe('SCE', function() {
44

5+
// Work around an IE8 bug. Though window.inject === angular.mock.inject, if it's invoked the
6+
// window scope, IE8 loses the exception object that bubbles up and replaces it with a TypeError.
7+
// By using a local alias, it gets invoked on the global scope instead of window.
8+
// Ref: https://github.com/angular/angular.js/pull/4221#/issuecomment-25515813
9+
var inject = angular.mock.inject;
10+
511
describe('when disabled', function() {
612
beforeEach(function() {
713
module(function($sceProvider) {
@@ -262,9 +268,7 @@ describe('SCE', function() {
262268
$sceDelegateProvider.resourceUrlBlacklist(cfg.blackList);
263269
}
264270
});
265-
// This needs to be angular.mock.inject even though it's === window.inject.
266-
// Ref: https://github.com/angular/angular.js/pull/4221#/issuecomment-25515813
267-
angular.mock.inject(testFn);
271+
inject(testFn);
268272
}
269273
}
270274

@@ -399,20 +403,13 @@ describe('SCE', function() {
399403
expect($sce.getTrustedResourceUrl('http://example.com/foo:1/2.3?4&5-6')).toEqual('http://example.com/foo:1/2.3?4&5-6');
400404
}));
401405

402-
// TODO(chirayu): This throws a very helpful TypeError exception - "Object doesn't support
403-
// this property or method". Tracing using the debugger on IE8 developer tools shows me one
404-
// catch(e) block where the exception is correct, but jumping up to the parent catch block has
405-
// the TypeError exception. I've been unable to repro this outside this snippet or figure out
406-
// why this is happening. Until then, this test doesn't run on IE8.
407-
if (!msie || msie > 8) {
408-
it('should not accept *** in the string', function() {
409-
expect(function() {
410-
runTest({whiteList: ['http://***']}, null)();
411-
}).toThrowMinErr('$injector', 'modulerr', new RegExp(
412-
/Failed to instantiate module function ?\(\$sceDelegateProvider\) due to:\n/.source +
413-
/[^[]*\[\$sce:iwcard\] Illegal sequence \*\*\* in string matcher\. String: http:\/\/\*\*\*/.source));
414-
});
415-
}
406+
it('should not accept *** in the string', function() {
407+
expect(function() {
408+
runTest({whiteList: ['http://***']}, null)();
409+
}).toThrowMinErr('$injector', 'modulerr', new RegExp(
410+
/Failed to instantiate module function ?\(\$sceDelegateProvider\) due to:\n/.source +
411+
/[^[]*\[\$sce:iwcard\] Illegal sequence \*\*\* in string matcher\. String: http:\/\/\*\*\*/.source));
412+
});
416413
});
417414

418415
describe('"self" matcher', function() {

0 commit comments

Comments
 (0)