aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/menu
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/menu')
-rw-r--r--tests/unit/menu/menu.html364
-rw-r--r--tests/unit/menu/menu_common.js1
-rw-r--r--tests/unit/menu/menu_core.js18
-rw-r--r--tests/unit/menu/menu_events.js47
-rw-r--r--tests/unit/menu/menu_methods.js4
-rw-r--r--tests/unit/menu/menu_options.js27
-rw-r--r--tests/unit/menu/menu_test_helpers.js2
7 files changed, 272 insertions, 191 deletions
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index ed376232e..a49c72a04 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -48,220 +48,254 @@
<div id="qunit-fixture">
<ul class="foo" id="menu1">
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a id="testID1" class="foo" href="#">Addyston</a></li>
- <li class="foo"><a class="foo" href="#">Adelphi</a></li>
+ <li class="foo">Aberdeen</li>
+ <li class="foo">Ada</li>
+ <li class="foo">Adamsville</li>
+ <li id="testID1" class="foo">Addyston</li>
+ <li class="foo">Adelphi</li>
</ul>
<ul id="menu2">
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a class="foo" href="#"><span class="ui-icon ui-icon-print"></span>Addyston</a></li>
- <li>
- <a href="#">Delphi</a>
+ <li class="foo">Aberdeen</li>
+ <li class="foo">Ada</li>
+ <li class="foo">Adamsville</li>
+ <li class="foo"><span class="ui-icon ui-icon-print"></span>Addyston</li>
+ <li>Delphi
<ul>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Saarland</a></li>
- <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ <li class="foo">Ada</li>
+ <li class="foo">Saarland</li>
+ <li class="foo">Salzburg</li>
</ul>
</li>
- <li class="foo"><a class="foo" href="#">Saarland</a></li>
- <li>
- <a href="#">Salzburg</a>
+ <li class="foo">Saarland</li>
+ <li>Salzburg
<ul>
- <li>
- <a href="#">Delphi</a>
+ <li>Delphi
<ul>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Saarland</a></li>
- <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ <li class="foo">Ada</li>
+ <li class="foo">Saarland</li>
+ <li class="foo">Salzburg</li>
</ul>
</li>
- <li>
- <a href="#">Delphi</a>
+ <li>Delphi
<ul>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo">Ada</li>
<li> - </li>
- <li class="foo"><a class="foo" href="#">Saarland</a></li>
+ <li class="foo">Saarland</li>
<li></li>
- <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ <li class="foo">Salzburg</li>
<li>&ndash;</li>
</ul>
</li>
- <li class="foo"><a class="foo" href="#">Perch</a></li>
+ <li class="foo">Perch</li>
</ul>
</li>
</ul>
<ul class="foo" id="menu3">
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a class="foo" href="#">Addyston</a></li>
- <li class="foo"><a class="foo" href="#">Adelphi</a></li>
- <li class="foo"><a class="foo" href="#">Adena</a></li>
- <li class="foo"><a class="foo" href="#">Adrian</a></li>
- <li class="foo"><a class="foo" href="#">Akron</a></li>
- <li class="foo"><a class="foo" href="#">Albany</a></li>
- <li class="foo"><a class="foo" href="#">Alexandria</a></li>
- <li class="foo"><a class="foo" href="#">Alger</a></li>
- <li class="foo"><a class="foo" href="#">Alledonia</a></li>
- <li class="foo"><a class="foo" href="#">Alliance</a></li>
- <li class="foo"><a class="foo" href="#">Alpha</a></li>
- <li class="foo"><a class="foo" href="#">Alvada</a></li>
- <li class="foo"><a class="foo" href="#">Alvordton</a></li>
- <li class="foo"><a class="foo" href="#">Amanda</a></li>
- <li class="foo"><a class="foo" href="#">Amelia</a></li>
- <li class="foo"><a class="foo" href="#">Amesville</a></li>
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a class="foo" href="#">Addyston</a></li>
- <li class="foo"><a class="foo" href="#">Adelphi</a></li>
- <li class="foo"><a class="foo" href="#">Adena</a></li>
- <li class="foo"><a class="foo" href="#">Adrian</a></li>
- <li class="foo"><a class="foo" href="#">Akron</a></li>
- <li class="foo"><a class="foo" href="#">Albany</a></li>
- <li class="foo"><a class="foo" href="#">Alexandria</a></li>
- <li class="foo"><a class="foo" href="#">Alger</a></li>
- <li class="foo"><a class="foo" href="#">Alledonia</a></li>
- <li class="foo"><a class="foo" href="#">Alliance</a></li>
- <li class="foo"><a class="foo" href="#">Alpha</a></li>
- <li class="foo"><a class="foo" href="#">Alvada</a></li>
- <li class="foo"><a class="foo" href="#">Alvordton</a></li>
- <li class="foo"><a class="foo" href="#">Amanda</a></li>
- <li class="foo"><a class="foo" href="#">Amelia</a></li>
- <li class="foo"><a class="foo" href="#">Amesville</a></li>
+ <li class="foo">Aberdeen</li>
+ <li class="foo">Ada</li>
+ <li class="foo">Adamsville</li>
+ <li class="foo">Addyston</li>
+ <li class="foo">Adelphi</li>
+ <li class="foo">Adena</li>
+ <li class="foo">Adrian</li>
+ <li class="foo">Akron</li>
+ <li class="foo">Albany</li>
+ <li class="foo">Alexandria</li>
+ <li class="foo">Alger</li>
+ <li class="foo">Alledonia</li>
+ <li class="foo">Alliance</li>
+ <li class="foo">Alpha</li>
+ <li class="foo">Alvada</li>
+ <li class="foo">Alvordton</li>
+ <li class="foo">Amanda</li>
+ <li class="foo">Amelia</li>
+ <li class="foo">Amesville</li>
+ <li class="foo">Aberdeen</li>
+ <li class="foo">Ada</li>
+ <li class="foo">Adamsville</li>
+ <li class="foo">Addyston</li>
+ <li class="foo">Adelphi</li>
+ <li class="foo">Adena</li>
+ <li class="foo">Adrian</li>
+ <li class="foo">Akron</li>
+ <li class="foo">Albany</li>
+ <li class="foo">Alexandria</li>
+ <li class="foo">Alger</li>
+ <li class="foo">Alledonia</li>
+ <li class="foo">Alliance</li>
+ <li class="foo">Alpha</li>
+ <li class="foo">Alvada</li>
+ <li class="foo">Alvordton</li>
+ <li class="foo">Amanda</li>
+ <li class="foo">Amelia</li>
+ <li class="foo">Amesville</li>
</ul>
<ul class="foo" id="menu4">
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo">Aberdeen</li>
<li class="foo">
- <a class="foo" href="#">Ada</a>
+ Ada
<ul class="foo">
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a class="foo" href="#">Addyston</a></li>
- <li class="foo"><a class="foo" href="#">Adelphi</a></li>
- <li class="foo"><a class="foo" href="#">Adena</a></li>
- <li class="foo"><a class="foo" href="#">Adrian</a></li>
- <li class="foo"><a class="foo" href="#">Akron</a></li>
- <li class="foo"><a class="foo" href="#">Albany</a></li>
- <li class="foo"><a class="foo" href="#">Alexandria</a></li>
- <li class="foo"><a class="foo" href="#">Alger</a></li>
- <li class="foo"><a class="foo" href="#">Alledonia</a></li>
- <li class="foo"><a class="foo" href="#">Alliance</a></li>
- <li class="foo"><a class="foo" href="#">Alpha</a></li>
- <li class="foo"><a class="foo" href="#">Alvada</a></li>
- <li class="foo"><a class="foo" href="#">Alvordton</a></li>
- <li class="foo"><a class="foo" href="#">Amanda</a></li>
- <li class="foo"><a class="foo" href="#">Amelia</a></li>
- <li class="foo"><a class="foo" href="#">Amesville</a></li>
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a class="foo" href="#">Addyston</a></li>
- <li class="foo"><a class="foo" href="#">Adelphi</a></li>
- <li class="foo"><a class="foo" href="#">Adena</a></li>
- <li class="foo"><a class="foo" href="#">Adrian</a></li>
- <li class="foo"><a class="foo" href="#">Akron</a></li>
- <li class="foo"><a class="foo" href="#">Albany</a></li>
+ <li class="foo">Aberdeen</li>
+ <li class="foo">Ada</li>
+ <li class="foo">Adamsville</li>
+ <li class="foo">Addyston</li>
+ <li class="foo">Adelphi</li>
+ <li class="foo">Adena</li>
+ <li class="foo">Adrian</li>
+ <li class="foo">Akron</li>
+ <li class="foo">Albany</li>
+ <li class="foo">Alexandria</li>
+ <li class="foo">Alger</li>
+ <li class="foo">Alledonia</li>
+ <li class="foo">Alliance</li>
+ <li class="foo">Alpha</li>
+ <li class="foo">Alvada</li>
+ <li class="foo">Alvordton</li>
+ <li class="foo">Amanda</li>
+ <li class="foo">Amelia</li>
+ <li class="foo">Amesville</li>
+ <li class="foo">Aberdeen</li>
+ <li class="foo">Ada</li>
+ <li class="foo">Adamsville</li>
+ <li class="foo">Addyston</li>
+ <li class="foo">Adelphi</li>
+ <li class="foo">Adena</li>
+ <li class="foo">Adrian</li>
+ <li class="foo">Akron</li>
+ <li class="foo">Albany</li>
</ul>
</li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a class="foo" href="#">Addyston</a></li>
- <li class="foo"><a class="foo" href="#">Adelphi</a></li>
- <li class="foo"><a class="foo" href="#">Adena</a></li>
- <li class="foo"><a class="foo" href="#">Adrian</a></li>
- <li class="foo"><a class="foo" href="#">Akron</a></li>
- <li class="foo"><a class="foo" href="#">Albany</a></li>
- <li class="foo"><a class="foo" href="#">Alexandria</a></li>
- <li class="foo"><a class="foo" href="#">Alger</a></li>
- <li class="foo"><a class="foo" href="#">Alledonia</a></li>
- <li class="foo"><a class="foo" href="#">Alliance</a></li>
- <li class="foo"><a class="foo" href="#">Alpha</a></li>
- <li class="foo"><a class="foo" href="#">Alvada</a></li>
- <li class="foo"><a class="foo" href="#">Alvordton</a></li>
- <li class="foo"><a class="foo" href="#">Amanda</a></li>
- <li class="foo"><a class="foo" href="#">Amelia</a></li>
- <li class="foo"><a class="foo" href="#">Amesville</a></li>
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a class="foo" href="#">Addyston</a></li>
- <li class="foo"><a class="foo" href="#">Adelphi</a></li>
- <li class="foo"><a class="foo" href="#">Adena</a></li>
- <li class="foo"><a class="foo" href="#">Adrian</a></li>
- <li class="foo"><a class="foo" href="#">Akron</a></li>
- <li class="foo"><a class="foo" href="#">Albany</a></li>
- <li class="foo"><a class="foo" href="#">Alexandria</a></li>
- <li class="foo"><a class="foo" href="#">Alger</a></li>
- <li class="foo"><a class="foo" href="#">Alledonia</a></li>
- <li class="foo"><a class="foo" href="#">Alliance</a></li>
- <li class="foo"><a class="foo" href="#">Alpha</a></li>
- <li class="foo"><a class="foo" href="#">Alvada</a></li>
- <li class="foo"><a class="foo" href="#">Alvordton</a></li>
- <li class="foo"><a class="foo" href="#">Amanda</a></li>
- <li class="foo"><a class="foo" href="#">Amelia</a></li>
- <li class="foo"><a class="foo" href="#">Amesville</a></li>
+ <li class="foo">Adamsville</li>
+ <li class="foo">Addyston</li>
+ <li class="foo">Adelphi</li>
+ <li class="foo">Adena</li>
+ <li class="foo">Adrian</li>
+ <li class="foo">Akron</li>
+ <li class="foo">Albany</li>
+ <li class="foo">Alexandria</li>
+ <li class="foo">Alger</li>
+ <li class="foo">Alledonia</li>
+ <li class="foo">Alliance</li>
+ <li class="foo">Alpha</li>
+ <li class="foo">Alvada</li>
+ <li class="foo">Alvordton</li>
+ <li class="foo">Amanda</li>
+ <li class="foo">Amelia</li>
+ <li class="foo">Amesville</li>
+ <li class="foo">Aberdeen</li>
+ <li class="foo">Ada</li>
+ <li class="foo">Adamsville</li>
+ <li class="foo">Addyston</li>
+ <li class="foo">Adelphi</li>
+ <li class="foo">Adena</li>
+ <li class="foo">Adrian</li>
+ <li class="foo">Akron</li>
+ <li class="foo">Albany</li>
+ <li class="foo">Alexandria</li>
+ <li class="foo">Alger</li>
+ <li class="foo">Alledonia</li>
+ <li class="foo">Alliance</li>
+ <li class="foo">Alpha</li>
+ <li class="foo">Alvada</li>
+ <li class="foo">Alvordton</li>
+ <li class="foo">Amanda</li>
+ <li class="foo">Amelia</li>
+ <li class="foo">Amesville</li>
</ul>
<div id="menu5">
- <blockquote><a href="#">Aberdeen</a></blockquote>
- <blockquote><a href="#">Ada</a></blockquote>
- <blockquote><a href="#">Adamsville</a></blockquote>
- <blockquote><a href="#">Addyston</a></blockquote>
- <blockquote>
- <a href="#">Delphi</a>
+ <blockquote>Aberdeen</blockquote>
+ <blockquote>Ada</blockquote>
+ <blockquote>Adamsville</blockquote>
+ <blockquote>Addyston</blockquote>
+ <blockquote>Delphi
<div>
- <blockquote><a href="#">Ada</a></blockquote>
- <blockquote><a href="#">Saarland</a></blockquote>
- <blockquote><a href="#">Salzburg</a></blockquote>
+ <blockquote>Ada</blockquote>
+ <blockquote>Saarland</blockquote>
+ <blockquote>Salzburg</blockquote>
</div>
</blockquote>
- <blockquote><a href="#">Saarland</a></blockquote>
- <blockquote>
- <a href="#">Salzburg</a>
+ <blockquote>Saarland</blockquote>
+ <blockquote>Salzburg
<div>
- <blockquote>
- <a href="#">Delphi</a>
+ <blockquote>Delphi
<div>
- <blockquote><a href="#">Ada</a></blockquote>
- <blockquote><a id="testID2" href="#">Saarland</a></blockquote>
- <blockquote><a href="#">Salzburg</a></blockquote>
+ <blockquote>Ada</blockquote>
+ <blockquote id="testID2">Saarland</blockquote>
+ <blockquote>Salzburg</blockquote>
</div>
</blockquote>
- <blockquote>
- <a href="#">Delphi</a>
+ <blockquote>Delphi
<div>
- <blockquote><a href="#">Ada</a></blockquote>
- <blockquote><a href="#">Saarland</a></blockquote>
- <blockquote><a href="#">Salzburg</a></blockquote>
+ <blockquote>Ada</blockquote>
+ <blockquote>Saarland</blockquote>
+ <blockquote>Salzburg</blockquote>
</div>
</blockquote>
- <blockquote><a href="#">Perch</a></blockquote>
+ <blockquote>Perch</blockquote>
</div>
</blockquote>
</div>
<ul id="menu6">
- <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
- <li class="foo ui-state-disabled"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Adamsville</a></li>
- <li class="foo"><a class="foo" href="#">Addyston</a></li>
- <li class="ui-state-disabled">
- <a id="testID3" href="#">Delphi</a>
+ <li class="foo">Aberdeen</li>
+ <li class="foo ui-state-disabled">Ada</li>
+ <li class="foo">Adamsville</li>
+ <li class="foo">Addyston</li>
+ <li id="testID3" class="ui-state-disabled">Delphi
<ul>
- <li class="foo"><a class="foo" href="#">Ada</a></li>
- <li class="foo"><a class="foo" href="#">Saarland</a></li>
- <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ <li class="foo">Ada</li>
+ <li class="foo">Saarland</li>
+ <li class="foo">Salzburg</li>
</ul>
</li>
- <li class="foo"><a class="foo" href="#">Saarland</a></li>
+ <li class="foo">Saarland</li>
+</ul>
+
+<ul id="menu7">
+ <li class="ui-menu-group"><strong>Group 1</strong></li>
+ <li>Aberdeen</li>
+ <li>Ada</li>
+ <li>Adamsville</li>
+ <li>Addyston</li>
+ <li></li>
+ <li class="ui-menu-group"><strong>Group 2</strong></li>
+ <li>Delphi
+ <ul>
+ <li>Ada</li>
+ <li>Saarland</li>
+ <li>Salzburg</li>
+ </ul>
+ </li>
+ <li>Saarland</li>
+ <li>---</li>
+ <li class="ui-menu-group"><strong>Group 3</strong></li>
+ <li>Salzburg
+ <ul>
+ <li>Delphi
+ <ul>
+ <li>Ada</li>
+ <li> - </li>
+ <li>Saarland</li>
+ <li>&mdash;</li>
+ <li>Salzburg</li>
+ <li>&ndash;</li>
+ </ul>
+ </li>
+ <li>Delphi
+ <ul>
+ <li>Ada</li>
+ <li>Saarland</li>
+ <li>Salzburg</li>
+ </ul>
+ </li>
+ <li>Perch</li>
+ </ul>
+ </li>
+ <li>Amesville</li>
</ul>
</div>
diff --git a/tests/unit/menu/menu_common.js b/tests/unit/menu/menu_common.js
index 4a89a947a..2404ebe02 100644
--- a/tests/unit/menu/menu_common.js
+++ b/tests/unit/menu/menu_common.js
@@ -4,6 +4,7 @@ TestHelpers.commonWidgetTests( "menu", {
icons: {
submenu: "ui-icon-carat-1-e"
},
+ items: "> *",
menus: "ul",
position: {
my: "left top",
diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js
index 5ee28c14a..923d2961e 100644
--- a/tests/unit/menu/menu_core.js
+++ b/tests/unit/menu/menu_core.js
@@ -27,4 +27,22 @@ test( "accessibility", function () {
// Item roles are tested in the role option tests
});
+asyncTest( "#9044: Autofocus issue with dialog opened from menu widget", function() {
+ expect( 1 );
+ var element = $( "#menu1" ).menu();
+
+ $( "<input>", { id: "test9044" } ).appendTo( "body" );
+
+ $( "#testID1" ).bind( "click", function() {
+ $( "#test9044" ).focus();
+ });
+
+ TestHelpers.menu.click( element, "3" );
+ setTimeout( function() {
+ equal( document.activeElement.id, "test9044", "Focus was swallowed by menu" );
+ $( "#test9044" ).remove();
+ start();
+ });
+});
+
})( jQuery );
diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js
index 405300c46..0b89b86ac 100644
--- a/tests/unit/menu/menu_events.js
+++ b/tests/unit/menu/menu_events.js
@@ -91,7 +91,7 @@ asyncTest( "handle focus of menu with active item", function() {
expect( 1 );
var element = $( "#menu1" ).menu({
focus: function( event ) {
- log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
+ log( $( event.target ).find( ".ui-state-focus" ).index() );
}
});
@@ -177,7 +177,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and without submen
log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
- log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
+ log( $( event.target ).find( ".ui-state-focus" ).index() );
}
});
@@ -243,7 +243,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
log( $( ui.item[0] ).text() );
},
focus: function( event ) {
- log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
+ log( $( event.target ).find( ".ui-state-focus" ).index() );
}
});
@@ -341,7 +341,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal( logOutput(), "keydown,5,6,0,1,0,2,4,0", "Keydown skip dividers and items without anchors" );
+ equal( logOutput(), "keydown,5,6,0,1,0,2,4,0", "Keydown skip dividers" );
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
@@ -363,7 +363,7 @@ asyncTest( "handle keyboard navigation on menu with scroll and without submenus"
log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
- log( $( event.target ).find( ".ui-state-focus" ).parent().index());
+ log( $( event.target ).find( ".ui-state-focus" ).index());
}
});
@@ -438,7 +438,7 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f
log( $( ui.item[ 0 ] ).text() );
},
focus: function( event ) {
- log( $( event.target ).find( ".ui-state-focus" ).parent().index());
+ log( $( event.target ).find( ".ui-state-focus" ).index());
}
});
@@ -533,7 +533,7 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite
log( $( ui.item[0] ).text() );
},
focus: function( event ) {
- log( $( event.target ).find( ".ui-state-focus" ).parent().index());
+ log( $( event.target ).find( ".ui-state-focus" ).index());
}
});
@@ -577,11 +577,42 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite
}
});
+asyncTest( "handle keyboard navigation and mouse click on menu with dividers and group labels", function() {
+ expect( 2 );
+ var element = $( "#menu7" ).menu({
+ items: "> :not('.ui-menu-group')",
+ select: function( event, ui ) {
+ log( $( ui.item[0] ).text() );
+ },
+ focus: function( event ) {
+ log( $( event.target ).find( ".ui-state-focus" ).index());
+ }
+ });
+
+ log( "keydown", true );
+ element.one( "menufocus", function() {
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ equal( logOutput(), "keydown,2,Ada", "Keydown skips initial group label" );
+ setTimeout( menukeyboard1, 50 );
+ });
+ element.focus();
+
+ function menukeyboard1() {
+ log( "keydown", true );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equal( logOutput(), "keydown,3,4,7", "Keydown focus skips divider and group label" );
+ start();
+ }
+});
+
asyncTest( "handle keyboard navigation with spelling of menu items", function() {
expect( 2 );
var element = $( "#menu2" ).menu({
focus: function( event ) {
- log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
+ log( $( event.target ).find( ".ui-state-focus" ).index() );
}
});
diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js
index 51d772972..5a633998d 100644
--- a/tests/unit/menu/menu_methods.js
+++ b/tests/unit/menu/menu_methods.js
@@ -73,11 +73,11 @@ test( "refresh icons (see #9377)", function() {
expect( 3 );
var element = $( "#menu1" ).menu();
ok( !element.hasClass( "ui-menu-icons") );
- element.find( "li:first a" ).html( "<span class='ui-icon ui-icon-disk'></span>Save</a>" );
+ element.find( "li:first" ).html( "<span class='ui-icon ui-icon-disk'></span>Save</a>" );
element.menu( "refresh" );
ok( element.hasClass( "ui-menu-icons" ) );
- element.find( "li:first a" ).html( "Save" );
+ element.find( "li:first" ).html( "Save" );
element.menu( "refresh" );
ok( !element.hasClass( "ui-menu-icons" ) );
});
diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js
index 27cea67a4..527cc4784 100644
--- a/tests/unit/menu/menu_options.js
+++ b/tests/unit/menu/menu_options.js
@@ -66,15 +66,14 @@ test( "{ icons: { submenu: 'custom' } }", function() {
test( "{ role: 'menu' } ", function() {
var element = $( "#menu1" ).menu(),
items = element.find( "li" );
- expect( 2 + 5 * items.length );
+ expect( 2 + 4 * items.length );
equal( element.attr( "role" ), "menu" );
ok( items.length > 0, "number of menu items" );
items.each(function( item ) {
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
- equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" );
- equal( $( "a", this ).attr( "role" ), "menuitem", "menu item ("+ item + ") role" );
- ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" );
- equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" );
+ equal( $( this ).attr( "role" ), "menuitem", "menu item ("+ item + ") role" );
+ ok( $( this ).hasClass( "ui-corner-all" ), "class for menu item ("+ item + ")" );
+ equal( $( this ).attr( "tabindex" ), "-1", "tabindex for menu item ("+ item + ")" );
});
});
@@ -83,15 +82,14 @@ test( "{ role: 'listbox' } ", function() {
role: "listbox"
}),
items = element.find( "li" );
- expect( 2 + 5 * items.length );
+ expect( 2 + 4 * items.length );
equal( element.attr( "role" ), "listbox" );
ok( items.length > 0, "number of menu items" );
items.each(function( item ) {
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
- equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" );
- equal( $( "a", this ).attr( "role" ), "option", "menu item ("+ item + ") role" );
- ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" );
- equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" );
+ equal( $( this ).attr( "role" ), "option", "menu item ("+ item + ") role" );
+ ok( $( this ).hasClass( "ui-corner-all" ), "class for menu item ("+ item + ")" );
+ equal( $( this ).attr( "tabindex" ), "-1", "tabindex for menu item ("+ item + ")" );
});
});
@@ -100,15 +98,14 @@ test( "{ role: null }", function() {
role: null
}),
items = element.find( "li" );
- expect( 2 + 5 * items.length );
+ expect( 2 + 4 * items.length );
strictEqual( element.attr( "role" ), undefined );
ok( items.length > 0, "number of menu items" );
items.each(function( item ) {
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
- equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" );
- equal( $( "a", this ).attr( "role" ), undefined, "menu item ("+ item + ") role" );
- ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" );
- equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" );
+ equal( $( this ).attr( "role" ), undefined, "menu item ("+ item + ") role" );
+ ok( $( this ).hasClass( "ui-corner-all" ), "class for menu item ("+ item + ")" );
+ equal( $( this ).attr( "tabindex" ), "-1", "tabindex for menu item ("+ item + ")" );
});
});
diff --git a/tests/unit/menu/menu_test_helpers.js b/tests/unit/menu/menu_test_helpers.js
index b6c09ad7a..77737c390 100644
--- a/tests/unit/menu/menu_test_helpers.js
+++ b/tests/unit/menu/menu_test_helpers.js
@@ -24,7 +24,7 @@ TestHelpers.menu = {
click: function( menu, item ) {
lastItem = item;
- menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" );
+ menu.children( ":eq(" + item + ")" ).trigger( "click" );
}
};