Skip to content

Commit

Permalink
test that middle click doesn't trigger a page change
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Sep 15, 2011
1 parent 416b666 commit 9cc8daa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/unit/navigation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,13 @@ <h1>Dialog</h1>
<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>
32 changes: 32 additions & 0 deletions tests/unit/navigation/navigation_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9cc8daa

Please sign in to comment.