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.5k
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
2.9k
Parsing Javascript
brn
12
9k
JSON & Object Tips
brn
1
400
CA 1Day Youth Bootcamp for Frontend LT
brn
0
790
Modern TypeScript
brn
2
750
javascript - behind the scene
brn
3
680
tc39 proposals
brn
0
780
プロダクト開発とTypeScript
brn
8
2.8k
React-Springでリッチなアニメーション
brn
1
600
Other Decks in Programming
See All in Programming
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
170
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
890
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
320
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
最新TCAキャッチアップ
0si43
0
140
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
1.9k
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
RubyLSPのマルチバイト文字対応
notfounds
0
120
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Visualization
eitanlees
145
15k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Producing Creativity
orderedlist
PRO
341
39k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
GitHub's CSS Performance
jonrohan
1030
460k
Rails Girls Zürich Keynote
gr2m
94
13k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Bash Introduction
62gerente
608
210k
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הַ剅ֹ䳔ְִׄׯ։