Permalink
Browse files

test that middle click doesn't trigger a page change

  • Loading branch information...
1 parent 416b666 commit 9cc8daa91a432c692d426c662c03b193191a4520 @johnbender johnbender committed Sep 15, 2011
Showing with 40 additions and 0 deletions.
  1. +8 −0 tests/unit/navigation/index.html
  2. +32 −0 tests/unit/navigation/navigation_core.js
@@ -263,5 +263,13 @@ <h2 id="qunit-userAgent"></h2>
<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>
@@ -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

0 comments on commit 9cc8daa

Please sign in to comment.