Skip to content

Commit be37c72

Browse files
committed
adding tests for #8870 making sure bind and unbind works on windows other than the current
1 parent 3d819b7 commit be37c72

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/unit/event.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,26 @@ test("bind/delegate bubbling, isDefaultPrevented", function() {
343343

344344
test("bind(), iframes", function() {
345345
// events don't work with iframes, see #939 - this test fails in IE because of contentDocument
346-
var doc = jQuery("#loadediframe").contents();
346+
var doc = jQuery("#loadedf").contents();
347347

348348
jQuery("div", doc).bind("click", function() {
349349
ok( true, "Binding to element inside iframe" );
350350
}).click().unbind("click");
351351
});
352352

353+
test("bind(), unbind events on different window", 2 ,function() {
354+
// unbinding an event bound to a different window would throw an exception in IE #8870
355+
var win = window.frames["loadediframe"],
356+
handler = function() { ok( true, "Bound to iframe window" );};
357+
jQuery(win).bind('foo',handler).trigger('foo');
358+
try{
359+
//error would be thrown here normally, so if the assertion runs we pass
360+
jQuery(win).unbind('foo', handler);
361+
ok( true, "Unbound succesfully" );
362+
}catch(e) {}
363+
jQuery(win).trigger('foo');
364+
});
365+
353366
test("bind(), trigger change on select", function() {
354367
expect(5);
355368
var counter = 0;

0 commit comments

Comments
 (0)