added two helpers and tests for proper url stack history traversal

This commit is contained in:
John Bender 2011-02-25 23:22:05 -08:00
parent 20dce2ce42
commit 86eceb03fc
4 changed files with 45 additions and 0 deletions

View file

@ -53,6 +53,16 @@
} else {
setTimeout($.testHelper.hideActivePageWhenComplete, 500);
}
},
openPage: function(hash){
location.href = location.href.split('#')[0] + hash;
},
sequence: function(fns, interval){
$.each(fns, function(i, fn){
setTimeout(fn, i * interval);
});
}
};
})(jQuery);

View file

@ -0,0 +1 @@
johnbender@john-benders-macbook-pro.local.504

View file

@ -94,5 +94,23 @@
<div id="no-trans-dialog" data-role="page">
</div>
<div id="dup-history-first" data-role="page">
<a href="#dup-history-second" data-transition="slideup" data-role="button" >
Page 2
</a>
</div>
<div id="dup-history-second" data-role="page">
<a href="#dup-history-first" data-transition="slideup" data-role="button">
Page 1
</a>
<a href="#dup-history-dialog" data-role="button" data-transition="pop" data-rel="dialog">Dialog</a>
</div>
<div id="dup-history-dialog" data-role="dialog">
<div data-role="header" data-position="inline">
<h1>Dialog</h1>
</div>
</div>
</body>
</html>

View file

@ -228,5 +228,21 @@
test( "data url works when role and url are reversed on the page element", function(){
testDataUrlHash("#reverse-attr-data-url a", /^#foo\/bar\/reverse.html$/);
});
asyncTest( "last entry choosen amongst multiple identical url history stack entries on hash change", function(){
$.testHelper.openPage("#dup-history-first");
$.testHelper.sequence([
function(){ $("#dup-history-first a").click(); },
function(){ $("#dup-history-second a:first").click(); },
function(){ $("#dup-history-first a").click(); },
function(){ $("#dup-history-second a:last").click(); },
function(){ $("#dup-history-dialog .ui-icon-delete").click(); },
function(){
// third page because the first opened page is manual hash manip
same($.mobile.urlHistory.activeIndex, 3, "should be the third page in the stack");
start();
}], 1000);
});
})(jQuery);