@guardian/ophan-tracker-js 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NPM-dist/core.js +1 -0
- package/NPM-dist/tests/core.test.js +8 -0
- package/package.json +1 -1
package/NPM-dist/core.js
CHANGED
|
@@ -11,6 +11,7 @@ init = function (servingPlatform, httpStatus) {
|
|
|
11
11
|
platform = servingPlatform;
|
|
12
12
|
window.addEventListener('pageshow', function (event) {
|
|
13
13
|
if (event.persisted) {
|
|
14
|
+
transmit.bumpViewId();
|
|
14
15
|
sendInitialEvent(httpStatus, location.href, window.document.referrer, 'bfcache');
|
|
15
16
|
}
|
|
16
17
|
}, false);
|
|
@@ -194,6 +194,14 @@ describe('loadType pageshow handling', () => {
|
|
|
194
194
|
loadType: 'bfcache'
|
|
195
195
|
}));
|
|
196
196
|
});
|
|
197
|
+
it('should call bumpViewId when pageshow event has persisted=true', () => {
|
|
198
|
+
expect(pageShowHandler).toBeTruthy();
|
|
199
|
+
transmit.bumpViewId.mockClear();
|
|
200
|
+
// Simulate a bfcache restore event
|
|
201
|
+
const mockEvent = { persisted: true };
|
|
202
|
+
pageShowHandler(mockEvent);
|
|
203
|
+
expect(transmit.bumpViewId).toHaveBeenCalledTimes(1);
|
|
204
|
+
});
|
|
197
205
|
it('should not call sendInitialEvent when pageshow event has persisted=false', () => {
|
|
198
206
|
expect(pageShowHandler).toBeTruthy();
|
|
199
207
|
transmit.sendInitial.mockClear();
|