dbxapp
4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
dbxapp.de
Portal
Start
Anwender
Entwickler
KI-Bereiche
Loading...
Searching...
No Matches
dbxUtilitiesReloadGuard_contract_test.php
Go to the documentation of this file.
1
<?php
2
declare(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
11
$assert
(
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
);
17
$assert
(
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
);
22
$assert
(
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
);
27
$assert
(
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
34
if
(
$failures
!== array()) {
35
fwrite(STDERR,
"FAIL\n- "
. implode(
"\n- "
,
$failures
) .
"\n"
);
36
exit
(1);
37
}
38
39
echo
"OK reload bypasses the leave confirmation while the navigation guard remains active.\n"
;
$failures
$failures
Definition
db_access_boundary_test.php:5
$base
$base
Definition
dbxApi_paths_test.php:11
$assert
$assert
Definition
dbxCmsEditorPerformance_contract_test.php:8
$source
$source
Definition
dbxCmsEditorPerformance_contract_test.php:4
$assert
$assert
Definition
dbxUtilitiesReloadGuard_contract_test.php:7
exit
exit
Definition
index.php:146
dbx
include
tests
dbxUtilitiesReloadGuard_contract_test.php
Generated by
1.17.0