From 0dc54d59a267563b6bdb0304075231c26cda20ea Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Thu, 11 Aug 2011 20:03:36 -0500 Subject: [PATCH 01/15] Fix for Split Button List dialog having no background and weird line from background image --- docs/lists/lists-split-purchase.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/lists/lists-split-purchase.html b/docs/lists/lists-split-purchase.html index 17e8c5ac..f62f2808 100755 --- a/docs/lists/lists-split-purchase.html +++ b/docs/lists/lists-split-purchase.html @@ -14,7 +14,7 @@ -
+

Purchase?

From fb0f6baf2470900f087eba0f2653b747534500b3 Mon Sep 17 00:00:00 2001 From: John Bender Date: Thu, 11 Aug 2011 22:32:59 -0700 Subject: [PATCH 02/15] refactor of test suite runner, added passed/failed counts to suite results --- tests/unit/runner.js | 94 +++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 44 deletions(-) diff --git a/tests/unit/runner.js b/tests/unit/runner.js index 2f36e1ed..bc741e96 100644 --- a/tests/unit/runner.js +++ b/tests/unit/runner.js @@ -1,58 +1,64 @@ -(function(){ - var test = function(data){ - var $frameElem = $("#testFrame"), - template = $frameElem.attr("data-src"), - updateFrame = function(dir){ - return $frameElem.attr("src", template.replace("{{testdir}}", dir)); - }; +$(function() { + var Runner = function( ) { + var self = this; - $.each(data.directories, function(i, dir){ - asyncTest( dir, function(){ - var testTimeout = 3 * 60 * 1000, checkInterval = 2000; + $.extend( self, { + frame: window.frames[ "testFrame" ], - // establish a timeout for a given suite in case of async tests hanging - var testTimer = setTimeout( function(){ - // prevent any schedule checks for completion - clearTimeouts(); - start(); - }, testTimeout ), + testTimeout: 3 * 60 * 1000, - checkTimer = setInterval( check, checkInterval ), + $frameElem: $( "#testFrame" ), - clearTimeouts = function(){ - // prevent the next interval of the check function and the test timeout - clearTimeout( checkTimer ); - clearTimeout( testTimer ); - }; + onTimeout: QUnit.start, - // check the iframe for success or failure and respond accordingly - function check(){ - // check for the frames jquery object each time - var framejQuery = window.frames["testFrame"].jQuery; + onFrameDone: function( failed, passed, total, runtime ){ + // record success + self.recordResult( false , failed ); + self.recordResult( true , passed ); - // if the iframe hasn't loaded (ie loaded jQuery) check back again shortly - if( !framejQuery ) return; + // make sure we don't time out the tests + clearTimeout( self.testTimer ); - // grab the result of the iframe test suite - // TODO strip extra white space - var result = framejQuery( "#qunit-banner" ).attr( "class" ); + // TODO decipher actual cause of multiple test results firing twice + // clear the done call to prevent early completion of other test cases + self.frame.QUnit.done = $.noop; - // if we have a result check it, otherwise check back shortly - if( result ){ - ok( result === "qunit-pass" ); - clearTimeouts(); - start(); - } - }; + // continue on to the next suite + QUnit.start(); + }, - expect( 1 ); + recordResult: function( result, count ) { + for( var i = 0; i < count; i++ ) { + ok( result ); + } + }, - // set the test suite page on the iframe - updateFrame( dir ); - }); + createTest: function( dir ) { + // check for the frames jquery object each time + $( "iframe#testFrame" ).one( "load", function() { + + // establish a timeout for a given suite in case of async tests hanging + self.testTimer = setTimeout( self.onTimeout, self.testTimeout ); + + // when the QUnit object reports done in the iframe + // run the onFrameDone method + self.frame.QUnit.done = self.onFrameDone; + }); + }, + + exec: function( data ) { + var template = self.$frameElem.attr( "data-src" ); + + $.each( data.directories, function(i, dir) { + asyncTest( dir, function() { + self.createTest( dir ); + self.$frameElem.attr( "src", template.replace("{{testdir}}", dir) ); + }); + }); + } }); }; // get the test directories - $.get("ls.php", test); -})(); + $.get( "ls.php", (new Runner()).exec ); +}); From 1fd9af8e36440c2c1d94c842951049f1d0fa2381 Mon Sep 17 00:00:00 2001 From: John Bender Date: Thu, 11 Aug 2011 22:55:27 -0700 Subject: [PATCH 03/15] minor refactor to test suite runner, and js moved to head --- tests/unit/index.php | 6 +++--- tests/unit/runner.js | 27 ++++++++++++--------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/unit/index.php b/tests/unit/index.php index 35dbb90e..cdc127fe 100644 --- a/tests/unit/index.php +++ b/tests/unit/index.php @@ -3,6 +3,9 @@ + + +
@@ -15,8 +18,5 @@ I think an entire link and stylesheet is a waste --> - - - diff --git a/tests/unit/runner.js b/tests/unit/runner.js index bc741e96..0e341c01 100644 --- a/tests/unit/runner.js +++ b/tests/unit/runner.js @@ -11,6 +11,15 @@ $(function() { onTimeout: QUnit.start, + onFrameLoad: function() { + // establish a timeout for a given suite in case of async tests hanging + self.testTimer = setTimeout( self.onTimeout, self.testTimeout ); + + // when the QUnit object reports done in the iframe + // run the onFrameDone method + self.frame.QUnit.done = self.onFrameDone; + }, + onFrameDone: function( failed, passed, total, runtime ){ // record success self.recordResult( false , failed ); @@ -33,25 +42,13 @@ $(function() { } }, - createTest: function( dir ) { - // check for the frames jquery object each time - $( "iframe#testFrame" ).one( "load", function() { - - // establish a timeout for a given suite in case of async tests hanging - self.testTimer = setTimeout( self.onTimeout, self.testTimeout ); - - // when the QUnit object reports done in the iframe - // run the onFrameDone method - self.frame.QUnit.done = self.onFrameDone; - }); - }, - exec: function( data ) { var template = self.$frameElem.attr( "data-src" ); $.each( data.directories, function(i, dir) { - asyncTest( dir, function() { - self.createTest( dir ); + QUnit.asyncTest( dir, function() { + self.dir = dir; + self.$frameElem.one( "load", self.onFrameLoad ); self.$frameElem.attr( "src", template.replace("{{testdir}}", dir) ); }); }); From 781c2430f55ba5bba9001bb3a90ef8f1f6f606eb Mon Sep 17 00:00:00 2001 From: John Bender Date: Fri, 12 Aug 2011 09:51:34 -0700 Subject: [PATCH 04/15] minor whitespace in test runner --- tests/unit/runner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/runner.js b/tests/unit/runner.js index 0e341c01..fda61661 100644 --- a/tests/unit/runner.js +++ b/tests/unit/runner.js @@ -23,7 +23,7 @@ $(function() { onFrameDone: function( failed, passed, total, runtime ){ // record success self.recordResult( false , failed ); - self.recordResult( true , passed ); + self.recordResult( true , passed ); // make sure we don't time out the tests clearTimeout( self.testTimer ); @@ -48,7 +48,7 @@ $(function() { $.each( data.directories, function(i, dir) { QUnit.asyncTest( dir, function() { self.dir = dir; - self.$frameElem.one( "load", self.onFrameLoad ); + self.$frameElem.one( "load", self.onFrameLoad ); self.$frameElem.attr( "src", template.replace("{{testdir}}", dir) ); }); }); From cfe12241a2bc8a20e45f352987cf52642b0c6a28 Mon Sep 17 00:00:00 2001 From: John Bender Date: Fri, 12 Aug 2011 09:56:40 -0700 Subject: [PATCH 05/15] fixedcustom select extension to respect the prototype alterations Fixes #2272 --- js/jquery.mobile.forms.select.custom.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/jquery.mobile.forms.select.custom.js b/js/jquery.mobile.forms.select.custom.js index e00bf114..9640c942 100644 --- a/js/jquery.mobile.forms.select.custom.js +++ b/js/jquery.mobile.forms.select.custom.js @@ -459,9 +459,11 @@ }); }; - $( "select:jqmData(native-menu='false')" ).live( "selectmenubeforecreate", function(){ + $( "select" ).live( "selectmenubeforecreate", function(){ var selectmenuWidget = $( this ).data( "selectmenu" ); - extendSelect( selectmenuWidget ); + if( !selectmenuWidget.options.nativeMenu ){ + extendSelect( selectmenuWidget ); + } }); })( jQuery ); From 2b3153365f629cc69694507325b4a4b732c28187 Mon Sep 17 00:00:00 2001 From: John Bender Date: Fri, 12 Aug 2011 10:39:36 -0700 Subject: [PATCH 06/15] fixed build files to include custom select --- Makefile | 5 +++-- build.xml | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a1705408..7c89afac 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,7 @@ JSFILES = js/jquery.ui.widget.js \ js/jquery.mobile.forms.button.js \ js/jquery.mobile.forms.slider.js \ js/jquery.mobile.forms.textinput.js \ + js/jquery.mobile.forms.select.custom.js \ js/jquery.mobile.forms.select.js \ js/jquery.mobile.buttonMarkup.js \ js/jquery.mobile.controlGroup.js \ @@ -126,7 +127,7 @@ notify: @@echo "The files have been built and are in " $$(pwd)/${OUTPUT} # Pull the latest commits. This is used for the nightly build but can be used to save some keystrokes -pull: +pull: @@git pull --quiet # Zip the 4 files and the theme images into one convenient package @@ -161,7 +162,7 @@ nightly: pull zip # Change the empty paths to the location of this nightly file @@find ${VER} -type f -name '*.html' -exec sed -i 's|href="themes/default/"|href="${NIGHTLY_WEBPATH}/${DIR}.min.css"|g' {} \; @@find ${VER} -type f -name '*.html' -exec sed -i 's|src="js/jquery.js"|src="http://code.jquery.com/jquery-${JQUERY}.min.js"|' {} \; - @@find ${VER} -type f -name '*.html' -exec sed -i 's|src="js/"|src="${NIGHTLY_WEBPATH}/${DIR}.min.js"|g' {} \; + @@find ${VER} -type f -name '*.html' -exec sed -i 's|src="js/"|src="${NIGHTLY_WEBPATH}/${DIR}.min.js"|g' {} \; # Move the demos into the output folder @@mv ${VER} ${OUTPUT}/demos diff --git a/build.xml b/build.xml index 21baaabf..abe8aef2 100644 --- a/build.xml +++ b/build.xml @@ -30,7 +30,7 @@ js/jquery.mobile.core.js, js/jquery.mobile.navigation.js, js/jquery.mobile.transition.js, - js/jquery.mobile.degradeInputs.js, + js/jquery.mobile.degradeInputs.js, js/jquery.mobile.dialog.js, js/jquery.mobile.page.sections.js, js/jquery.mobile.collapsible.js, @@ -44,6 +44,7 @@ js/jquery.mobile.forms.button.js, js/jquery.mobile.forms.slider.js, js/jquery.mobile.forms.textinput.js, + js/jquery.mobile.forms.select.custom.js, js/jquery.mobile.forms.select.js, js/jquery.mobile.buttonMarkup.js, js/jquery.mobile.controlGroup.js, From c5c89344adc79b09a0a35baced2fd840d6b867e0 Mon Sep 17 00:00:00 2001 From: John Bender Date: Fri, 12 Aug 2011 14:41:45 -0700 Subject: [PATCH 07/15] prevent qunit from running the suite until all the tests are defined --- tests/unit/runner.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit/runner.js b/tests/unit/runner.js index fda61661..8ad491ce 100644 --- a/tests/unit/runner.js +++ b/tests/unit/runner.js @@ -52,10 +52,18 @@ $(function() { self.$frameElem.attr( "src", template.replace("{{testdir}}", dir) ); }); }); + + // having defined all suite level tests let QUnit run + QUnit.start(); } }); }; + // prevent qunit from starting the test suite until all tests are defined + QUnit.begin = function( ) { + this.config.autostart = false; + }; + // get the test directories $.get( "ls.php", (new Runner()).exec ); }); From a197e17500ed9f4994f532ab384b0b45b414a1ea Mon Sep 17 00:00:00 2001 From: John Bender Date: Sat, 13 Aug 2011 00:50:16 -0700 Subject: [PATCH 08/15] cleaned up test suite index html, added reporting for failed and successfull tests at the suite level --- tests/unit/index.php | 26 ++++++++++++++++++++++---- tests/unit/runner.js | 25 +++++++++++++++++++------ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/tests/unit/index.php b/tests/unit/index.php index cdc127fe..2ecb3ba5 100644 --- a/tests/unit/index.php +++ b/tests/unit/index.php @@ -6,17 +6,35 @@ + -
+ - - diff --git a/tests/unit/runner.js b/tests/unit/runner.js index 8ad491ce..c0c89aa4 100644 --- a/tests/unit/runner.js +++ b/tests/unit/runner.js @@ -9,6 +9,8 @@ $(function() { $frameElem: $( "#testFrame" ), + assertionResultPrefix: "assertion result for test:", + onTimeout: QUnit.start, onFrameLoad: function() { @@ -18,30 +20,41 @@ $(function() { // when the QUnit object reports done in the iframe // run the onFrameDone method self.frame.QUnit.done = self.onFrameDone; + self.frame.QUnit.testDone = self.onTestDone; + }, + + onTestDone: function( name, bad, assertCount ) { + QUnit.ok( !bad, name ); + self.recordAssertions( assertCount - 1, name ); }, onFrameDone: function( failed, passed, total, runtime ){ - // record success - self.recordResult( false , failed ); - self.recordResult( true , passed ); - // make sure we don't time out the tests clearTimeout( self.testTimer ); // TODO decipher actual cause of multiple test results firing twice // clear the done call to prevent early completion of other test cases self.frame.QUnit.done = $.noop; + self.frame.QUnit.testDone = $.noop; + + // hide the extra assertions made to propogate the count + // to the suite level test + self.hideAssertionResults(); // continue on to the next suite QUnit.start(); }, - recordResult: function( result, count ) { + recordAssertions: function( count, parentTest ) { for( var i = 0; i < count; i++ ) { - ok( result ); + ok( true, self.assertionResultPrefix + parentTest ); } }, + hideAssertionResults: function() { + $( "li:not([id]):contains('" + self.assertionResultPrefix + "')" ).hide(); + }, + exec: function( data ) { var template = self.$frameElem.attr( "data-src" ); From 5c40e69c3af74597a8a86e20db7181a28a55114f Mon Sep 17 00:00:00 2001 From: John Bender Date: Mon, 15 Aug 2011 11:45:47 -0700 Subject: [PATCH 09/15] moved the relative path changing tests to the bottom of the core file, this is not a solution only a temporary fix. moving the relative path changing tests to another test file will most likely be the next move --- tests/unit/select/select_core.js | 201 +++++++++++++------------------ 1 file changed, 84 insertions(+), 117 deletions(-) diff --git a/tests/unit/select/select_core.js b/tests/unit/select/select_core.js index 7a1d91c9..ec462613 100644 --- a/tests/unit/select/select_core.js +++ b/tests/unit/select/select_core.js @@ -71,41 +71,6 @@ ]); }); - asyncTest( "a large select menu should come up in a dialog many times", function(){ - var menu, select; - - // if the second test doesn't run the dialog didn't come back up - expect( 2 ); - - $.testHelper.pageSequence([ - resetHash, - - function(){ - select = $("#select-choice-many-container a"); - - // bring up the dialog - select.trigger("click"); - }, - - function(){ - ok( $.mobile.activePage.is( ".ui-dialog "), "current page is a dialog" ); - closeDialog(); - }, - - function(){ - //bring up the dialog again - select.trigger("click"); - }, - - function(){ - ok( $.mobile.activePage.is( ".ui-dialog "), "current page is a dialog" ); - closeDialog(); - }, - - start - ]); - }); - asyncTest( "custom select menu always renders screen from the left", function(){ var select; @@ -204,6 +169,90 @@ ], 500); }); + asyncTest( "using custom refocuses the button after close", function() { + var select, button, triggered = false; + + expect( 1 ); + + $.testHelper.sequence([ + resetHash, + + function() { + select = $("#select-choice-focus-test"); + button = select.find( "a" ); + button.trigger( "click" ); + }, + + function() { + // NOTE this is called twice per triggered click + button.focus(function() { + triggered = true; + }); + + $(".ui-selectmenu-screen:not(.ui-screen-hidden)").trigger("click"); + }, + + function(){ + ok(triggered, "focus is triggered"); + start(); + } + ], 5000); + }); + + asyncTest( "selected items are highlighted", function(){ + $.testHelper.sequence([ + resetHash, + + function(){ + // bring up the smaller choice menu + ok($("#select-choice-few-container a").length > 0, "there is in fact a button in the page"); + $("#select-choice-few-container a").trigger("click"); + }, + + function(){ + var firstMenuChoice = $("#select-choice-few-menu li:first"); + ok( firstMenuChoice.hasClass( $.mobile.activeBtnClass ), + "default menu choice has the active button class" ); + + $("#select-choice-few-menu a:last").click(); + }, + + function(){ + // bring up the menu again + $("#select-choice-few-container a").trigger("click"); + }, + + function(){ + var lastMenuChoice = $("#select-choice-few-menu li:last"); + ok( lastMenuChoice.hasClass( $.mobile.activeBtnClass ), + "previously slected item has the active button class" ); + + // close the dialog + lastMenuChoice.find( "a" ).click(); + }, + + start + ], 1000); + }); + + test( "enabling and disabling", function(){ + var select = $( "select" ).first(), button; + + button = select.siblings( "a" ).first(); + + select.selectmenu( 'disable' ); + same( select.attr('disabled'), "disabled", "select is disabled" ); + ok( button.hasClass("ui-disabled"), "disabled class added" ); + same( button.attr('aria-disabled'), "true", "select is disabled" ); + same( select.selectmenu( 'option', 'disabled' ), true, "disbaled option set" ); + + select.selectmenu( 'enable' ); + same( select.attr('disabled'), undefined, "select is disabled" ); + ok( !button.hasClass("ui-disabled"), "disabled class added" ); + same( button.attr('aria-disabled'), "false", "select is disabled" ); + same( select.selectmenu( 'option', 'disabled' ), false, "disbaled option set" ); + }); + // https://github.com/jquery/jquery-mobile/issues/2181 asyncTest( "dialog sized select should alter the value of its parent select", function(){ var selectButton, value; @@ -262,86 +311,4 @@ start ]); }); - - asyncTest( "using custom refocuses the button after close", function() { - var select, button, triggered = false; - - expect( 1 ); - - $.testHelper.sequence([ - resetHash, - - function() { - select = $("#select-choice-focus-test"); - button = select.find( "a" ); - button.trigger( "click" ); - }, - - function() { - // NOTE this is called twice per triggered click - button.focus(function() { - triggered = true; - }); - - $(".ui-selectmenu-screen:not(.ui-screen-hidden)").trigger("click"); - }, - - function(){ - ok(triggered, "focus is triggered"); - start(); - } - ], 1000); - }); - - asyncTest( "selected items are highlighted", function(){ - $.testHelper.sequence([ - function(){ - // bring up the smaller choice menu - ok($("#select-choice-few-container a").length > 0, "there is in fact a button in the page"); - $("#select-choice-few-container a").trigger("click"); - }, - - function(){ - var firstMenuChoice = $("#select-choice-few-menu li:first"); - ok( firstMenuChoice.hasClass( $.mobile.activeBtnClass ), - "default menu choice has the active button class" ); - - $("#select-choice-few-menu a:last").click(); - }, - - function(){ - // bring up the menu again - $("#select-choice-few-container a").trigger("click"); - }, - - function(){ - var lastMenuChoice = $("#select-choice-few-menu li:last"); - ok( lastMenuChoice.hasClass( $.mobile.activeBtnClass ), - "previously slected item has the active button class" ); - - // close the dialog - lastMenuChoice.find( "a" ).click(); - }, - - start - ], 1000); - }); - - test( "enabling and disabling", function(){ - var select = $( "select" ).first(), button; - - button = select.siblings( "a" ).first(); - - select.selectmenu( 'disable' ); - same( select.attr('disabled'), "disabled", "select is disabled" ); - ok( button.hasClass("ui-disabled"), "disabled class added" ); - same( button.attr('aria-disabled'), "true", "select is disabled" ); - same( select.selectmenu( 'option', 'disabled' ), true, "disbaled option set" ); - - select.selectmenu( 'enable' ); - same( select.attr('disabled'), undefined, "select is disabled" ); - ok( !button.hasClass("ui-disabled"), "disabled class added" ); - same( button.attr('aria-disabled'), "false", "select is disabled" ); - same( select.selectmenu( 'option', 'disabled' ), false, "disbaled option set" ); - }); })(jQuery); From 5b4a29e643459e0e86a5b9b2b5162a69b707f859 Mon Sep 17 00:00:00 2001 From: John Bender Date: Mon, 15 Aug 2011 12:09:56 -0700 Subject: [PATCH 10/15] added **/*-tests.html glob convention to the test suite runner to make it easier to include seperate files in the suite --- tests/unit/ls.php | 6 ++++-- tests/unit/runner.js | 2 +- tests/unit/select/{cached-tests.html => cached.html} | 0 tests/unit/select/select_core.js | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) rename tests/unit/select/{cached-tests.html => cached.html} (100%) diff --git a/tests/unit/ls.php b/tests/unit/ls.php index 6bcd1d72..2108b544 100644 --- a/tests/unit/ls.php +++ b/tests/unit/ls.php @@ -13,6 +13,8 @@ closedir($handle); } - sort($directories); - echo json_encode( array('directories' => $directories )); + $test_pages = array_merge($directories, glob("**/*-tests.html")); + sort($test_pages); + + echo json_encode( array('testPages' => $test_pages)); ?> \ No newline at end of file diff --git a/tests/unit/runner.js b/tests/unit/runner.js index c0c89aa4..aa956e4c 100644 --- a/tests/unit/runner.js +++ b/tests/unit/runner.js @@ -58,7 +58,7 @@ $(function() { exec: function( data ) { var template = self.$frameElem.attr( "data-src" ); - $.each( data.directories, function(i, dir) { + $.each( data.testPages, function(i, dir) { QUnit.asyncTest( dir, function() { self.dir = dir; self.$frameElem.one( "load", self.onFrameLoad ); diff --git a/tests/unit/select/cached-tests.html b/tests/unit/select/cached.html similarity index 100% rename from tests/unit/select/cached-tests.html rename to tests/unit/select/cached.html diff --git a/tests/unit/select/select_core.js b/tests/unit/select/select_core.js index ec462613..ea804997 100644 --- a/tests/unit/select/select_core.js +++ b/tests/unit/select/select_core.js @@ -261,7 +261,7 @@ resetHash, function(){ - $.mobile.changePage( "cached-tests.html" ); + $.mobile.changePage( "cached.html" ); }, function(){ @@ -293,7 +293,7 @@ resetHash, function(){ - $.mobile.changePage( "cached-tests.html" ); + $.mobile.changePage( "cached.html" ); }, function(){ From b0c20e9d2a10b33c50e17d5bba716235115d759d Mon Sep 17 00:00:00 2001 From: John Bender Date: Mon, 15 Aug 2011 12:45:31 -0700 Subject: [PATCH 11/15] whitespace --- tests/unit/navigation/base-tests/content/content-page-2.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/navigation/base-tests/content/content-page-2.html b/tests/unit/navigation/base-tests/content/content-page-2.html index 871a74f3..76c9bbd5 100644 --- a/tests/unit/navigation/base-tests/content/content-page-2.html +++ b/tests/unit/navigation/base-tests/content/content-page-2.html @@ -8,7 +8,7 @@ Base Page 1 Internal Page 1 Internal Page 2 - +
From 907cf655b3c9cc201924b4635fddd5e6dde45d2b Mon Sep 17 00:00:00 2001 From: John Bender Date: Mon, 15 Aug 2011 12:45:56 -0700 Subject: [PATCH 12/15] fixed navigation base tests to handle the relative internal page issue by using the click hack, per @jblas --- tests/unit/navigation/navigation_base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/navigation/navigation_base.js b/tests/unit/navigation/navigation_base.js index 025d1fb8..db8a81f6 100644 --- a/tests/unit/navigation/navigation_base.js +++ b/tests/unit/navigation/navigation_base.js @@ -21,7 +21,7 @@ $.testHelper.pageSequence([ function(){ // Navigate from default internal page to another internal page. - $.testHelper.openPage("#internal-page-2"); + $.testHelper.openPage("#internal-page-2"); }, function(){ @@ -93,8 +93,8 @@ // Verify that we are on the expected page. same(location.hash, "#" + contentDir + "content-page-2.html", "call changePage() with a relative path should resolve relative to current page"); - // Try calling changePage() with an id - $.mobile.changePage("#internal-page-2"); + // test that an internal page works + $("a.ip2").click(); }, function(){ From 3d14498fe137cef4c404c6546d5fd24b88affe7c Mon Sep 17 00:00:00 2001 From: John Bender Date: Mon, 15 Aug 2011 13:00:01 -0700 Subject: [PATCH 13/15] moved select caching tests out to a seperate test file to prevent issues in the core test suite --- tests/unit/select/cached-tests.html | 27 +++++++++++ tests/unit/select/select_cached.js | 70 +++++++++++++++++++++++++++++ tests/unit/select/select_core.js | 58 ------------------------ 3 files changed, 97 insertions(+), 58 deletions(-) create mode 100644 tests/unit/select/cached-tests.html create mode 100644 tests/unit/select/select_cached.js diff --git a/tests/unit/select/cached-tests.html b/tests/unit/select/cached-tests.html new file mode 100644 index 00000000..5fd212b5 --- /dev/null +++ b/tests/unit/select/cached-tests.html @@ -0,0 +1,27 @@ + + + + + + jQuery Mobile Select Events Test Suite + + + + + + + + + + + + + +

jQuery Mobile Select Event Test Suite

+

+

+
    +
+
+ + diff --git a/tests/unit/select/select_cached.js b/tests/unit/select/select_cached.js new file mode 100644 index 00000000..dbc9f219 --- /dev/null +++ b/tests/unit/select/select_cached.js @@ -0,0 +1,70 @@ +/* + * mobile select unit tests + */ + +(function($){ + var resetHash; + + resetHash = function(timeout){ + $.testHelper.openPage( location.hash.indexOf("#default") >= 0 ? "#" : "#default" ); + }; + + // https://github.com/jquery/jquery-mobile/issues/2181 + asyncTest( "dialog sized select should alter the value of its parent select", function(){ + var selectButton, value; + + $.testHelper.pageSequence([ + resetHash, + + function(){ + $.mobile.changePage( "cached.html" ); + }, + + function(){ + selectButton = $( "#cached-page-select" ).siblings( 'a' ); + selectButton.click(); + }, + + function(){ + ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" ); + var option = $.mobile.activePage.find( "li a" ).not(":contains('" + selectButton.text() + "')").last(); + value = option.text(); + option.click(); + }, + + function(){ + same( value, selectButton.text(), "the selected value is propogated back to the button text" ); + start(); + } + ]); + }); + + // https://github.com/jquery/jquery-mobile/issues/2181 + asyncTest( "dialog sized select should prevent the removal of its parent page from the dom", function(){ + var selectButton, parentPageId; + + expect( 2 ); + + $.testHelper.pageSequence([ + resetHash, + + function(){ + $.mobile.changePage( "cached.html" ); + }, + + function(){ + selectButton = $.mobile.activePage.find( "#cached-page-select" ).siblings( 'a' ); + parentPageId = $.mobile.activePage.attr( 'id' ); + same( $("#" + parentPageId).length, 1, "establish the parent page exists" ); + selectButton.click(); + }, + + function(){ + same( $( "#" + parentPageId).length, 1, "make sure parent page is still there after opening the dialog" ); + $.mobile.activePage.find( "li a" ).last().click(); + }, + + start + ]); + }); +})(jQuery); \ No newline at end of file diff --git a/tests/unit/select/select_core.js b/tests/unit/select/select_core.js index ea804997..f32c345c 100644 --- a/tests/unit/select/select_core.js +++ b/tests/unit/select/select_core.js @@ -253,62 +253,4 @@ same( select.selectmenu( 'option', 'disabled' ), false, "disbaled option set" ); }); - // https://github.com/jquery/jquery-mobile/issues/2181 - asyncTest( "dialog sized select should alter the value of its parent select", function(){ - var selectButton, value; - - $.testHelper.pageSequence([ - resetHash, - - function(){ - $.mobile.changePage( "cached.html" ); - }, - - function(){ - selectButton = $( "#cached-page-select" ).siblings( 'a' ); - selectButton.click(); - }, - - function(){ - ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" ); - var option = $.mobile.activePage.find( "li a" ).not(":contains('" + selectButton.text() + "')").last(); - value = option.text(); - option.click(); - }, - - function(){ - same( value, selectButton.text(), "the selected value is propogated back to the button text" ); - start(); - } - ]); - }); - - // https://github.com/jquery/jquery-mobile/issues/2181 - asyncTest( "dialog sized select should prevent the removal of its parent page from the dom", function(){ - var selectButton, parentPageId; - - expect( 2 ); - - $.testHelper.pageSequence([ - resetHash, - - function(){ - $.mobile.changePage( "cached.html" ); - }, - - function(){ - selectButton = $.mobile.activePage.find( "#cached-page-select" ).siblings( 'a' ); - parentPageId = $.mobile.activePage.attr( 'id' ); - same( $("#" + parentPageId).length, 1, "establish the parent page exists" ); - selectButton.click(); - }, - - function(){ - same( $( "#" + parentPageId).length, 1, "make sure parent page is still there after opening the dialog" ); - $.mobile.activePage.find( "li a" ).last().click(); - }, - - start - ]); - }); })(jQuery); From 9da8114fca900d2a485b0f60c40a8687203bd764 Mon Sep 17 00:00:00 2001 From: Samuel Padou Date: Tue, 16 Aug 2011 13:55:02 +0200 Subject: [PATCH 14/15] add test for domCache option handling when closing a full page select menu --- tests/unit/select/cached-dom-cache-true.html | 65 ++++++++++++++++++++ tests/unit/select/select_cached.js | 31 ++++++++++ 2 files changed, 96 insertions(+) create mode 100755 tests/unit/select/cached-dom-cache-true.html diff --git a/tests/unit/select/cached-dom-cache-true.html b/tests/unit/select/cached-dom-cache-true.html new file mode 100755 index 00000000..b5e719d3 --- /dev/null +++ b/tests/unit/select/cached-dom-cache-true.html @@ -0,0 +1,65 @@ + + + + + + +
+
+ + +
+
+ + diff --git a/tests/unit/select/select_cached.js b/tests/unit/select/select_cached.js index dbc9f219..1dfc54dd 100644 --- a/tests/unit/select/select_cached.js +++ b/tests/unit/select/select_cached.js @@ -67,4 +67,35 @@ start ]); }); + + asyncTest( "dialog sized select shouldn't rebind its parent page remove handler when closing, if the parent page domCache option is true", function(){ + expect( 3 ); + + $.testHelper.pageSequence([ + resetHash, + + function(){ + $.mobile.changePage( "cached-dom-cache-true.html" ); + }, + + function(){ + $.mobile.activePage.find( "#domcache-page-select" ).siblings( 'a' ).click(); + }, + + function(){ + ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" ); + $.mobile.activePage.find( "li a" ).last().click(); + }, + + function(){ + ok( $.mobile.activePage.is( "#dialog-select-parent-domcache-test" ), "the dialog closed" ); + $.mobile.changePage( $( "#default" ) ); + }, + + function(){ + same( $("#dialog-select-parent-domcache-test").length, 1, "make sure the select parent page is still cached in the dom after changing page" ); + start(); + } + ]); + }); })(jQuery); \ No newline at end of file From e8f78dacb1c6a4150ae0158f56ae9a01c5602302 Mon Sep 17 00:00:00 2001 From: Samuel Padou Date: Tue, 16 Aug 2011 13:57:07 +0200 Subject: [PATCH 15/15] check the domCache option before rebinding the page remove when closing a full page select menu --- js/jquery.mobile.forms.select.custom.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/jquery.mobile.forms.select.custom.js b/js/jquery.mobile.forms.select.custom.js index 9640c942..3ec6882b 100644 --- a/js/jquery.mobile.forms.select.custom.js +++ b/js/jquery.mobile.forms.select.custom.js @@ -248,9 +248,11 @@ // rebind the page remove that was unbound in the open function // to allow for the parent page removal from actions other than the use // of a dialog sized custom select - self.thisPage.bind( "pagehide.remove", function() { - $(this).remove(); - }); + if( !self.thisPage.data("page").options.domCache ){ + self.thisPage.bind( "pagehide.remove", function() { + $(this).remove(); + }); + } // doesn't solve the possible issue with calling change page // where the objects don't define data urls which prevents dialog key