From d214edb945494a882d72c588e07b47736f9075fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 27 Apr 2017 20:22:41 +0200 Subject: [PATCH] SpecialJavaScriptTest: Make sure we don't catch our own exception If the jQuery promise returned by mw.loader.using() is rejected synchronously (e.g. because one of the modules has a dependency on non-existent module), the function passed to fail() also executes synchronously. Note that this is true also with jQuery 3. The exception it throws was caught by the catch() below, which resulted in start() being called twice, which resulted in QUnit throwing 'Uncaught Error: Called start() outside of a test context too many times' rather than actually starting. Change-Id: I5c6b50647c0af0fdec6547aaa59165f6b4a42642 --- includes/specials/SpecialJavaScriptTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialJavaScriptTest.php b/includes/specials/SpecialJavaScriptTest.php index 52064b79f5..17c64c8ede 100644 --- a/includes/specials/SpecialJavaScriptTest.php +++ b/includes/specials/SpecialJavaScriptTest.php @@ -143,7 +143,11 @@ class SpecialJavaScriptTest extends SpecialPage { .always( function () { start(); } ) - .fail( function ( e ) { throw e; } ); + .fail( function ( e ) { + setTimeout( function () { + throw e; + } ); + } ); } catch ( e ) { start(); throw e; -- 2.20.1