diff --git a/reference-implementation/lib/abstract-ops/ecmascript.js b/reference-implementation/lib/abstract-ops/ecmascript.js index 731b38c0..68220078 100644 --- a/reference-implementation/lib/abstract-ops/ecmascript.js +++ b/reference-implementation/lib/abstract-ops/ecmascript.js @@ -1,7 +1,8 @@ 'use strict'; const assert = require('assert'); -const isFakeDetached = Symbol('is "detached" for our purposes'); +const ArrayBufferPrototypeTransferToFixedLength = ArrayBuffer.prototype.transferToFixedLength; +const ArrayBufferPrototypeDetachedGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'detached').get; exports.typeIsObject = x => (typeof x === 'object' && x !== null) || typeof x === 'function'; @@ -15,31 +16,17 @@ exports.CopyDataBlockBytes = (dest, destOffset, src, srcOffset, n) => { new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset); }; -// Not implemented correctly exports.TransferArrayBuffer = O => { assert(!exports.IsDetachedBuffer(O)); - const transferredIshVersion = O.slice(); - - // This is specifically to fool tests that test "is transferred" by taking a non-zero-length - // ArrayBuffer and checking if its byteLength starts returning 0. - Object.defineProperty(O, 'byteLength', { - get() { - return 0; - } - }); - O[isFakeDetached] = true; - - return transferredIshVersion; + return ArrayBufferPrototypeTransferToFixedLength.call(O); }; -// Not implemented correctly exports.CanTransferArrayBuffer = O => { return !exports.IsDetachedBuffer(O); }; -// Not implemented correctly exports.IsDetachedBuffer = O => { - return isFakeDetached in O; + return ArrayBufferPrototypeDetachedGetter.call(O) === true; }; exports.Call = (F, V, args = []) => { diff --git a/reference-implementation/lib/abstract-ops/readable-streams.js b/reference-implementation/lib/abstract-ops/readable-streams.js index cbbb3140..0a7cfaff 100644 --- a/reference-implementation/lib/abstract-ops/readable-streams.js +++ b/reference-implementation/lib/abstract-ops/readable-streams.js @@ -1584,6 +1584,8 @@ function ReadableByteStreamControllerPullInto(controller, view, min, readIntoReq assert(minimumFill >= elementSize && minimumFill <= view.byteLength); assert(minimumFill % elementSize === 0); + const byteOffset = view.byteOffset; + const byteLength = view.byteLength; const ctor = view.constructor; let buffer; @@ -1597,8 +1599,8 @@ function ReadableByteStreamControllerPullInto(controller, view, min, readIntoReq const pullIntoDescriptor = { buffer, bufferByteLength: buffer.byteLength, - byteOffset: view.byteOffset, - byteLength: view.byteLength, + byteOffset, + byteLength, bytesFilled: 0, minimumFill, elementSize, diff --git a/reference-implementation/web-platform-tests b/reference-implementation/web-platform-tests index 186a9fd7..ad6c0aa1 160000 --- a/reference-implementation/web-platform-tests +++ b/reference-implementation/web-platform-tests @@ -1 +1 @@ -Subproject commit 186a9fd7abc3d9c31e2b37680be757e992af9e3a +Subproject commit ad6c0aa100e1fc9d88c8967d55dca004a46a73bd