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
410
CA 1Day Youth Bootcamp for Frontend LT
brn
0
820
Modern TypeScript
brn
2
750
javascript - behind the scene
brn
3
690
tc39 proposals
brn
0
800
プロダクト開発とTypeScript
brn
8
2.8k
React-Springでリッチなアニメーション
brn
1
620
Other Decks in Programming
See All in Programming
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
Security_for_introducing_eBPF
kentatada
0
110
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
Symfony Mapper Component
soyuka
2
730
ドメインイベント増えすぎ問題
h0r15h0
1
220
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
1
120
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
930
CSC509 Lecture 14
javiergs
PRO
0
140
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
520
39k
Six Lessons from altMBA
skipperchong
27
3.5k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Navigating Team Friction
lara
183
15k
Agile that works and the tools we love
rasmusluckow
328
21k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
A designer walks into a library…
pauljervisheath
204
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
GitHub's CSS Performance
jonrohan
1030
460k
Git: the NoSQL Database
bkeepers
PRO
427
64k
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הַ剅ֹ䳔ְִׄׯ։