@@ -55,26 +55,6 @@ const WORKER_HTML = `<!DOCTYPE html>
5555 <title>T-Ruby WASM Worker</title>
5656</head>
5757<body>
58- <script>
59- // Protect native APIs before any extension can modify them
60- (function() {
61- const nativeFinalizationRegistry = window.FinalizationRegistry;
62- const nativeWeakRef = window.WeakRef;
63-
64- // Ensure these are the native implementations
65- Object.defineProperty(window, 'FinalizationRegistry', {
66- value: nativeFinalizationRegistry,
67- writable: false,
68- configurable: false
69- });
70-
71- Object.defineProperty(window, 'WeakRef', {
72- value: nativeWeakRef,
73- writable: false,
74- configurable: false
75- });
76- })();
77- <\/script>
7858<script type="module">
7959// CDN URLs
8060const RUBY_WASM_CDN = 'https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.7.0/dist/browser/+esm';
@@ -266,14 +246,20 @@ async function doLoadCompiler(
266246 progress : 5
267247 } ) ;
268248
269- // Create sandboxed iframe with srcdoc
270- // Using srcdoc creates an about:srcdoc origin which most extensions don't target
249+ // Create iframe with blob URL
250+ // Using blob: URL creates a unique origin that extensions typically don't target
271251 const iframe = document . createElement ( 'iframe' ) ;
272252 iframe . style . display = 'none' ;
273- // allow-scripts: needed to run JavaScript
274- // allow-same-origin: needed for postMessage to work properly
275- iframe . sandbox . add ( 'allow-scripts' ) ;
276- iframe . srcdoc = WORKER_HTML ;
253+
254+ // Create blob URL - this gives us a blob: origin
255+ const blob = new Blob ( [ WORKER_HTML ] , { type : 'text/html' } ) ;
256+ const blobUrl = URL . createObjectURL ( blob ) ;
257+ iframe . src = blobUrl ;
258+
259+ // Clean up blob URL after iframe loads
260+ iframe . onload = ( ) => {
261+ URL . revokeObjectURL ( blobUrl ) ;
262+ } ;
277263
278264 // Message handler
279265 const messageHandler = ( event : MessageEvent ) => {
0 commit comments