/* * mobile support unit tests */ (function( $ ) { $.testHelper = { // synchronously loads sets of asynchronous dependencies asyncLoad: function( seq ) { function loadSeq( seq, i ){ if( !seq[i] ){ QUnit.start(); return; } // if the file has a dot in the name its most likely a lib file // so we should grab it from the js directory. This could be regarded // as overeager convention ... don't care its a test helper and the // failure will be obvious if it happens (eg "can't load this file") require({ baseUrl: (seq[i][0].indexOf(".") > -1) ? "../../../js" : location.pathname }); require( seq[i], function() { loadSeq(seq, i + 1); }); } // stop qunit from running the tests until everything is in the page QUnit.config.autostart = false; loadSeq( seq, 0 ); }, excludeFileProtocol: function(callback){ var message = "Tests require script reload and cannot be run via file: protocol"; if (location.protocol == "file:") { test(message, function(){ ok(false, message); }); } else { callback(); } }, // TODO prevent test suite loads when the browser doesn't support push state // and push-state false is defined. setPushStateFor: function( libs ) { if( $.support.pushState && location.search.indexOf( "push-state" ) >= 0 ) { $.support.pushState = false; } $.each(libs, function(i, l) { $( "