11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { promisify } = require('util'); 61cb0ef41Sopenharmony_ciconst execFile = require('child_process').execFile; 71cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst echoFixture = fixtures.path('echo.js'); 101cb0ef41Sopenharmony_ciconst promisified = promisify(execFile); 111cb0ef41Sopenharmony_ciconst invalidArgTypeError = { 121cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_TYPE', 131cb0ef41Sopenharmony_ci name: 'TypeError' 141cb0ef41Sopenharmony_ci}; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci{ 171cb0ef41Sopenharmony_ci // Verify that the signal option works properly 181cb0ef41Sopenharmony_ci const ac = new AbortController(); 191cb0ef41Sopenharmony_ci const signal = ac.signal; 201cb0ef41Sopenharmony_ci const promise = promisified(process.execPath, [echoFixture, 0], { signal }); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci ac.abort(); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci assert.rejects( 251cb0ef41Sopenharmony_ci promise, 261cb0ef41Sopenharmony_ci { name: 'AbortError' } 271cb0ef41Sopenharmony_ci ).then(common.mustCall()); 281cb0ef41Sopenharmony_ci} 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci{ 311cb0ef41Sopenharmony_ci // Verify that the signal option works properly when already aborted 321cb0ef41Sopenharmony_ci const signal = AbortSignal.abort(); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci assert.rejects( 351cb0ef41Sopenharmony_ci promisified(process.execPath, [echoFixture, 0], { signal }), 361cb0ef41Sopenharmony_ci { name: 'AbortError' } 371cb0ef41Sopenharmony_ci ).then(common.mustCall()); 381cb0ef41Sopenharmony_ci} 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci{ 411cb0ef41Sopenharmony_ci // Verify that if something different than Abortcontroller.signal 421cb0ef41Sopenharmony_ci // is passed, ERR_INVALID_ARG_TYPE is thrown 431cb0ef41Sopenharmony_ci const signal = {}; 441cb0ef41Sopenharmony_ci assert.throws(() => { 451cb0ef41Sopenharmony_ci promisified(process.execPath, [echoFixture, 0], { signal }); 461cb0ef41Sopenharmony_ci }, invalidArgTypeError); 471cb0ef41Sopenharmony_ci} 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci{ 501cb0ef41Sopenharmony_ci // Verify that if something different than Abortcontroller.signal 511cb0ef41Sopenharmony_ci // is passed, ERR_INVALID_ARG_TYPE is thrown 521cb0ef41Sopenharmony_ci const signal = 'world!'; 531cb0ef41Sopenharmony_ci assert.throws(() => { 541cb0ef41Sopenharmony_ci promisified(process.execPath, [echoFixture, 0], { signal }); 551cb0ef41Sopenharmony_ci }, invalidArgTypeError); 561cb0ef41Sopenharmony_ci} 57