@whotracksme/reporting 12.1.15 β†’ 12.1.16

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v12.1.16 (Thu Nov 19 2026)
2
+
3
+ #### πŸ› Bug Fix
4
+
5
+ - Fixed: After a restart of the service worker, the state of all tabs is lost [#258](https://github.com/whotracksme/webextension-packages/pull/258) ([@philipp-classen](https://github.com/philipp-classen))
6
+
7
+ #### Authors: 1
8
+
9
+ - Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
10
+
11
+ ---
12
+
1
13
  # v12.1.15 (Thu Nov 19 2026)
2
14
 
3
15
  #### πŸ› Bug Fix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whotracksme/reporting",
3
- "version": "12.1.15",
3
+ "version": "12.1.16",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./sanitizer": "./reporting/src/sanitizer.js",
@@ -599,7 +599,7 @@ export default class Pages {
599
599
  if (openTabs) {
600
600
  const deserializedTabs = Object.entries(openTabs).map(
601
601
  ([tabId, tabContent]) => [
602
- tabId,
602
+ Number(tabId), // tab ids are numbers, but object keys are strings
603
603
  this._deserializeTabContent(tabContent),
604
604
  ],
605
605
  );
@@ -15,6 +15,7 @@ import Pages, { stripLazyVars, CANCEL_LAZY_VAR } from '../src/pages.js';
15
15
  import UrlAnalyzer from '../src/url-analyzer.js';
16
16
  import SessionStorageWrapper from '../src/session-storage.js';
17
17
  import Patterns from '../src/patterns.js';
18
+ import FakeSessionApi from './helpers/fake-session-storage.js';
18
19
 
19
20
  function waitForPendingMicrotasks() {
20
21
  return new Promise((resolve) => {
@@ -860,6 +861,107 @@ ${total} tests run: ${passed} passed, ${failed} failed (${ratio}% passed)
860
861
  });
861
862
  }
862
863
  });
864
+
865
+ describe('after a restart of the service worker', function () {
866
+ const TAB_ID = 7;
867
+ const WINDOW_ID = 1;
868
+ const URL_A = 'https://www.example.com/start';
869
+ const URL_B = 'https://www.example.com/article';
870
+ let sessionApi;
871
+
872
+ function tab(url, status) {
873
+ return {
874
+ id: TAB_ID,
875
+ windowId: WINDOW_ID,
876
+ incognito: false,
877
+ active: true,
878
+ status,
879
+ title: `Title of ${url}`,
880
+ url,
881
+ };
882
+ }
883
+
884
+ function navigate(url, transitionType) {
885
+ chromeApiMock.tabs.onUpdated.dispatch(
886
+ TAB_ID,
887
+ { status: 'loading', url },
888
+ tab(url, 'loading'),
889
+ );
890
+ chromeApiMock.webNavigation.onCommitted.dispatch({
891
+ tabId: TAB_ID,
892
+ frameId: 0,
893
+ parentFrameId: -1,
894
+ url,
895
+ transitionType,
896
+ });
897
+ chromeApiMock.tabs.onUpdated.dispatch(
898
+ TAB_ID,
899
+ { status: 'complete' },
900
+ tab(url, 'complete'),
901
+ );
902
+ }
903
+
904
+ // like "initMocks", but the state is kept in the (fake) session storage
905
+ async function startPages({ openTabs }) {
906
+ chromeApiMock.tabs.query = async () => openTabs;
907
+ uut = new Pages({
908
+ config: { pages: { chrome: chromeApiMock } },
909
+ urlAnalyzer,
910
+ newPageApprover: stubNewPageApprover(),
911
+ pageSessionStore: new SessionStorageWrapper({
912
+ sessionApi,
913
+ namespace: 'test',
914
+ }),
915
+ });
916
+ await uut.init();
917
+ await uut.blockUntilFullInit();
918
+ }
919
+
920
+ async function restart({ openTabs }) {
921
+ await uut.sessionStore.flush();
922
+ uut.unload();
923
+ await startPages({ openTabs });
924
+ }
925
+
926
+ beforeEach(async function () {
927
+ sessionApi = new FakeSessionApi();
928
+ await startPages({ openTabs: [] });
929
+
930
+ // the user opens a page, and then follows a link to another page
931
+ chromeApiMock.tabs.onActivated.dispatch({
932
+ tabId: TAB_ID,
933
+ windowId: WINDOW_ID,
934
+ });
935
+ navigate(URL_A, 'typed');
936
+ navigate(URL_B, 'link');
937
+ expect(uut.describeTab(TAB_ID)).to.include({ url: URL_B, ref: URL_A });
938
+ });
939
+
940
+ it('should keep the information about a tab that is still open', async function () {
941
+ await restart({ openTabs: [tab(URL_B, 'complete')] });
942
+
943
+ expect([...uut.openTabs.keys()]).to.eql([TAB_ID]);
944
+ expect(uut.describeTab(TAB_ID)).to.include({
945
+ url: URL_B,
946
+ ref: URL_A,
947
+ pageLoadMethod: 'full-page-load',
948
+ });
949
+ });
950
+
951
+ it('should drop the information if the tab shows another page now', async function () {
952
+ await restart({ openTabs: [tab(URL_A, 'complete')] });
953
+
954
+ expect([...uut.openTabs.keys()]).to.eql([TAB_ID]);
955
+ expect(uut.describeTab(TAB_ID).url).to.eql(URL_A);
956
+ expect(uut.describeTab(TAB_ID).ref).to.be.undefined;
957
+ });
958
+
959
+ it('should drop a tab that was closed', async function () {
960
+ await restart({ openTabs: [] });
961
+
962
+ expect([...uut.openTabs.keys()]).to.eql([]);
963
+ });
964
+ });
863
965
  });
864
966
  });
865
967