test that middle click doesn't trigger a page change

This commit is contained in:
John Bender 2011-09-15 10:25:04 -07:00
parent 416b666ca8
commit 9cc8daa91a
2 changed files with 40 additions and 0 deletions

View file

@ -263,5 +263,13 @@
<a href="#active-state-page1" data-nstest-rel="back" data-nstest-role="button">back button</a>
</div>
</div>
<div id="odd-clicks-page" data-nstest-role="page">
<a href="#odd-clicks-page-dest" id="right-or-middle-click">foo</a>
</div>
<div id="odd-clicks-page-dest" data-nstest-role="page"></div>
</body>
</html>

View file

@ -787,6 +787,38 @@
]);
});
asyncTest( "clicks with middle mouse button are ignored", function() {
$.testHelper.pageSequence([
function() {
$.testHelper.openPage( "#odd-clicks-page" );
},
function() {
$( "#right-or-middle-click" ).click();
},
// make sure the page is opening first without the mocked button click value
// only necessary to prevent issues with test specific fixtures
function() {
same($.mobile.activePage[0], $("#odd-clicks-page-dest")[0]);
$.testHelper.openPage( "#odd-clicks-page" );
// mock the which value to simulate a middle click
$.Event.prototype.which = 2;
},
function() {
$( "#right-or-middle-click" ).click();
},
function( timeout ) {
ok( timeout, "page event handler timed out due to ignored click" );
ok($.mobile.activePage[0] !== $("#odd-clicks-page-dest")[0], "pages are not the same");
start();
}
]);
});
asyncTest( "handling of button active state when navigating by clicking back button", 1, function(){
$.testHelper.pageSequence([
// open our test page