'
- var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown()
- $dropdown
- .parent('.dropdown')
- .on('shown.bs.dropdown', function () {
- assert.ok($dropdown.parent('.dropdown').hasClass('show'), '"show" class added on click')
- done()
- })
- $dropdown.trigger('click')
- })
-
QUnit.test('should remove "show" class if body is clicked', function (assert) {
assert.expect(2)
var done = assert.async()
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index 53a2e04167..914366ae22 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -607,36 +607,40 @@ $(function () {
assert.expect(1)
var done = assert.async()
- var $toggleBtn = $('')
- .appendTo('#qunit-fixture')
+ try {
+ var $toggleBtn = $('')
+ .appendTo('#qunit-fixture')
- $toggleBtn.trigger('click')
- setTimeout(function () {
+ $toggleBtn.trigger('click')
+ } catch (e) {
assert.strictEqual($('#modal-test').length, 0, 'target has not been parsed and added to the document')
done()
- }, 1)
+ }
})
QUnit.test('should not execute js from target', function (assert) {
assert.expect(0)
var done = assert.async()
- // This toggle button contains XSS payload in its data-target
- // Note: it uses the onerror handler of an img element to execute the js, because a simple script element does not work here
- // a script element works in manual tests though, so here it is likely blocked by the qunit framework
- var $toggleBtn = $('')
- .appendTo('#qunit-fixture')
- // The XSS payload above does not have a closure over this function and cannot access the assert object directly
- // However, it can send a click event to the following control button, which will then fail the assert
- $('