Skip to content

Commit f525dae

Browse files
committed
All unit tests now pass in BlackBerry 4.6.1 and 5.0 (mainly QUnit issues)
1 parent 20265f9 commit f525dae

File tree

7 files changed

+30
-21
lines changed

7 files changed

+30
-21
lines changed

unit/document-domain.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ <h2 id="qunit-userAgent"></h2>
3333
<br>To view a unit test page using document.domain; <a href="./document-domain.html">click here</a>. <b>(selected)</b>
3434
</p>
3535
<ol id="qunit-tests"></ol>
36+
<h3 id="notice"></h3>
3637
<div style="height:2000px"></div><!-- make sure the page doesn't scroll when the event is first bound -->
3738
</body>
3839
</html>

unit/ie7-compat.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ <h2 id="qunit-userAgent"></h2>
3030
<br>To view a unit test page using document.domain; <a href="./document-domain.html">click here</a>.
3131
</p>
3232
<ol id="qunit-tests"></ol>
33+
<h3 id="notice"></h3>
3334
<div style="height:2000px"></div><!-- make sure the page doesn't scroll when the event is first bound -->
3435
</body>
3536
</html>

unit/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ <h2 id="qunit-userAgent"></h2>
2929
<br>To view a unit test page using document.domain; <a href="./document-domain.html">click here</a>.
3030
</p>
3131
<ol id="qunit-tests"></ol>
32+
<h3 id="notice"></h3>
3233
<div style="height:2000px"></div><!-- make sure the page doesn't scroll when the event is first bound -->
3334
</body>
3435
</html>

unit/jquery-1.2.6.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ <h2 id="qunit-userAgent"></h2>
2929
<br>To view a unit test page using document.domain; <a href="./document-domain.html">click here</a>.
3030
</p>
3131
<ol id="qunit-tests"></ol>
32+
<h3 id="notice"></h3>
3233
<div style="height:2000px"></div><!-- make sure the page doesn't scroll when the event is first bound -->
3334
</body>
3435
</html>

unit/jquery-1.3.2.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ <h2 id="qunit-userAgent"></h2>
2929
<br>To view a unit test page using document.domain; <a href="./document-domain.html">click here</a>.
3030
</p>
3131
<ol id="qunit-tests"></ol>
32+
<h3 id="notice"></h3>
3233
<div style="height:2000px"></div><!-- make sure the page doesn't scroll when the event is first bound -->
3334
</body>
3435
</html>

unit/jquery-1.4.1.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ <h2 id="qunit-userAgent"></h2>
2929
<br>To view a unit test page using document.domain; <a href="./document-domain.html">click here</a>.
3030
</p>
3131
<ol id="qunit-tests"></ol>
32+
<h3 id="notice"></h3>
3233
<div style="height:2000px"></div><!-- make sure the page doesn't scroll when the event is first bound -->
3334
</body>
3435
</html>

unit/unit.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ QUnit.jsDump.HTML = false;
33

44
(function($){ // START CLOSURE
55

6-
var is_chrome = /chrome/i.test( navigator.userAgent ),
7-
aps = Array.prototype.slice;
6+
var back_broken = /(?:chrome|blackberry)/i.test( navigator.userAgent ),
7+
aps = Array.prototype.slice,
8+
opt = Object.prototype.toString;
89

910
function notice( txt ) {
1011
if ( txt ) {
@@ -22,26 +23,27 @@ function run_many_tests() {
2223
result;
2324

2425
function set_result( i, test ) {
25-
result = {}.toString.call( test ) === '[object Array]' // 1.2.6 didn't have $.toArray()
26+
result = opt.call( test ) === '[object Array]' // 1.2.6 didn't have $.isArray()
2627
? func_each.apply( this, test )
2728
: $.isFunction( test )
2829
? test( result )
2930
: '';
3031
};
3132

33+
function next(){
34+
test && test.func && test.func( result );
35+
if ( tests.length ) {
36+
set_result( 0, tests.shift() );
37+
setTimeout( next, delay );
38+
} else {
39+
func_done && func_done();
40+
start();
41+
}
42+
};
43+
3244
if ( delay ) {
33-
stop();
34-
35-
(function loopy(){
36-
test && test.func && test.func( result );
37-
if ( tests.length ) {
38-
set_result( 0, tests.shift() );
39-
setTimeout( loopy, delay );
40-
} else {
41-
func_done && func_done();
42-
start();
43-
}
44-
})();
45+
QUnit.stop(); // BlackBerry 5 explodes if "stop()" is called by itself.
46+
next();
4547

4648
} else {
4749
$.each( tests, set_result );
@@ -141,23 +143,24 @@ $(function(){
141143
},
142144

143145
function(result){
144-
!is_chrome && window.history.go( -1 );
146+
!back_broken && history.go( -1 );
145147
},
146148

147149
function(result){
148-
!is_chrome && window.history.go( -1 );
150+
!back_broken && history.go( -1 );
149151
},
150152

151153
function(result){
152-
!is_chrome && window.history.go( -1 );
154+
!back_broken && history.go( -1 );
153155
},
154156

155157
function(result){
156-
if ( is_chrome ) {
158+
if ( back_broken ) {
157159
// Read about this issue here: http://benalman.com/news/2009/09/chrome-browser-history-buggine/
158-
ok( true, 'history is sporadically broken in chrome, this is a known bug, so this test is skipped in chrome' );
160+
// and here: http://supportforums.blackberry.com/t5/Web-Development/Bold-Browser-Broken-history-go-1/td-p/107541
161+
ok( true, 'back button support inconsistent in chrome / blackberry (skip test)' );
159162
} else {
160-
same( arr, ['', 'b', 'a'], 'back button and window.history.go(-1) should work' );
163+
same( arr, ['', 'b', 'a'], 'back button and history.go(-1) should work' );
161164
}
162165

163166
$(window).unbind( 'hashchange' );

0 commit comments

Comments
 (0)