Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 45252c3

Browse files
committed
fix($sce): use msie instead of $document[0].documentMode
this is important so that people can mock $window without having to add stuff that angular uses internally into it Closes #9661
1 parent c2edef8 commit 45252c3

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/ng/sce.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ function $SceProvider() {
722722
$document, $parse, $sceDelegate) {
723723
// Prereq: Ensure that we're not running in IE<11 quirks mode. In that mode, IE < 11 allow
724724
// the "expression(javascript expression)" syntax which is insecure.
725-
if (enabled && $document[0].documentMode < 8) {
725+
if (enabled && msie < 8) {
726726
throw $sceMinErr('iequirks',
727727
'Strict Contextual Escaping does not support Internet Explorer version < 11 in quirks ' +
728728
'mode. You can fix this by adding the text <!doctype html> to the top of your HTML ' +

test/ng/sceSpecs.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ describe('SCE', function() {
2727
});
2828

2929
describe('IE<11 quirks mode', function() {
30+
/* global msie: true */
31+
var msieBackup;
32+
33+
beforeEach(function() {
34+
msieBackup = msie;
35+
});
36+
37+
afterEach(function() {
38+
msie = msieBackup;
39+
});
40+
3041
function runTest(enabled, documentMode, expectException) {
42+
msie = documentMode;
3143
module(function($provide) {
32-
$provide.value('$document', [{
33-
documentMode: documentMode
34-
}]);
3544
$provide.value('$sceDelegate', {trustAs: null, valueOf: null, getTrusted: null});
3645
});
3746

test/ng/windowSpec.js

+5
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ describe('$window', function() {
44
it("should inject $window", inject(function($window) {
55
expect($window).toBe(window);
66
}));
7+
8+
it('should be able to mock $window without errors', function() {
9+
module({$window: {}});
10+
inject(['$sce', angular.noop]);
11+
});
712
});

0 commit comments

Comments
 (0)