mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 06:31:20 -08:00
test(iframe): [PKG-IFRAME-05] verify native cached history and interrupted navigation
This commit is contained in:
1 parent
b35183c7af
commit
cb6c767731
19 files changed
+7908
-13
No files matched your search
@@ -0,0 +1,26 @@
|
||||
<!doctype html>
|
||||
<title>Iframe document history</title>
|
||||
<script src="/observe.js"></script>
|
||||
<script src="/tool.js"></script>
|
||||
<iframe style="width: 640px; height: 360px" allowfullscreen></iframe>
|
||||
<script>
|
||||
window.timeline = []
|
||||
window.callbacks = []
|
||||
window.states = {}
|
||||
window.track = (name, promise) => {
|
||||
states[name] = { status: 'pending' }
|
||||
promise.then(
|
||||
(value) => (states[name] = { status: 'resolved', value }),
|
||||
(error) => (states[name] = { status: 'rejected', error: error.message }),
|
||||
)
|
||||
}
|
||||
const target = new URL('/child.html', location.href)
|
||||
target.search = location.search
|
||||
if (target.searchParams.get('relation') === 'cross') target.hostname = 'localhost'
|
||||
window.targetFrame = document.querySelector('iframe')
|
||||
addEventListener('message', (event) => {
|
||||
if (event.source === targetFrame.contentWindow) timeline.push(event.data)
|
||||
})
|
||||
window.tool = new ArtplayerToolIframe({ iframe: targetFrame, url: target.href })
|
||||
tool.message((packet) => callbacks.push(packet))
|
||||
</script>
|
||||
Reference in new issue
Block a user