Skip to content

Commit

Permalink
fix(ses): #2684 without native harden
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jan 6, 2025
1 parent 9e6303d commit fc24fe3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion packages/ses/src/intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions packages/ses/src/make-hardener.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
String,
TypeError,
WeakSet,
globalThis,
// globalThis, // if we suppress native harden
apply,
arrayForEach,
defineProperty,
Expand Down Expand Up @@ -131,13 +131,13 @@ const freezeTypedArray = array => {
export const makeHardener = () => {
// TODO Get the native hardener to suppressTrapping at each step,
// rather than freeze. Until then, we cannot use it, which is *expensive*!
// TODO Comment out the following to skip the native hardener.
// TODO Comment in the following to use the native hardener.
//
// Use a native hardener if possible.
if (typeof globalThis.harden === 'function') {
const safeHarden = globalThis.harden;
return safeHarden;
}
// if (typeof globalThis.harden === 'function') {
// const safeHarden = globalThis.harden;
// return safeHarden;
// }

const hardened = new WeakSet();

Expand Down
2 changes: 1 addition & 1 deletion packages/ses/test/native-harden.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit fc24fe3

Please sign in to comment.