11cb0ef41Sopenharmony_ci// META: global=window,worker 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst error1 = new Error('error1'); 51cb0ef41Sopenharmony_cierror1.name = 'error1'; 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst error2 = new Error('error2'); 81cb0ef41Sopenharmony_cierror2.name = 'error2'; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cipromise_test(t => { 111cb0ef41Sopenharmony_ci const ws = new WritableStream({ 121cb0ef41Sopenharmony_ci start(controller) { 131cb0ef41Sopenharmony_ci controller.error(error1); 141cb0ef41Sopenharmony_ci } 151cb0ef41Sopenharmony_ci }); 161cb0ef41Sopenharmony_ci return promise_rejects_exactly(t, error1, ws.getWriter().closed, 'stream should be errored'); 171cb0ef41Sopenharmony_ci}, 'controller.error() should error the stream'); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_citest(() => { 201cb0ef41Sopenharmony_ci let controller; 211cb0ef41Sopenharmony_ci const ws = new WritableStream({ 221cb0ef41Sopenharmony_ci start(c) { 231cb0ef41Sopenharmony_ci controller = c; 241cb0ef41Sopenharmony_ci } 251cb0ef41Sopenharmony_ci }); 261cb0ef41Sopenharmony_ci ws.abort(); 271cb0ef41Sopenharmony_ci controller.error(error1); 281cb0ef41Sopenharmony_ci}, 'controller.error() on erroring stream should not throw'); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_cipromise_test(t => { 311cb0ef41Sopenharmony_ci let controller; 321cb0ef41Sopenharmony_ci const ws = new WritableStream({ 331cb0ef41Sopenharmony_ci start(c) { 341cb0ef41Sopenharmony_ci controller = c; 351cb0ef41Sopenharmony_ci } 361cb0ef41Sopenharmony_ci }); 371cb0ef41Sopenharmony_ci controller.error(error1); 381cb0ef41Sopenharmony_ci controller.error(error2); 391cb0ef41Sopenharmony_ci return promise_rejects_exactly(t, error1, ws.getWriter().closed, 'first controller.error() should win'); 401cb0ef41Sopenharmony_ci}, 'surplus calls to controller.error() should be a no-op'); 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_cipromise_test(() => { 431cb0ef41Sopenharmony_ci let controller; 441cb0ef41Sopenharmony_ci const ws = new WritableStream({ 451cb0ef41Sopenharmony_ci start(c) { 461cb0ef41Sopenharmony_ci controller = c; 471cb0ef41Sopenharmony_ci } 481cb0ef41Sopenharmony_ci }); 491cb0ef41Sopenharmony_ci return ws.abort().then(() => { 501cb0ef41Sopenharmony_ci controller.error(error1); 511cb0ef41Sopenharmony_ci }); 521cb0ef41Sopenharmony_ci}, 'controller.error() on errored stream should not throw'); 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_cipromise_test(() => { 551cb0ef41Sopenharmony_ci let controller; 561cb0ef41Sopenharmony_ci const ws = new WritableStream({ 571cb0ef41Sopenharmony_ci start(c) { 581cb0ef41Sopenharmony_ci controller = c; 591cb0ef41Sopenharmony_ci } 601cb0ef41Sopenharmony_ci }); 611cb0ef41Sopenharmony_ci return ws.getWriter().close().then(() => { 621cb0ef41Sopenharmony_ci controller.error(error1); 631cb0ef41Sopenharmony_ci }); 641cb0ef41Sopenharmony_ci}, 'controller.error() on closed stream should not throw'); 65