mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
Avoid observer handshakes on child-frame load completion
This commit is contained in:
+1
@@ -70,6 +70,7 @@ it('binds edit protection to the current main-frame document and real lifecycle
|
||||
for (let event = 0; event < count; event++) {
|
||||
guest.emit('frame-created')
|
||||
guest.emit('did-start-navigation', { isMainFrame: false, isSameDocument: false })
|
||||
guest.emit('did-stop-loading')
|
||||
}
|
||||
expect(changed).not.toHaveBeenCalled()
|
||||
expect(mainFrame.send).toHaveBeenCalledTimes(challenges)
|
||||
|
||||
+11
-2
@@ -128,6 +128,15 @@ export function installBrowserGuestDiscardProtection(
|
||||
owner.unavailable = false
|
||||
snapshot()
|
||||
}
|
||||
const loadStopped = (): void => {
|
||||
const needsSnapshot = owner.navigating || owner.generation === null
|
||||
owner.navigating = false
|
||||
if (needsSnapshot) {
|
||||
snapshot()
|
||||
} else {
|
||||
publish()
|
||||
}
|
||||
}
|
||||
const unresponsive = (): void => {
|
||||
owner.unavailable = true
|
||||
invalidate()
|
||||
@@ -143,7 +152,7 @@ export function installBrowserGuestDiscardProtection(
|
||||
guest.on('ipc-message', report)
|
||||
guest.on('did-start-navigation', navigation)
|
||||
guest.on('dom-ready', settled)
|
||||
guest.on('did-stop-loading', settled)
|
||||
guest.on('did-stop-loading', loadStopped)
|
||||
guest.on('responsive', responsive)
|
||||
guest.on('unresponsive', unresponsive)
|
||||
guest.on('render-process-gone', unresponsive)
|
||||
@@ -156,7 +165,7 @@ export function installBrowserGuestDiscardProtection(
|
||||
guest.off('ipc-message', report)
|
||||
guest.off('did-start-navigation', navigation)
|
||||
guest.off('dom-ready', settled)
|
||||
guest.off('did-stop-loading', settled)
|
||||
guest.off('did-stop-loading', loadStopped)
|
||||
guest.off('responsive', responsive)
|
||||
guest.off('unresponsive', unresponsive)
|
||||
guest.off('render-process-gone', unresponsive)
|
||||
|
||||
Reference in New Issue
Block a user