aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/dialog/dialog_events.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/dialog/dialog_events.js')
-rw-r--r--tests/unit/dialog/dialog_events.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js
index ee7a8bcb3..cbeced0f8 100644
--- a/tests/unit/dialog/dialog_events.js
+++ b/tests/unit/dialog/dialog_events.js
@@ -39,6 +39,51 @@ test("open", function() {
el.remove();
});
+
+test( "focus", function() {
+ expect( 5 );
+ var el, other;
+ el = $("#dialog1").dialog({
+ autoOpen: false
+ });
+ other = $("#dialog2").dialog({
+ autoOpen: false
+ });
+
+ el.one( "dialogopen", function() {
+ ok( true, "open, just once" );
+ });
+ el.one( "dialogfocus", function() {
+ ok( true, "focus on open" );
+ });
+ other.dialog( "open" );
+
+ el.one( "dialogfocus", function() {
+ ok( true, "when opening and already open and wasn't on top" );
+ });
+ other.dialog( "open" );
+ el.dialog( "open" );
+
+ el.one( "dialogfocus", function() {
+ ok( true, "when calling moveToTop and wasn't on top" );
+ });
+ other.dialog( "moveToTop" );
+ el.dialog( "moveToTop" );
+
+ el.bind( "dialogfocus", function() {
+ ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
+ });
+ other.dialog( "moveToTop" );
+ el.trigger( "mousedown" );
+
+ // triggers just once when already on top
+ el.dialog( "open" );
+ el.dialog( "moveToTop" );
+ el.trigger( "mousedown" );
+
+ el.add( other ).remove();
+});
+
test("dragStart", function() {
expect(9);
@@ -280,4 +325,20 @@ test("beforeClose", function() {
el.remove();
});
+// #8789 and #8838
+asyncTest("ensure dialog's container doesn't scroll on resize and focus", function() {
+ expect(2);
+
+ var el = $('#dialog1').dialog(),
+ initialScroll = $(window).scrollTop();
+ el.dialog('option', 'height', 600);
+ equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after height change");
+ setTimeout( function(){
+ $(".ui-dialog-titlebar-close").simulate('mousedown');
+ equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog");
+ el.dialog('destroy');
+ start();
+ }, 500);
+});
+
})(jQuery);