mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-08 09:07:46 +08:00
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
This commit is contained in:
@@ -722,7 +722,7 @@ function $SceProvider() {
|
||||
$document, $parse, $sceDelegate) {
|
||||
// Prereq: Ensure that we're not running in IE<11 quirks mode. In that mode, IE < 11 allow
|
||||
// the "expression(javascript expression)" syntax which is insecure.
|
||||
if (enabled && $document[0].documentMode < 8) {
|
||||
if (enabled && msie < 8) {
|
||||
throw $sceMinErr('iequirks',
|
||||
'Strict Contextual Escaping does not support Internet Explorer version < 11 in quirks ' +
|
||||
'mode. You can fix this by adding the text <!doctype html> to the top of your HTML ' +
|
||||
|
||||
@@ -27,11 +27,20 @@ describe('SCE', function() {
|
||||
});
|
||||
|
||||
describe('IE<11 quirks mode', function() {
|
||||
/* global msie: true */
|
||||
var msieBackup;
|
||||
|
||||
beforeEach(function() {
|
||||
msieBackup = msie;
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
msie = msieBackup;
|
||||
});
|
||||
|
||||
function runTest(enabled, documentMode, expectException) {
|
||||
msie = documentMode;
|
||||
module(function($provide) {
|
||||
$provide.value('$document', [{
|
||||
documentMode: documentMode
|
||||
}]);
|
||||
$provide.value('$sceDelegate', {trustAs: null, valueOf: null, getTrusted: null});
|
||||
});
|
||||
|
||||
|
||||
@@ -4,4 +4,9 @@ describe('$window', function() {
|
||||
it("should inject $window", inject(function($window) {
|
||||
expect($window).toBe(window);
|
||||
}));
|
||||
|
||||
it('should be able to mock $window without errors', function() {
|
||||
module({$window: {}});
|
||||
inject(['$sce', angular.noop]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user