Open PhilippImhof opened 1 year ago
Just for completeness: The following HTML snippet (while not perfect at all) gives the warning in current windows SEB, but not in SEB for Mac.
<html>
<head>
<script>
window.onbeforeunload = function(e) {
e.preventDefault()
return true;
};
</script>
</head>
<body>
<p><textarea></textarea></p>
<p><a href="https://safeexambrowser.org">SEB</a></p>
</body>
</html>
Looks like once again Apple doesn't support full browser functionality in the embeddable WebKit browser engine (although they use it in Safari...). https://developer.apple.com/forums/thread/707103 I will further investigate this, if it's as it seems, then either it's possible to catch the beforeunload event with some injected Javascript and handle it accordingly or only a bug report to Apple will help (in future macOS versions): https://developer.apple.com/bug-reporting/
Of course having this "Back" button in Moodle quizzes which breaks the autosave functionality is insanity and should also be fixed there asap, regardless of this WKWebView issue.
The embedded WebView API WKWebView is more or less the same on macOS and iOS. On iOS neither Safari nor third-party browsers like Chrome (on iOS all third-party browsers have to use WKWebView) display a warning when the Back button is used on page with entered text. So it's definitely an issue which we have to report to Apple.
Btw. such a warning seems to be out of fashion, as even GitHub doesn't display a warning when you're entering text here in a discussion or issue and navigate away. Text is just lost! Grrrr
Thanks for that quick reaction and the check. As I do not have any iOS devices, I wasn't able to verify that. So if we depend on Apple to solve that, we're probably going to wait for a long time...
Btw. such a warning seems to be out of fashion, as even GitHub doesn't display a warning when you're entering text here in a discussion or issue and navigate away. Text is just lost! Grrrr
It seems to me that GitHub stores the data, so if I press back in the browser and then return to this page or if I close the tab and restore it, my text is still there.
So I saw there is a private WebKit delegate method (event handler) for beforeUnload, they are using it in the standard WebKit mini browser sample code. I guess I will be able to implement that for the macOS version of SEB (don't know though if I'll have time to add it to SEB 3.4). This private method maybe doesn't work on iOS (well for the App Store you anyways can't really use it). Safari for iOS at least doesn't show the warning on the test page you created. I copied a version of your test to our testing page, available at this link, hope that's fine for you. I also tried to inject a Javascript workaround I found somewhere into all loaded web pages, but that didn't work.
Most browsers allow to display a warning message when the user navigates away from a form that has unsaved changes. This functionality is available in SEB for Windows, but does not work on MacOS. As a consequence, users might lose unsaved changes in a Moodle quiz as described in MDL-79324.
The way that functionality is implemented in Moodle, it works with other browsers on Mac (Chrome, Firefox, Safari) and with SEB on Windows, so I'd argue it is not an implementation error on the side of the Moodle devs.