Open GoogleCodeExporter opened 9 years ago
I've run a few tests and I don't think there is a perfect solution here.
The onbeforeunload handler is called when the tab is closed, or surfed away, or
reloaded. But the handler has a timeout (about a second, I think), after which
it will complete the operation without displaying the dialog.
You can call postMessage from the handler, and the NaCl module will get the
message asynchronously. But it is possible that the user will close the tab
before the NaCl module is finished with whatever it is doing.
Calling postMessageAndAwaitResponse does work, but it is subject to the
watchdog timer, which is potentially worse than waiting for the user to close
the tab.
It also looks like the DOM is not updated while the dialog is displayed. I
tried posting a message from the NaCl module back to JavaScript (for example,
to display something like "Save Finished"), but you won't see anything until
you click "Stay on this page".
Original comment by binji@chromium.org
on 23 Jun 2015 at 7:56
Original issue reported on code.google.com by
j...@chromium.org
on 22 Jun 2015 at 11:52