From 86eceb03fc0e02644d542e702d915cffee087426 Mon Sep 17 00:00:00 2001 From: John Bender Date: Fri, 25 Feb 2011 23:22:05 -0800 Subject: [PATCH] added two helpers and tests for proper url stack history traversal --- tests/jquery.testHelper.js | 10 ++++++++++ tests/unit/listview/.#listview_core.js | 1 + tests/unit/navigation/index.html | 18 ++++++++++++++++++ tests/unit/navigation/navigation_core.js | 16 ++++++++++++++++ 4 files changed, 45 insertions(+) create mode 120000 tests/unit/listview/.#listview_core.js diff --git a/tests/jquery.testHelper.js b/tests/jquery.testHelper.js index b1d94bad..244de4e1 100644 --- a/tests/jquery.testHelper.js +++ b/tests/jquery.testHelper.js @@ -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); \ No newline at end of file diff --git a/tests/unit/listview/.#listview_core.js b/tests/unit/listview/.#listview_core.js new file mode 120000 index 00000000..a59dd872 --- /dev/null +++ b/tests/unit/listview/.#listview_core.js @@ -0,0 +1 @@ +johnbender@john-benders-macbook-pro.local.504 \ No newline at end of file diff --git a/tests/unit/navigation/index.html b/tests/unit/navigation/index.html index 44f9a100..f12cb6d4 100644 --- a/tests/unit/navigation/index.html +++ b/tests/unit/navigation/index.html @@ -94,5 +94,23 @@
+
+ + Page 2 + +
+ +
+ + Page 1 + + Dialog +
+ +
+
+

Dialog

+
+
diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 84defe33..e8257ff5 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -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);