From 4bd611884a5f1dd02878f73bccd51d85c1e49186 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 4 Apr 2012 14:58:04 -0700 Subject: detect if title in tooltip is text or html. if text - use `text` method to prevent xss. all add a few notes to js readme about updated event --- js/tests/unit/bootstrap-tooltip.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'js/tests/unit/bootstrap-tooltip.js') diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 8543162c6..f6e00089b 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -59,4 +59,28 @@ $(function () { ok(!$(".tooltip").length, 'tooltip removed') }) + test("should detect if title string is html or text: foo", function () { + ok(!$.fn.tooltip.Constructor.prototype.isHTML('foo'), 'correctly detected html') + }) + + test("should detect if title string is html or text: &lt;foo&gt;", function () { + ok(!$.fn.tooltip.Constructor.prototype.isHTML('<foo>'), 'correctly detected html') + }) + + test("should detect if title string is html or text: <div>foo</div>", function () { + ok($.fn.tooltip.Constructor.prototype.isHTML('
foo
'), 'correctly detected html') + }) + + test("should detect if title string is html or text: asdfa<div>foo</div>asdfasdf", function () { + ok($.fn.tooltip.Constructor.prototype.isHTML('asdfa
foo
asdfasdf'), 'correctly detected html') + }) + + test("should detect if title string is html or text: document.createElement('div')", function () { + ok($.fn.tooltip.Constructor.prototype.isHTML(document.createElement('div')), 'correctly detected html') + }) + + test("should detect if title string is html or text: $('<div />)", function () { + ok($.fn.tooltip.Constructor.prototype.isHTML($('
')), 'correctly detected html') + }) + }) \ No newline at end of file -- cgit v1.2.3 From b14455b03a977cbbf99112d39b55461785666a3f Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 14 Apr 2012 23:10:03 -0700 Subject: add tests for mouseout delay in tooltip --- js/tests/unit/bootstrap-tooltip.js | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'js/tests/unit/bootstrap-tooltip.js') diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index f6e00089b..63f4f0b07 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -59,6 +59,56 @@ $(function () { ok(!$(".tooltip").length, 'tooltip removed') }) + test("should not show tooltip if leave event occurs before delay expires", function () { + var tooltip = $('') + .appendTo('#qunit-fixture') + .tooltip({ delay: 200 }) + + stop() + + tooltip.trigger('mouseenter') + + setTimeout(function () { + ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') + tooltip.trigger('mouseout') + setTimeout(function () { + ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') + start() + }, 200) + }, 100) + }) + + test("should not show tooltip if leave event occurs before delay expires", function () { + var tooltip = $('') + .appendTo('#qunit-fixture') + .tooltip({ delay: 100 }) + stop() + tooltip.trigger('mouseenter') + setTimeout(function () { + ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') + tooltip.trigger('mouseout') + setTimeout(function () { + ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') + start() + }, 100) + }, 50) + }) + + test("should show tooltip if leave event hasn't occured before delay expires", function () { + var tooltip = $('') + .appendTo('#qunit-fixture') + .tooltip({ delay: 200 }) + stop() + tooltip.trigger('mouseenter') + setTimeout(function () { + ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') + setTimeout(function () { + ok(!$(".tooltip").hasClass('fade in'), 'tooltip has faded in') + start() + }, 200) + }, 100) + }) + test("should detect if title string is html or text: foo", function () { ok(!$.fn.tooltip.Constructor.prototype.isHTML('foo'), 'correctly detected html') }) -- cgit v1.2.3