chore($sniffer): Remove $sniffer.msie & $sniffer.msieDocumentMode

Since msie is now set to document.documentMode, it's not necessary to keep
the documentMode in a separate property.

Also, msie is a variable global to Angular source so there's no need to
replicate it in $sniffer.

Closes gh-9496
This commit is contained in:
Michał Gołębiowski
2014-10-08 17:09:00 +02:00
committed by Igor Minar
parent 2435e2b8f8
commit 64241a57e2
6 changed files with 18 additions and 34 deletions

View File

@@ -1,13 +1,13 @@
@ngdoc error @ngdoc error
@name $sce:iequirks @name $sce:iequirks
@fullName IE8 in quirks mode is unsupported @fullName IE<11 in quirks mode is unsupported
@description @description
This error occurs when you are using AngularJS with {@link ng.$sce Strict Contextual Escaping (SCE)} mode enabled (the default) on IE8 or lower in quirks mode. This error occurs when you are using AngularJS with {@link ng.$sce Strict Contextual Escaping (SCE)} mode enabled (the default) on IE10 or lower in quirks mode.
In this mode, IE8 allows one to execute arbitrary javascript by the use of the `expression()` syntax and is not supported. In this mode, IE<11 allow one to execute arbitrary javascript by the use of the `expression()` syntax and is not supported.
Refer Refer
[MSDN Blogs > IEBlog > Ending Expressions](http://blogs.msdn.com/b/ie/archive/2008/10/16/ending-expressions.aspx) [CSS expressions no longer supported for the Internet zone](http://msdn.microsoft.com/en-us/library/ie/dn384050(v=vs.85).aspx)
to learn more about them. to learn more about them.
To resolve this error please specify the proper doctype at the top of your main html document: To resolve this error please specify the proper doctype at the top of your main html document:

View File

@@ -410,7 +410,7 @@ function $SceDelegateProvider() {
* *
* As of version 1.2, Angular ships with SCE enabled by default. * As of version 1.2, Angular ships with SCE enabled by default.
* *
* Note: When enabled (the default), IE8 in quirks mode is not supported. In this mode, IE8 allows * Note: When enabled (the default), IE<11 in quirks mode is not supported. In this mode, IE<11 allow
* one to execute arbitrary javascript by the use of the expression() syntax. Refer * one to execute arbitrary javascript by the use of the expression() syntax. Refer
* <http://blogs.msdn.com/b/ie/archive/2008/10/16/ending-expressions.aspx> to learn more about them. * <http://blogs.msdn.com/b/ie/archive/2008/10/16/ending-expressions.aspx> to learn more about them.
* You can ensure your document is in standards mode and not quirks mode by adding `<!doctype html>` * You can ensure your document is in standards mode and not quirks mode by adding `<!doctype html>`
@@ -727,13 +727,13 @@ function $SceProvider() {
* sce.js and sceSpecs.js would need to be aware of this detail. * sce.js and sceSpecs.js would need to be aware of this detail.
*/ */
this.$get = ['$parse', '$sniffer', '$sceDelegate', function( this.$get = ['$document', '$parse', '$sceDelegate', function(
$parse, $sniffer, $sceDelegate) { $document, $parse, $sceDelegate) {
// Prereq: Ensure that we're not running in IE8 quirks mode. In that mode, IE allows // 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. // the "expression(javascript expression)" syntax which is insecure.
if (enabled && $sniffer.msie && $sniffer.msieDocumentMode < 8) { if (enabled && $document[0].documentMode < 8) {
throw $sceMinErr('iequirks', throw $sceMinErr('iequirks',
'Strict Contextual Escaping does not support Internet Explorer version < 9 in quirks ' + '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 ' + 'mode. You can fix this by adding the text <!doctype html> to the top of your HTML ' +
'document. See http://docs.angularjs.org/api/ng.$sce for more information.'); 'document. See http://docs.angularjs.org/api/ng.$sce for more information.');
} }

View File

@@ -21,7 +21,6 @@ function $SnifferProvider() {
int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]), int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
boxee = /Boxee/i.test(($window.navigator || {}).userAgent), boxee = /Boxee/i.test(($window.navigator || {}).userAgent),
document = $document[0] || {}, document = $document[0] || {},
documentMode = document.documentMode,
vendorPrefix, vendorPrefix,
vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/, vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/,
bodyStyle = document.body && document.body.style, bodyStyle = document.body && document.body.style,
@@ -81,9 +80,7 @@ function $SnifferProvider() {
vendorPrefix: vendorPrefix, vendorPrefix: vendorPrefix,
transitions : transitions, transitions : transitions,
animations : animations, animations : animations,
android: android, android: android
msie : msie,
msieDocumentMode: documentMode
}; };
}]; }];
} }

View File

@@ -18,7 +18,7 @@ describe('$location', function() {
var urlParsingNodePlaceholder; var urlParsingNodePlaceholder;
beforeEach(inject(function ($sniffer) { beforeEach(inject(function ($sniffer) {
if ($sniffer.msie) return; if (msie) return;
urlParsingNodePlaceholder = urlParsingNode; urlParsingNodePlaceholder = urlParsingNode;
@@ -38,7 +38,7 @@ describe('$location', function() {
})); }));
afterEach(inject(function ($sniffer) { afterEach(inject(function ($sniffer) {
if ($sniffer.msie) return; if (msie) return;
//reset urlParsingNode //reset urlParsingNode
urlParsingNode = urlParsingNodePlaceholder; urlParsingNode = urlParsingNodePlaceholder;
})); }));

View File

@@ -26,13 +26,12 @@ describe('SCE', function() {
})); }));
}); });
describe('IE8 quirks mode', function() { describe('IE<11 quirks mode', function() {
function runTest(enabled, documentMode, expectException) { function runTest(enabled, documentMode, expectException) {
module(function($provide) { module(function($provide) {
$provide.value('$sniffer', { $provide.value('$document', [{
msie: documentMode, documentMode: documentMode
msieDocumentMode: documentMode }]);
});
$provide.value('$sceDelegate', {trustAs: null, valueOf: null, getTrusted: null}); $provide.value('$sceDelegate', {trustAs: null, valueOf: null, getTrusted: null});
}); });
@@ -47,7 +46,7 @@ describe('SCE', function() {
if (expectException) { if (expectException) {
expect(constructSce).toThrowMinErr( expect(constructSce).toThrowMinErr(
'$sce', 'iequirks', 'Strict Contextual Escaping does not support Internet Explorer ' + '$sce', 'iequirks', 'Strict Contextual Escaping does not support Internet Explorer ' +
'version < 9 in quirks mode. You can fix this by adding the text <!doctype html> to ' + 'version < 11 in quirks mode. You can fix this by adding the text <!doctype html> to ' +
'the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more ' + 'the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more ' +
'information.'); 'information.');
} else { } else {

View File

@@ -332,16 +332,4 @@ describe('$sniffer', function() {
expect($sniffer.android).toBe(2); expect($sniffer.android).toBe(2);
}); });
}); });
it('should return the internal msie flag', inject(function($sniffer) {
expect(isNaN($sniffer.msie)).toBe(isNaN(msie));
if (msie) {
expect($sniffer.msie).toBe(msie);
}
}));
it('should return document.documentMode as msieDocumentMode', function() {
var someDocumentMode = 123;
expect(sniffer({}, {documentMode: someDocumentMode}).msieDocumentMode).toBe(someDocumentMode);
});
}); });