diff options
author | Michał Gołębiowski <m.goleb@gmail.com> | 2016-01-20 13:54:31 +0100 |
---|---|---|
committer | Michał Gołębiowski <m.goleb@gmail.com> | 2016-01-20 13:54:31 +0100 |
commit | 5c01cb1cc4a41b29d6739d061de8217c33037639 (patch) | |
tree | 43f2206451ba042acbfa48d545dbe27b6dd1f901 /test/unit/deferred.js | |
parent | 250fd800a171cac9ab713cbbe1a70a90a348e3dc (diff) | |
download | jquery-5c01cb1cc4a41b29d6739d061de8217c33037639.tar.gz jquery-5c01cb1cc4a41b29d6739d061de8217c33037639.zip |
Tests: Fix Deferred tests in Android 5.0's stock Chrome browser & Yandex.Browser
Some Chrome versions newer than 30 but older than 42 display the "undefined is
not a function" error, not mentioning the function name. This has been fixed
in Chrome 42. Relax two tests to allow for this divergence in older Chromoiums.
This affects our Android 5.0 & Yandex.Browser testing.
Diffstat (limited to 'test/unit/deferred.js')
-rw-r--r-- | test/unit/deferred.js | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/test/unit/deferred.js b/test/unit/deferred.js index d65ce34ca..e2683fd92 100644 --- a/test/unit/deferred.js +++ b/test/unit/deferred.js @@ -534,14 +534,32 @@ QUnit[ window.console ? "test" : "skip" ]( "jQuery.Deferred.exceptionHook", func oldWarn = window.console.warn; window.console.warn = function( msg ) { - assert.ok( /barf/.test( msg ), "Message: " + msg ); + + // Support: Chrome < 42 + // Some Chrome versions newer than 30 but older than 42 display the "undefined is + // not a function" error, not mentioning the function name. This has been fixed + // in Chrome 42. Relax this test there. + // This affects our Android 5.0 & Yandex.Browser testing. + var oldChromium = false; + if ( /chrome/i.test( navigator.userAgent ) ) { + oldChromium = parseInt( + navigator.userAgent.match( /chrome\/(\d+)/i )[ 1 ], 10 ) < 42; + } + if ( oldChromium ) { + assert.ok( /(?:barf|undefined)/.test( msg ), "Message: " + msg ); + } else { + assert.ok( /barf/.test( msg ), "Message: " + msg ); + } }; jQuery.when( defer.then( function() { + // Should get an error jQuery.barf(); } ).then( null, jQuery.noop ), + defer.then( function() { + // Should NOT get an error throw new Error( "Make me a sandwich" ); } ).then( null, jQuery.noop ) @@ -562,6 +580,7 @@ QUnit[ window.console ? "test" : "skip" ]( "jQuery.Deferred.exceptionHook with s oldWarn = window.console.warn; jQuery.Deferred.getStackHook = function() { + // Default exceptionHook assumes the stack is in a form console.warn can log, // but a custom getStackHook+exceptionHook pair could save a raw form and // format it to a string only when an exception actually occurs. @@ -570,7 +589,22 @@ QUnit[ window.console ? "test" : "skip" ]( "jQuery.Deferred.exceptionHook with s }; window.console.warn = function( msg, stack ) { - assert.ok( /cough_up_hairball/.test( msg ), "Function mentioned: " + msg ); + + // Support: Chrome < 42 + // Some Chrome versions newer than 30 but older than 42 display the "undefined is + // not a function" error, not mentioning the function name. This has been fixed + // in Chrome 42. Relax this test there. + // This affects our Android 5.0 & Yandex.Browser testing. + var oldChromium = false; + if ( /chrome/i.test( navigator.userAgent ) ) { + oldChromium = parseInt( + navigator.userAgent.match( /chrome\/(\d+)/i )[ 1 ], 10 ) < 42; + } + if ( oldChromium ) { + assert.ok( /(?:cough_up_hairball|undefined)/.test( msg ), "Function mentioned: " + msg ); + } else { + assert.ok( /cough_up_hairball/.test( msg ), "Function mentioned: " + msg ); + } assert.ok( /NO STACK FOR YOU/.test( stack ), "Stack trace included: " + stack ); }; defer.then( function() { |