- worked on this during ES2015 time frame, so never went through stages process
- got punted to later (rightly so!)
- goal for today: resume work on this, reassert committee interest via advancing to stage 1
- sandbox
- iframe without DOM
- principled version of Node's
'vm'
module
- sync Worker
- security isolation (with synchronous but coarse-grained communication channel)
- plugins (e.g., spreadsheet functions)
- in-browser code editors
- server-side rendering
- testing/mocking (e.g., jsdom)
- in-browser transpilation
let realm = new Realm();
let outerGlobal = window;
let innerGlobal = realm.global;
let f = realm.evalScript("(function() { return 17 })");
f() === 17 // true
Reflect.getPrototypeOf(f) === outerFlobal.Function.prototype // false
Reflect.getPrototypeOf(f) === innerGlobal.Function.prototype // true
class EmptyRealm extends Realm {
constructor(...args) { super(...args); }
init() { /* do nothing */ }
}
class FakeWindow extends Realm {
init() {
super.init(); // install the standard primordials
let global = this.global;
global.document = new FakeDocument(...);
global.alert = new Proxy(fakeAlert, { ... });
...
}
}
class ESNextRealm extends Realm {
[Realm.directEval](source) { return compile(source); }
[Realm.indirectEval](source) { ... }
...
}
realm.evalModule()
- module registry
- hooks for manipulating module requests