Skip to content

Commit

Permalink
Merge pull request #1651 from endojs/markm-1490-better-safari-debugging
Browse files Browse the repository at this point in the history
fix(ses): better safari debugging
  • Loading branch information
erights authored Jun 24, 2023
2 parents 1e9026d + 8e9ead0 commit 3dac711
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions packages/ses/src/strict-scope-terminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ const scopeProxyHandlerProperties = {

// note: this is likely a bug of safari
// https://bugs.webkit.org/show_bug.cgi?id=195534
getPrototypeOf() {
getPrototypeOf(_shadow) {
return null;
},

// See https://github.com/endojs/endo/issues/1510
// TODO: report as bug to v8 or Chrome, and record issue link here.
getOwnPropertyDescriptor(_target, prop) {
getOwnPropertyDescriptor(_shadow, prop) {
// Coerce with `String` in case prop is a symbol.
const quotedProp = q(String(prop));
// eslint-disable-next-line @endo/no-polymorphic-call
Expand All @@ -69,6 +69,12 @@ const scopeProxyHandlerProperties = {
);
return undefined;
},

// See https://github.com/endojs/endo/issues/1490
// TODO Report bug to JSC or Safari
ownKeys(_shadow) {
return [];
},
};

// The scope handler's prototype is a proxy that throws if any trap other
Expand Down
6 changes: 3 additions & 3 deletions packages/ses/test/test-sloppy-globals-scope-terminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test('sloppyGlobalsScopeTerminator/getPrototypeOf - has null prototype', t => {
});

test('sloppyGlobalsScopeTerminator/getOwnPropertyDescriptor - always has start compartment properties but provides no prop desc', t => {
t.plan(4);
t.plan(5);

const globalObject = {};
const scopeTerminator = createSloppyGlobalsScopeTerminator(globalObject);
Expand All @@ -55,10 +55,11 @@ test('sloppyGlobalsScopeTerminator/getOwnPropertyDescriptor - always has start c
t.is(Reflect.getOwnPropertyDescriptor(scopeTerminator, 'eval'), undefined);
t.is(Reflect.has(scopeTerminator, 'xyz'), true);
t.is(Reflect.getOwnPropertyDescriptor(scopeTerminator, 'xyz'), undefined);
t.deepEqual(Reflect.ownKeys(scopeTerminator), []);
});

test('sloppyGlobalsScopeTerminator/etc - all other handlers throw errors', t => {
t.plan(8);
t.plan(7);

const globalObject = {};
const scopeTerminator = createSloppyGlobalsScopeTerminator(globalObject);
Expand All @@ -72,7 +73,6 @@ test('sloppyGlobalsScopeTerminator/etc - all other handlers throw errors', t =>
instanceOf: Error,
});
t.throws(() => Reflect.isExtensible(scopeTerminator), { instanceOf: Error });
t.throws(() => Reflect.ownKeys(scopeTerminator), { instanceOf: Error });
t.throws(() => Reflect.preventExtensions(scopeTerminator), {
instanceOf: Error,
});
Expand Down
6 changes: 3 additions & 3 deletions packages/ses/test/test-strict-scope-terminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('strictScopeTerminator/getPrototypeOf - has null prototype', t => {
});

test('strictScopeTerminator/getOwnPropertyDescriptor - always has start compartment properties but provides no prop desc', t => {
t.plan(8);
t.plan(9);

const originalWarn = console.warn;
let didWarn = 0;
Expand All @@ -52,13 +52,14 @@ test('strictScopeTerminator/getOwnPropertyDescriptor - always has start compartm
Reflect.getOwnPropertyDescriptor(strictScopeTerminator, 'xyz'),
undefined,
);
t.deepEqual(Reflect.ownKeys(strictScopeTerminator), []);
t.is(didWarn, 2);

console.warn = originalWarn;
});

test('strictScopeTerminator/etc - all other handlers throw errors', t => {
t.plan(8);
t.plan(7);

t.throws(() => Reflect.apply(strictScopeTerminator), { instanceOf: Error });
t.throws(() => Reflect.construct(strictScopeTerminator), {
Expand All @@ -73,7 +74,6 @@ test('strictScopeTerminator/etc - all other handlers throw errors', t => {
t.throws(() => Reflect.isExtensible(strictScopeTerminator), {
instanceOf: Error,
});
t.throws(() => Reflect.ownKeys(strictScopeTerminator), { instanceOf: Error });
t.throws(() => Reflect.preventExtensions(strictScopeTerminator), {
instanceOf: Error,
});
Expand Down

0 comments on commit 3dac711

Please sign in to comment.