Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ecmascript proposal-realms
Search
Taketoshi Aono(青野健利 a.k.a brn)
September 17, 2017
Programming
1
2.6k
Ecmascript proposal-realms
現在提案中のtc39/proposal-realmsについて
ToKyoto.js#1
Taketoshi Aono(青野健利 a.k.a brn)
September 17, 2017
Tweet
Share
More Decks by Taketoshi Aono(青野健利 a.k.a brn)
See All by Taketoshi Aono(青野健利 a.k.a brn)
document.write再考
brn
6
3k
Parsing Javascript
brn
14
9.3k
JSON & Object Tips
brn
1
510
CA 1Day Youth Bootcamp for Frontend LT
brn
0
970
Modern TypeScript
brn
2
820
javascript - behind the scene
brn
3
750
tc39 proposals
brn
0
890
プロダクト開発とTypeScript
brn
8
2.9k
React-Springでリッチなアニメーション
brn
1
710
Other Decks in Programming
See All in Programming
2025 年のコーディングエージェントの現在地とエンジニアの仕事の変化について
azukiazusa1
19
10k
Claude Codeで実装以外の開発フロー、どこまで自動化できるか?失敗と成功
ndadayo
4
2k
モバイルアプリからWebへの横展開を加速した話_Claude_Code_実践術.pdf
kazuyasakamoto
0
310
MLH State of the League: 2026 Season
theycallmeswift
0
230
ソフトウェアテスト徹底指南書の紹介
goyoki
1
140
奥深くて厄介な「改行」と仲良くなる20分
oguemon
1
460
Vue・React マルチプロダクト開発を支える Vite
andpad
0
110
MCPとデザインシステムに立脚したデザインと実装の融合
yukukotani
4
1.3k
AWS発のAIエディタKiroを使ってみた
iriikeita
1
170
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
380
テストカバレッジ100%を10年続けて得られた学びと品質
mottyzzz
2
490
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
120
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.8k
Facilitating Awesome Meetings
lara
55
6.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
Designing for Performance
lara
610
69k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
How to Ace a Technical Interview
jacobian
279
23k
Transcript
Ecmascript Proposal-Realms
せ: @brn (ꫬꅿ⨳ⵃa.k.a ـٕ٦ظ) 耵噟: ؿٗٝزؒٝسؒٝآص،٥iOSؒٝآص، ⠓爡: Cyberagent ،سذؙأةآؔRightSegment٥AI Messenger
ـؚٗ: http://abcdef.gets.b6n.ch/ Twitter: https://twitter.com/brn227 GitHub: https://github.com/brn
What is Relms? Realmsהכءٝفٕח鎉ֲהծ DOM搀׃Iframe٥Node.JSךVMٌآُ٦ٕ ְזך
What can we do? Realms⢪ֲֿהדⴽךglobalؔـآؙؑز橆㞮ד ؝٦س晙evalֿׅהָדֹկ
let realm = new Realm();! ! let outerGlobal = window;!
let innerGlobal = realm.global;! ! let f = realm.evalScript("(function() { return 17 })");! ! f() === 17 // true! ! Reflect.getPrototypeOf(f) === outerGlobal.Function.prototype // false! ! Reflect.getPrototypeOf(f) === innerGlobal.Function.prototype // true!
Hook some calls תRealmsך؝ٝأزؙٓة٦חؔـآؙؑز床ֿׅהדぐ珏 Hook㹋鄲ֿׅהָדֹկ
const r = new Realm({! evalHook(sourceText) {! return compile(sourceText);! },!
importHook(referrerNamespace, specifier) {! ...! }! });! const result = r.eval('eval("1")');! // compile('1')を呼び出して、戻り値を評価する const ns = r.eval('import("foo")');! // referrerNamespaceがnullでspecifierが"foo"!
Your own Realms Realmsכؙٓأזךד竰䪫׃ג荈ⴓ杝荈ך橆㞮欰䧭ֿׅהָד ֹկ
class FakeWindow extends Realm {! init() {! super.init();! // グローバルを初期化
let global = this.global;! ! // 各種グローバルオブジェクトを書き換え global.document = new FakeDocument(...);! global.alert = new Proxy(fakeAlert, { ... });! ...! }! }!
Limitation 植㖈ךהֿevalScriptח湫䱸؝٦س床ׁזְה꼽湡կ 㢩鿇أؙٔفزRealmsז橆㞮ד㹋遤׃ְկ https://github.com/tc39/proposal-realms/issues/71 Realms.prototype.importScript 䲿周׃גֶֹת׃կ
Status תStage-1זךד孡ꞿח䖉ְ
Summary ➬✲ָ䎢デ噟歲זךד穠圓ⴖ㹋חק׃ְկ document.writeהַ剅ֹ䳔ְִׄׯ։