Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

raises: ignore global exceptions stemming from test. Fixes #257 - Globally-executed...
authorRichard Gibson <richard.gibson@gmail.com>
Fri, 8 Jun 2012 14:23:49 +0000 (10:23 -0400)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Fri, 8 Jun 2012 15:08:43 +0000 (17:08 +0200)
qunit/qunit.js
test/test.js

index 8e1239a..47b3b0b 100644 (file)
@@ -469,11 +469,13 @@ QUnit.assert = {
                        expected = null;
                }
 
+               config.current.ignoreGlobalErrors = true;
                try {
                        block.call( config.current.testEnvironment );
                } catch (e) {
                        actual = e;
                }
+               config.current.ignoreGlobalErrors = false;
 
                if ( actual ) {
                        // we don't want to validate thrown error
@@ -936,6 +938,9 @@ addEvent( window, "load", QUnit.load );
 // addEvent(window, "error" ) gives us a useless event object
 window.onerror = function( message, file, line ) {
        if ( QUnit.config.current ) {
+               if ( QUnit.config.current.ignoreGlobalErrors ) {
+                       return true;
+               }
                QUnit.pushFailure( message, file + ":" + line );
        } else {
                QUnit.test( "global failure", function() {
index f0292f6..f79591b 100644 (file)
@@ -321,6 +321,15 @@ test("raises",function() {
                "custom validation function"
        );
 
+       raises(
+               function() {
+                       ( window.execScript || function( data ) {
+                               window["eval"].call( window, data );
+                       })( "throw 'error'" );
+               },
+               'globally-executed errors caught'
+       );
+
     this.CustomError = CustomError;
 
     raises(

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf