in packages/core/browser-vm/src/Context.js [8:32]
static create(conf) {
return new Promise((resolve) => {
const iframe = document.createElement('iframe');
// TODO: change src to a reasonable value.
iframe.setAttribute('src', conf.url ? conf.url : '/api.json');
iframe.style.cssText = 'position: absolute; top: -20000px; width: 1px; height: 1px;';
if (conf.id) iframe.setAttribute('data-id', conf.id);
// body will be hijacked in sandbox, so get body from html
const topBody = document.documentElement?.getElementsByTagName('body')[0] || document.body;
topBody.appendChild(iframe);
// the onload will no trigger when src is about:blank
if (conf.url === 'about:blank') {
return resolve(new this(conf, iframe));
}
iframe.onload = () => {
resolve(new this(conf, iframe));
};
});
}