From 2b87aa1f00a347778ce3f0938231b196e59e5afb Mon Sep 17 00:00:00 2001 From: Emily Stark Date: Sun, 22 Jun 2014 16:31:13 -0700 Subject: [PATCH] Do feature detection instead of browser detection for ui test. The previous `isIE()` check returned false for IE11. --- packages/ui/render_tests.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/ui/render_tests.js b/packages/ui/render_tests.js index 0a61fff6e9a..d2ffd56c5d9 100644 --- a/packages/ui/render_tests.js +++ b/packages/ui/render_tests.js @@ -15,11 +15,6 @@ var HR = HTML.HR; var TEXTAREA = HTML.TEXTAREA; var INPUT = HTML.INPUT; -var isIE = function () { - var myNav = navigator.userAgent.toLowerCase(); - return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false; -}; - Tinytest.add("ui - render - basic", function (test) { var run = function (input, expectedInnerHTML, expectedHTML, expectedCode) { var div = document.createElement("DIV"); @@ -209,6 +204,15 @@ Tinytest.add("ui - render - closures", function (test) { }); +// IE strips malformed styles like "bar::d" from the `style` +// attribute. We detect this to adjust expectations for the StyleHandler +// test below. +var malformedStylesAllowed = function () { + var div = document.createElement("div"); + div.setAttribute("style", "bar::d;"); + return (div.getAttribute("style") === "bar::d;"); +}; + Tinytest.add("ui - render - closure GC", function (test) { // test that removing parent element removes listeners and stops autoruns. (function () { @@ -331,11 +335,14 @@ Tinytest.add("ui - render - reactive attributes", function (test) { Deps.flush(); test.equal(canonicalizeHtml(div.innerHTML), ''); - // test malformed styles - different expectations in IE from Chrome + // test malformed styles - different expectations in IE (which + // strips malformed styles) from other browsers R.set({'style': 'foo: a; bar::d;:e; baz: c;'}); Deps.flush(); test.equal(canonicalizeHtml(div.innerHTML), - isIE() ? '' : ''); + malformedStylesAllowed() ? + '' : + ''); // Test strange styles R.set({'style': ' foo: c; constructor: a; __proto__: b;'});