Skip to content

Commit

Permalink
Draggable Tests: fix old Safari and old Opera tests with jQuery < 1.8…
Browse files Browse the repository at this point in the history
… tests by accounting for a bug in $.contains on disconnected Elements.
  • Loading branch information
mikesherov committed Apr 7, 2013
1 parent 6a3bf60 commit 3c1a3ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/unit/draggable/draggable_options.js
Expand Up @@ -1289,9 +1289,15 @@ test( "#8459: element can snap to an element that was removed during drag", func
moves: 1
});

// TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" );
closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" );
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
if ( TestHelpers.draggable.unreliableContains ) {
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
} else {
// TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" );
closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" );
}
});

test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() {
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/draggable/draggable_test_helpers.js
@@ -1,6 +1,11 @@
TestHelpers.draggable = {
// todo: remove the unreliable offset hacks
unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
unreliableContains: function(){
var element = $( "<div>" );
return $.contains( element[ 0 ].ownerDocument, element[ 0 ] );
}(),
testDrag: function(el, handle, dx, dy, expectedDX, expectedDY, msg) {
var offsetAfter, actual, expected,
offsetBefore = el.offset();
Expand Down

0 comments on commit 3c1a3ca

Please sign in to comment.