aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng
diff options
context:
space:
mode:
authorTobias Bosch2013-11-19 20:42:38 -0800
committerPete Bacon Darwin2013-11-20 23:12:39 +0000
commitec3c4f94c79e23c29abcde6e1d2f6eaf05e0664c (patch)
treeb012206a97beda4a868f2a27a243a643a4f6cd74 /test/ng
parent6b8bbe4d90640542eed5607a8c91f6b977b1d6c0 (diff)
downloadangular.js-ec3c4f94c79e23c29abcde6e1d2f6eaf05e0664c.tar.bz2
refactor($sce): Use $sniffer instead of $document for feature detection.
Also adds `$sniffer.msieDocumentMode` property. Closes #4931 Closes #5045
Diffstat (limited to 'test/ng')
-rw-r--r--test/ng/sceSpecs.js33
-rw-r--r--test/ng/snifferSpec.js5
2 files changed, 18 insertions, 20 deletions
diff --git a/test/ng/sceSpecs.js b/test/ng/sceSpecs.js
index e1588fe2..66c05c0d 100644
--- a/test/ng/sceSpecs.js
+++ b/test/ng/sceSpecs.js
@@ -29,10 +29,10 @@ describe('SCE', function() {
describe('IE8 quirks mode', function() {
function runTest(enabled, documentMode, expectException) {
module(function($provide) {
- $provide.value('$document', [{
- documentMode: documentMode,
- createElement: function() {}
- }]);
+ $provide.value('$sniffer', {
+ msie: documentMode,
+ msieDocumentMode: documentMode
+ });
$provide.value('$sceDelegate', {trustAs: null, valueOf: null, getTrusted: null});
});
@@ -43,22 +43,15 @@ describe('SCE', function() {
return $injector.invoke(sceProvider.$get, sceProvider);
}
- var origMsie = $window.msie;
- try {
- $window.msie = true;
- if (expectException) {
- expect(constructSce).toThrowMinErr(
- '$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 ' +
- 'the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more ' +
- 'information.');
- } else {
- // no exception.
- constructSce();
- }
- }
- finally {
- $window.msie = origMsie;
+ if (expectException) {
+ expect(constructSce).toThrowMinErr(
+ '$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 ' +
+ 'the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more ' +
+ 'information.');
+ } else {
+ // no exception.
+ constructSce();
}
});
}
diff --git a/test/ng/snifferSpec.js b/test/ng/snifferSpec.js
index 9ab317d2..24e0584b 100644
--- a/test/ng/snifferSpec.js
+++ b/test/ng/snifferSpec.js
@@ -337,4 +337,9 @@ describe('$sniffer', function() {
it('should return true for msie when internet explorer is being used', inject(function($sniffer) {
expect($sniffer.msie > 0).toBe(window.navigator.appName == 'Microsoft Internet Explorer');
}));
+
+ it('should return document.documentMode as msieDocumentMode', function() {
+ var someDocumentMode = 123;
+ expect(sniffer({}, {documentMode: someDocumentMode}).msieDocumentMode).toBe(someDocumentMode);
+ });
});