Skip to content

Commit 59da723

Browse files
mikesherovscottgonzalez
authored andcommitted
Selectable Tests: Fix test failures in IE7 by accounting simulated events properly.(cherry picked from commit 875139e)
1 parent a93ad18 commit 59da723

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

tests/unit/selectable/selectable_events.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,30 @@ test( "stop", function() {
3838
test( "mousedown: initial position of helper", function() {
3939
expect( 2 );
4040

41-
var contentToForceScroll, helper,
42-
element = $("#selectable1").selectable();
41+
var helperOffset,
42+
element = $( "#selectable1" ).selectable(),
43+
contentToForceScroll = $( "<div>" ).css({
44+
height: "10000px",
45+
width: "10000px"
46+
});
4347

44-
contentToForceScroll = $("<div>").css({
45-
height: "10000px",
46-
width: "10000px"
47-
});
48+
contentToForceScroll.appendTo( "body" );
49+
$( window ).scrollTop( 100 ).scrollLeft( 100 );
4850

49-
contentToForceScroll.appendTo("body");
50-
$( window ).scrollTop( 1 ).scrollLeft( 1 );
5151
element.simulate( "mousedown", {
5252
clientX: 10,
5353
clientY: 10
5454
});
5555

56-
helper = $(".ui-selectable-helper");
57-
equal( helper.css("top"), "11px", "Scroll top should be accounted for." );
58-
equal( helper.css("left"), "11px", "Scroll left should be accounted for." );
56+
// we do a GTE comparison here because IE7 erroneously subtracts
57+
// 2 pixels from a simulated mousedown for clientX/Y
58+
// Support: IE7
59+
helperOffset = $( ".ui-selectable-helper" ).offset();
60+
ok( helperOffset.top >= 99, "Scroll top should be accounted for." );
61+
ok( helperOffset.left >= 99, "Scroll left should be accounted for." );
5962

6063
// Cleanup
61-
element.simulate("mouseup");
64+
element.simulate( "mouseup" );
6265
contentToForceScroll.remove();
6366
$( window ).scrollTop( 0 ).scrollLeft( 0 );
6467
});

0 commit comments

Comments
 (0)