should just be manual reformattings
MODIFY
src/commons.js
src/commons.js
@@ -10,7 +10,8 @@ export const {
assign,
create,
freeze,
- defineProperties, // Object.defineProperty is allowed to fail silentlty, use Object.defineProperties instead.
+ defineProperties, // Object.defineProperty is allowed to fail
+ // silentlty, use Object.defineProperties instead.
getOwnPropertyDescriptor,
getOwnPropertyDescriptors,
getOwnPropertyNames,
@@ -20,18 +21,22 @@ export const {
export const {
apply,
- ownKeys // Reflect.ownKeys includes Symbols and unenumerables, unlike Object.keys()
+ ownKeys // Reflect.ownKeys includes Symbols and unenumerables,
+ // unlike Object.keys()
} = Reflect;
/**
- * uncurryThis()
- * See http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
- * which only lives at http://web.archive.org/web/20160805225710/http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
+ * uncurryThis() See
+ * http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
+ * which only lives at
+ * http://web.archive.org/web/20160805225710/http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
*
* Performance:
* 1. The native call is about 10x faster on FF than chrome
- * 2. The version using Function.bind() is about 100x slower on FF, equal on chrome, 2x slower on Safari
- * 3. The version using a spread and Reflect.apply() is about 10x slower on FF, equal on chrome, 2x slower on Safari
+ * 2. The version using Function.bind() is about 100x slower on FF,
+ * equal on chrome, 2x slower on Safari
+ * 3. The version using a spread and Reflect.apply() is about 10x
+ * slower on FF, equal on chrome, 2x slower on Safari
*
* const bind = Function.prototype.bind;
* const uncurryThis = bind.bind(bind.call);
@@ -40,7 +45,8 @@ const uncurryThis = fn => (thisArg, ...args) => apply(fn, thisArg, args);
// We also capture these for security: changes to Array.prototype after the
// Realm shim runs shouldn't affect subsequent Realm operations.
-export const objectHasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty),
+export const
+ objectHasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty),
arrayForEach = uncurryThis(Array.prototype.forEach),
arrayFilter = uncurryThis(Array.prototype.filter),
arrayPush = uncurryThis(Array.prototype.push),

MODIFY
src/evaluators.js
src/evaluators.js
@@ -41,7 +41,8 @@ function createScopedEvaluatorFactory(unsafeRec, constants) {
// 2: 'optimizer' catches common variable names for speed
// 3: The inner strict function is effectively passed two parameters:
// a) its arguments[0] is the source to be directly evaluated.
- // b) its 'this' is the this binding seen by the code being directly evaluated.
+ // b) its 'this' is the this binding seen by the code being
+ // directly evaluated.
// everything in the 'optimizer' string is looked up in the proxy
// (including an 'arguments[0]', which points at the Proxy). 'function' is
@@ -195,7 +196,8 @@ export function createFunctionEvaluator(unsafeRec, safeEval) {
// character - it may make the combined function expression
// compile. We avoid this problem by checking for this early on.
- // note: v8 throws just like this does, but chrome accepts e.g. 'a = new Date()'
+ // note: v8 throws just like this does, but chrome accepts
+ // e.g. 'a = new Date()'
throw new unsafeGlobal.SyntaxError(
'shim limitation: Function arg string contains parenthesis'
);
@@ -220,16 +222,19 @@ export function createFunctionEvaluator(unsafeRec, safeEval) {
// with instance checks in any compartment of the same root realm.
setPrototypeOf(safeFunction, unsafeFunction.prototype);
- assert(getPrototypeOf(safeFunction).constructor !== Function, 'hide Function');
- assert(getPrototypeOf(safeFunction).constructor !== unsafeFunction, 'hide unsafeFunction');
+ assert(getPrototypeOf(safeFunction).constructor !== Function,
+ 'hide Function');
+ assert(getPrototypeOf(safeFunction).constructor !== unsafeFunction,
+ 'hide unsafeFunction');
defineProperties(safeFunction, {
// Ensure that any function created in any compartment in a root realm is an
// instance of Function in any compartment of the same root ralm.
prototype: { value: unsafeFunction.prototype },
- // Provide a custom output without overwriting the Function.prototype.toString
- // which is called by some third-party libraries.
+ // Provide a custom output without overwriting the
+ // Function.prototype.toString which is called by some third-party
+ // libraries.
toString: {
value: safeEval("() => 'function Function() { [shim code] }'"),
writable: false,

MODIFY
src/optimizer.js
src/optimizer.js
@@ -104,7 +104,9 @@ export function getOptimizableGlobals(safeGlobal) {
const constants = arrayFilter(getOwnPropertyNames(descs), name => {
// Ensure we have a valid identifier. We use regexpTest rather than
// /../.test() to guard against the case where RegExp has been poisoned.
- if (name === 'eval' || keywords.has(name) || !regexpTest(identifierPattern, name)) {
+ if (name === 'eval' ||
+ keywords.has(name) ||
+ !regexpTest(identifierPattern, name)) {
return false;
}

MODIFY
src/realm.js
src/realm.js
@@ -55,9 +55,8 @@ function createRealmRec(unsafeRec) {
const safeGlobal = create(unsafeGlobal.Object.prototype);
const safeEvaluatorFactory = createSafeEvaluatorFactory(unsafeRec, safeGlobal);
const safeEval = createSafeEvaluator(safeEvaluatorFactory);
- const safeEvalWhichTakesEndowments = createSafeEvaluatorWhichTakesEndowments(
- safeEvaluatorFactory
- );
+ const safeEvalWhichTakesEndowments =
+ createSafeEvaluatorWhichTakesEndowments(safeEvaluatorFactory);
const safeFunction = createFunctionEvaluator(unsafeRec, safeEval);
setDefaultBindings(sharedGlobalDescs, safeGlobal, safeEval, safeFunction);

MODIFY
src/realmFacade.js
src/realmFacade.js
@@ -4,7 +4,12 @@ import { cleanupSource } from './utilities';
// never referenced again, because it closes over the wrong intrinsics
export function buildChildRealm(unsafeRec, BaseRealm) {
- const { initRootRealm, initCompartment, getRealmGlobal, realmEvaluate } = BaseRealm;
+ const {
+ initRootRealm,
+ initCompartment,
+ getRealmGlobal,
+ realmEvaluate
+ } = BaseRealm;
// This Object and Reflect are brand new, from a new unsafeRec, so no user
// code has been run or had a chance to manipulate them. We extract these
@@ -136,7 +141,8 @@ export function buildChildRealm(unsafeRec, BaseRealm) {
// The parentheses means we don't bind the 'buildChildRealm' name inside the
// child's namespace. this would accept an anonymous function declaration.
// function expression (not a declaration) so it has a completion value.
-const buildChildRealmString = cleanupSource(`'use strict'; (${buildChildRealm})`);
+const buildChildRealmString =
+ cleanupSource(`'use strict'; (${buildChildRealm})`);
export function createRealmFacade(unsafeRec, BaseRealm) {
const { unsafeEval } = unsafeRec;

MODIFY
src/repair/accessors.js
src/repair/accessors.js
* This function can be used in two ways: (1) invoked directly to fix the primal
* realm's Object.prototype, and (2) converted to a string to be executed
* inside each new RootRealm to fix their Object.prototypes. Evaluation requires
- * the function to have no dependencies, so don't import anything from the outside.
+ * the function to have no dependencies, so don't import anything from
+ * the outside.
*/
// todo: this file should be moved out to a separate repo and npm module.
@@ -24,10 +25,11 @@ export function repairAccessors() {
prototype: objectPrototype
} = Object;
- // On some platforms, the implementation of these functions act as if they are
- // in sloppy mode: if they're invoked badly, they will expose the global object,
- // so we need to repair these for security. Thus it is our responsibility to fix
- // this, and we need to include repairAccessors. E.g. Chrome in 2016.
+ // On some platforms, the implementation of these functions act as
+ // if they are in sloppy mode: if they're invoked badly, they will
+ // expose the global object, so we need to repair these for
+ // security. Thus it is our responsibility to fix this, and we need
+ // to include repairAccessors. E.g. Chrome in 2016.
try {
// Verify that the method is not callable.

MODIFY
src/repair/functions.js
src/repair/functions.js
@@ -37,7 +37,8 @@ export function repairFunctions() {
FunctionInstance = (0, eval)(declaration);
} catch (e) {
if (e instanceof SyntaxError) {
- // Prevent failure on platforms where async and/or generators are not supported.
+ // Prevent failure on platforms where async and/or generators
+ // are not supported.
return;
}
// Re-throw
@@ -55,7 +56,8 @@ export function repairFunctions() {
// (new Error()).constructors does not inherit from Function, because Error
// was defined before ES6 classes. So we don't need to repair it too.
- // (Error()).constructor inherit from Function, which gets a tamed constructor here.
+ // (Error()).constructor inherit from Function, which gets a tamed
+ // constructor here.
// todo: in an ES6 class that does not inherit from anything, what does its
// constructor inherit from? We worry that it inherits from Function, in
@@ -64,11 +66,15 @@ export function repairFunctions() {
// This line replaces the original constructor in the prototype chain
// with the tamed one. No copy of the original is peserved.
- defineProperties(FunctionPrototype, { constructor: { value: TamedFunction } });
+ defineProperties(FunctionPrototype, {
+ constructor: { value: TamedFunction }
+ });
// This line sets the tamed constructor's prototype data property to
// the original one.
- defineProperties(TamedFunction, { prototype: { value: FunctionPrototype } });
+ defineProperties(TamedFunction, {
+ prototype: { value: FunctionPrototype }
+ });
if (TamedFunction !== Function.prototype.constructor) {
// Ensures that all functions meet "instanceof Function" in a realm.

MODIFY
src/scopeHandler.js
src/scopeHandler.js
@@ -122,9 +122,10 @@ export function createScopeHandler(unsafeRec) {
has(target, prop) {
// proxies stringify 'prop', so no TOCTTOU danger here
- // unsafeGlobal: hide all properties of unsafeGlobal at the expense of 'typeof'
- // being wrong for those properties. For example, in the browser, evaluating
- // 'document = 3', will add a property to safeGlobal instead of throwing a
+ // unsafeGlobal: hide all properties of unsafeGlobal at the
+ // expense of 'typeof' being wrong for those properties. For
+ // example, in the browser, evaluating 'document = 3', will add
+ // a property to safeGlobal instead of throwing a
// ReferenceError.
if (prop === 'eval' || prop in target || prop in unsafeGlobal) {
return true;

MODIFY
src/unsafeRec.js
src/unsafeRec.js
@@ -18,12 +18,13 @@ const unsafeGlobalEvalSrc = `(0, eval)("'use strict'; this")`;
// This method is only exported for testing purposes.
export function createNewUnsafeGlobalForNode() {
- // Note that webpack and others will shim 'vm' including the method 'runInNewContext',
- // so the presence of vm is not a useful check
+ // Note that webpack and others will shim 'vm' including the method
+ // 'runInNewContext', so the presence of vm is not a useful check
// TODO: Find a better test that works with bundlers
// eslint-disable-next-line no-new-func
- const isNode = new Function('try {return this===global}catch(e){ return false}')();
+ const isNode = new Function(
+ 'try {return this===global}catch(e){return false}')();
if (!isNode) {
return undefined;
@@ -88,8 +89,10 @@ function createUnsafeRec(unsafeGlobal, allShims = []) {
});
}
-const repairAccessorsShim = cleanupSource(`"use strict"; (${repairAccessors})();`);
-const repairFunctionsShim = cleanupSource(`"use strict"; (${repairFunctions})();`);
+const repairAccessorsShim =
+ cleanupSource(`"use strict"; (${repairAccessors})();`);
+const repairFunctionsShim =
+ cleanupSource(`"use strict"; (${repairFunctions})();`);
// Create a new unsafeRec from a brand new context, with new intrinsics and a
// new global object

MODIFY
test/module/unsafeRec.js
test/module/unsafeRec.js
@@ -12,7 +12,13 @@ test('createNewUnsafeRec', t => {
t.plan(7);
const unsafeRec = createNewUnsafeRec();
- const { unsafeGlobal, sharedGlobalDescs, unsafeEval, unsafeFunction, allShims } = unsafeRec;
+ const {
+ unsafeGlobal,
+ sharedGlobalDescs,
+ unsafeEval,
+ unsafeFunction,
+ allShims
+ } = unsafeRec;
t.ok(Object.isFrozen(unsafeRec));
@@ -44,10 +50,13 @@ test('createNewUnsafeGlobalForNode on node', t => {
t.ok(unsafeGlobal instanceof unsafeGlobal.Object, 'global must be an Object');
t.notOk(unsafeGlobal instanceof Object, 'must not be Object in this realm');
- t.ok(unsafeGlobal.eval instanceof unsafeGlobal.Function, 'must provide eval() function');
- t.notOk(unsafeGlobal.eval instanceof Function, 'eval() must not be Function in this realm');
+ t.ok(unsafeGlobal.eval instanceof unsafeGlobal.Function,
+ 'must provide eval() function');
+ t.notOk(unsafeGlobal.eval instanceof Function,
+ 'eval() must not be Function in this realm');
- t.ok(unsafeGlobal.Function instanceof unsafeGlobal.Function, 'must provide Function() function');
+ t.ok(unsafeGlobal.Function instanceof unsafeGlobal.Function,
+ 'must provide Function() function');
t.notOk(
unsafeGlobal.Function instanceof Function,
'Function() must not be Function in this realm'

should just be manual reformattings