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.2k
JSON & Object Tips
brn
1
490
CA 1Day Youth Bootcamp for Frontend LT
brn
0
950
Modern TypeScript
brn
2
810
javascript - behind the scene
brn
3
740
tc39 proposals
brn
0
880
プロダクト開発とTypeScript
brn
8
2.9k
React-Springでリッチなアニメーション
brn
1
700
Other Decks in Programming
See All in Programming
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
3
780
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
130
スタートアップの急成長を支えるプラットフォームエンジニアリングと組織戦略
sutochin26
1
6k
20250704_教育事業におけるアジャイルなデータ基盤構築
hanon52_
5
810
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
200
AI時代の『改訂新版 良いコード/悪いコードで学ぶ設計入門』 / ai-good-code-bad-code
minodriven
19
7.5k
Result型で“失敗”を型にするPHPコードの書き方
kajitack
5
920
Goで作る、開発・CI環境
sin392
0
240
プロダクト志向ってなんなんだろうね
righttouch
PRO
0
190
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
780
git worktree × Claude Code × MCP ~生成AI時代の並列開発フロー~
hisuzuya
1
580
VS Code Update for GitHub Copilot
74th
2
650
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
A Modern Web Designer's Workflow
chriscoyier
695
190k
Designing Experiences People Love
moore
142
24k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Raft: Consensus for Rubyists
vanstee
140
7k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Documentation Writing (for coders)
carmenintech
72
4.9k
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הַ剅ֹ䳔ְִׄׯ։