Files
photo-live/apps/viewer/public/__test__/embed-host.html
T
2026-09-21 18:55:15 +08:00

50 lines
2.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<!-- apps/viewer/public/__test__/embed-host.html —— P4b Task 4 e2e 专用宿主夹具页。
仅测试资产(计划约定:不入 viewer 生产路由),模拟第三方站点引入
{VIEWER_ORIGIN}/embed/v1/loader.js:查询参数 ?slot=&lang=&interval=&position=
透传为 loader data-*;?poll= 同源写入 iframe contentWindow.__embedPollMs 加速
轮询断言(__viewerPollMs 惰性读取同一约定)。本页不设 CSP——宿主真实 CSP
要求(script-src/frame-src {EMBED_ORIGIN})见 packages/embed-loader/README-embed.md。 -->
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>embed host fixture</title>
</head>
<body>
<h1>Host page (embed e2e fixture)</h1>
<p>宿主夹具页:loader 注入区。</p>
<script>
(function () {
var q = new URLSearchParams(location.search);
var slot = q.get('slot');
if (!slot) return;
var s = document.createElement('script');
s.src = '/embed/v1/loader.js';
s.defer = true;
s.dataset.slot = slot;
var map = { lang: 'lang', interval: 'interval', position: 'position', poll: 'poll' };
for (var key in map) {
var value = q.get(key);
if (value) s.dataset[map[key]] = value;
}
document.body.appendChild(s);
var poll = parseInt(q.get('poll') || '', 10);
if (poll > 0) {
var timer = setInterval(function () {
try {
var frame = document.querySelector('iframe');
if (frame && frame.contentWindow) frame.contentWindow.__embedPollMs = poll;
} catch (e) {
/* 跨源写入被拒(真实第三方场景)——夹具仅在同源生效 */
}
}, 250);
setTimeout(function () {
clearInterval(timer);
}, 60000);
}
})();
</script>
</body>
</html>