diff --git a/packages/ses/src/intrinsics.js b/packages/ses/src/intrinsics.js index 6dd17b58ee..ad8bc3ed42 100644 --- a/packages/ses/src/intrinsics.js +++ b/packages/ses/src/intrinsics.js @@ -48,7 +48,9 @@ function initProperty(obj, name, desc) { preDesc.enumerable !== desc.enumerable || preDesc.configurable !== desc.configurable ) { - throw TypeError(`Conflicting definitions of ${name}`); + if (name !== 'harden') { + throw TypeError(`Conflicting definitions of ${name}`); + } } } defineProperty(obj, name, desc); diff --git a/packages/ses/src/make-hardener.js b/packages/ses/src/make-hardener.js index d377fd8793..0af5908b4a 100644 --- a/packages/ses/src/make-hardener.js +++ b/packages/ses/src/make-hardener.js @@ -26,7 +26,7 @@ import { String, TypeError, WeakSet, - globalThis, + // globalThis, // if we suppress native harden apply, arrayForEach, defineProperty, @@ -128,11 +128,14 @@ const freezeTypedArray = array => { * @returns {Harden} */ export const makeHardener = () => { - // Use a native hardener if possible. - if (typeof globalThis.harden === 'function') { - const safeHarden = globalThis.harden; - return safeHarden; - } + // TODO Get the native hardener to suppressTrapping at each step, + // rather than freeze. Until then, it is *expensive*! + // + // // Use a native hardener if possible. + // if (typeof globalThis.harden === 'function') { + // const safeHarden = globalThis.harden; + // return safeHarden; + // } const hardened = new WeakSet(); @@ -238,7 +241,9 @@ export const makeHardener = () => { // NOTE: Calls getter during harden, which seems dangerous. // But we're only calling the problematic getter whose // hazards we think we understand. - // @ts-expect-error TS should know FERAL_STACK_GETTER + + // TODO either remove or at-ts-expect-error + // @ts-ignore-error TS should know FERAL_STACK_GETTER // cannot be `undefined` here. // See https://github.com/endojs/endo/pull/2232#discussion_r1575179471 value: apply(FERAL_STACK_GETTER, obj, []), diff --git a/packages/ses/test/native-harden.test.js b/packages/ses/test/native-harden.test.js index 235ef69aa3..90c32b9f35 100644 --- a/packages/ses/test/native-harden.test.js +++ b/packages/ses/test/native-harden.test.js @@ -4,7 +4,7 @@ import { assertFakeFrozen } from './_lockdown-harden-unsafe.js'; // eslint-disable-next-line import/order import test from 'ava'; -test('mocked globalThis.harden', t => { +test.skip('mocked globalThis.harden', t => { t.is(harden, mockHarden); t.is(harden.isFake, true);