asyncHelpers-asyncTest-return-not-thenable.js (793B)
1 // Copyright (C) 2022 Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 description: | 5 The 'asyncTest' helper rejects test functions that do not return a thenable. 6 includes: [asyncHelpers.js, compareArray.js] 7 ---*/ 8 9 const doneValues = []; 10 function $DONE(error) { 11 // Will be a TypeError from trying to invoke .then() on non-thenable 12 doneValues.push(error instanceof TypeError); 13 } 14 asyncTest(function () { 15 return null; 16 }); 17 asyncTest(function () { 18 return {}; 19 }); 20 asyncTest(function () { 21 return "string"; 22 }); 23 asyncTest(function () { 24 return 42; 25 }); 26 asyncTest(function () {}); 27 asyncTest(function () { 28 return function () {}; 29 }); 30 assert.compareArray(doneValues, [true, true, true, true, true, true]); 31 32 reportCompare(0, 0);