11cb0ef41Sopenharmony_ci// META: global=window,worker 21cb0ef41Sopenharmony_ci// META: script=/common/sab.js 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci["ArrayBuffer", "SharedArrayBuffer"].forEach(arrayBufferOrSharedArrayBuffer => { 51cb0ef41Sopenharmony_ci test(() => { 61cb0ef41Sopenharmony_ci const buf = createBuffer(arrayBufferOrSharedArrayBuffer, 2); 71cb0ef41Sopenharmony_ci const view = new Uint8Array(buf); 81cb0ef41Sopenharmony_ci const buf2 = createBuffer(arrayBufferOrSharedArrayBuffer, 2); 91cb0ef41Sopenharmony_ci const view2 = new Uint8Array(buf2); 101cb0ef41Sopenharmony_ci const decoder = new TextDecoder("utf-8"); 111cb0ef41Sopenharmony_ci view[0] = 0xEF; 121cb0ef41Sopenharmony_ci view[1] = 0xBB; 131cb0ef41Sopenharmony_ci view2[0] = 0xBF; 141cb0ef41Sopenharmony_ci view2[1] = 0x40; 151cb0ef41Sopenharmony_ci assert_equals(decoder.decode(buf, {stream:true}), ""); 161cb0ef41Sopenharmony_ci view[0] = 0x01; 171cb0ef41Sopenharmony_ci view[1] = 0x02; 181cb0ef41Sopenharmony_ci assert_equals(decoder.decode(buf2), "@"); 191cb0ef41Sopenharmony_ci }, "Modify buffer after passing it in (" + arrayBufferOrSharedArrayBuffer + ")"); 201cb0ef41Sopenharmony_ci}); 21