Analyse: Verweildauer bei internem Seitenwechsel sofort senden
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ab4c53d6df
commit
30412cb0ea
3 files changed
+83
-3
No files matched your search
@@ -185,7 +185,7 @@ function harness({ gpc, dnt, stored, search = '', src = 'https://project.webklar
|
||||
const history = { pushState() {}, replaceState(s, t, u) { this.replaced = u; } };
|
||||
const win = {
|
||||
innerWidth: 1200, innerHeight: 800, scrollX: 0, scrollY: 300, document, history,
|
||||
location: { hostname: 'mein.de', pathname: '/start', search, href: 'https://mein.de/start' + search, hash: '' },
|
||||
location: { hostname: 'mein.de', origin: 'https://mein.de', pathname: '/start', search, href: 'https://mein.de/start' + search, hash: '' },
|
||||
addEventListener(t, f) { (winL[t] ||= []).push(f); },
|
||||
removeEventListener(t, f) { winL[t] = (winL[t] || []).filter((x) => x !== f); },
|
||||
};
|
||||
@@ -431,3 +431,49 @@ test('w.js: [data-webklar-consent] spaeter hinzugefuegt funktioniert per Delegat
|
||||
assert.ok(hostEl(h));
|
||||
assert.ok(btn(hostEl(h).shadow, 'Ablehnen').focused);
|
||||
});
|
||||
|
||||
// ---------- Verweildauer bei internem Seitenwechsel ----------
|
||||
const ACC = { v: 1, a: 'accept', t: 1_700_000_000_000 - 1000 };
|
||||
const lnk = (href, attrs = {}) => { const a = makeEl('a'); a.setAttribute('href', href); for (const k in attrs) a.setAttribute(k, attrs[k]); a.parentNode = makeEl('body'); return a; };
|
||||
const enCount = (h) => h.sent.filter((s) => s.d.t === 'en').length;
|
||||
|
||||
test('w.js: interner Link-Klick sendet en sofort, pagehide danach nicht doppelt', () => {
|
||||
const h = harness({ stored: ACC });
|
||||
h.ck(lnk('/kontakt'));
|
||||
assert.equal(enCount(h), 1);
|
||||
assert.deepEqual(h.sent.map((s) => s.d.t), ['pv', 'ck', 'en']);
|
||||
const en = h.sent.at(-1).d;
|
||||
assert.equal(en.path, '/start'); assert.equal(en.scroll, 55);
|
||||
h.leave();
|
||||
assert.equal(enCount(h), 1);
|
||||
h.ck(lnk('https://mein.de/andere?x=1#a'));
|
||||
assert.equal(enCount(h), 1);
|
||||
});
|
||||
|
||||
test('w.js: kein fruehes en bei externem Link, Anker, gleicher Seite, Modifier, Ziel/Download, defaultPrevented', () => {
|
||||
const h = harness({ stored: ACC });
|
||||
h.ck(lnk('https://anders.de/x'));
|
||||
h.ck(lnk('#oben'));
|
||||
h.ck(lnk('/start#unten'));
|
||||
h.ck(lnk('/kontakt'), { ctrlKey: true });
|
||||
h.ck(lnk('/kontakt'), { metaKey: true });
|
||||
h.ck(lnk('/kontakt'), { shiftKey: true });
|
||||
h.ck(lnk('/kontakt'), { button: 1 });
|
||||
h.ck(lnk('/kontakt', { target: '_blank' }));
|
||||
h.ck(lnk('/datei.pdf', { download: '' }));
|
||||
h.ck(lnk('/kontakt'), { defaultPrevented: true });
|
||||
h.ck(lnk('mailto:a@b.de'));
|
||||
assert.equal(enCount(h), 0);
|
||||
h.leave();
|
||||
assert.equal(enCount(h), 1);
|
||||
});
|
||||
|
||||
test('w.js: ohne Einwilligung oder nach Widerruf kein fruehes en', () => {
|
||||
const h = harness();
|
||||
h.ck(lnk('/kontakt'));
|
||||
assert.equal(enCount(h), 0);
|
||||
const g = harness({ stored: ACC });
|
||||
g.store['wk-consent'] = JSON.stringify({ v: 1, a: 'reject', t: 1_700_000_000_000 });
|
||||
g.ck(lnk('/kontakt'));
|
||||
assert.equal(enCount(g), 0);
|
||||
});
|
||||
Reference in new issue
Block a user