dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxUtilitiesReloadGuard_contract_test.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4$base = dirname(__DIR__, 2);
5$source = (string)file_get_contents($base . '/js/lib/utilities.js');
6$failures = array();
7$assert = static function (bool $condition, string $message) use (&$failures): void {
8 if (!$condition) $failures[] = $message;
9};
10
12 str_contains($source, 'key === "f5"')
13 && str_contains($source, '(event.ctrlKey || event.metaKey) && key === "r"')
14 && str_contains($source, 'allowLeaveGuardNavigation(10000);'),
15 'F5, Strg+R oder Cmd+R geben den Reload nicht vor der Verlassenswarnung frei.'
16);
18 str_contains($source, 'window.navigation.addEventListener("navigate"')
19 && str_contains($source, 'event.navigationType === "reload"'),
20 'Toolbar- und programmatische Reloads werden bei verfuegbarer Navigation API nicht erkannt.'
21);
23 str_contains($source, 'window.addEventListener("beforeunload"')
24 && str_contains($source, 'Date.now() <= leaveGuardAllowUntil'),
25 'Der Reload-Bypass ist nicht mit der zentralen Verlassenswarnung verbunden.'
26);
28 !str_contains($source, 'hasReloadSafeWorkspace()')
29 && str_contains($source, 'event.preventDefault();')
30 && str_contains($source, 'event.returnValue = "";'),
31 'Das Schliessen eines Tabs oder Browserfensters ist nicht mehr durch beforeunload geschuetzt.'
32);
33
34if ($failures !== array()) {
35 fwrite(STDERR, "FAIL\n- " . implode("\n- ", $failures) . "\n");
36 exit(1);
37}
38
39echo "OK reload bypasses the leave confirmation while the navigation guard remains active.\n";
exit
Definition index.php:146