Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Do feature detection instead of browser detection for ui test.

The previous `isIE()` check returned false for IE11.
  • Loading branch information...
commit 2b87aa1f00a347778ce3f0938231b196e59e5afb 1 parent 69455d4
@estark37 estark37 authored
Showing with 14 additions and 7 deletions.
  1. +14 −7 packages/ui/render_tests.js
View
21 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), '<span style="foo: c"></span>');
- // 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() ? '<span style="foo: a; baz: c"></span>' : '<span style="foo: a; bar::d; baz: c"></span>');
+ malformedStylesAllowed() ?
+ '<span style="foo: a; bar::d; baz: c"></span>' :
+ '<span style="foo: a; baz: c"></span>');
// Test strange styles
R.set({'style': ' foo: c; constructor: a; __proto__: b;'});

1 comment on commit 2b87aa1

@avital
Owner

thanks for doing this. (cc @arbesfeld, browser detection is evil)

Please sign in to comment.
Something went wrong with that request. Please try again.