@whotracksme/reporting 12.1.19 β†’ 12.1.20

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.20 (Fri Nov 20 2026)
2
+
3
+ #### πŸ› Bug Fix
4
+
5
+ - Fixed: do not change the pageId on title updates [#262](https://github.com/whotracksme/webextension-packages/pull/262) ([@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.19 (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.19",
3
+ "version": "12.1.20",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./sanitizer": "./reporting/src/sanitizer.js",
@@ -1163,8 +1163,9 @@ export default class Pages {
1163
1163
 
1164
1164
  let updated = false;
1165
1165
  if (tab.title && tab.title !== entry.title) {
1166
+ // A new title is not a navigation. Keep the page id, or pending
1167
+ // lazy variables (e.g. the page structure) are lost for this page.
1166
1168
  entry.title = tab.title;
1167
- entry.pageId = ++this._pageIdGenerator;
1168
1169
  updated = true;
1169
1170
  }
1170
1171
  if (tab.url && tab.url !== entry.url) {
@@ -1914,6 +1915,7 @@ export default class Pages {
1914
1915
  type: 'lazy-init',
1915
1916
  field,
1916
1917
  tabId,
1918
+ cancelled: result === CANCEL_LAZY_VAR,
1917
1919
  });
1918
1920
  })
1919
1921
  .catch((e) => {
@@ -802,6 +802,138 @@ describe('#Pages', function () {
802
802
  });
803
803
  });
804
804
 
805
+ describe('when the title changes during the page analysis', function () {
806
+ const TAB_ID = 7;
807
+ const WINDOW_ID = 1;
808
+ const PAGE_URL = 'https://www.example.com/app';
809
+ const OTHER_URL = 'https://www.example.com/other';
810
+ let finishPageAnalysis;
811
+ let pageEvents;
812
+
813
+ function tab({
814
+ url = PAGE_URL,
815
+ title = 'App',
816
+ status = 'complete',
817
+ } = {}) {
818
+ return {
819
+ id: TAB_ID,
820
+ windowId: WINDOW_ID,
821
+ incognito: false,
822
+ active: true,
823
+ status,
824
+ title,
825
+ url,
826
+ };
827
+ }
828
+
829
+ function beginPageLoad(url) {
830
+ chromeApiMock.tabs.onUpdated.dispatch(
831
+ TAB_ID,
832
+ { status: 'loading', url },
833
+ tab({ url, status: 'loading' }),
834
+ );
835
+ }
836
+
837
+ function finishPageLoad(url) {
838
+ chromeApiMock.tabs.onUpdated.dispatch(
839
+ TAB_ID,
840
+ { status: 'complete' },
841
+ tab({ url }),
842
+ );
843
+ }
844
+
845
+ function changeTitle(title) {
846
+ chromeApiMock.tabs.onUpdated.dispatch(
847
+ TAB_ID,
848
+ { title },
849
+ tab({ title }),
850
+ );
851
+ }
852
+
853
+ function pageAnalysisEvents() {
854
+ return pageEvents.filter(
855
+ ({ type, field }) =>
856
+ type === 'lazy-init' && field === 'pageStructure',
857
+ );
858
+ }
859
+
860
+ beforeEach(function () {
861
+ // the page analysis script runs until the test ends it
862
+ chromeApiMock.scripting = {
863
+ executeScript: () =>
864
+ new Promise((resolve) => {
865
+ finishPageAnalysis = async () => {
866
+ const result = {
867
+ title: 'App',
868
+ url: PAGE_URL,
869
+ noindex: false,
870
+ };
871
+ resolve([{ result }]);
872
+ await waitForPendingMicrotasks();
873
+ };
874
+ }),
875
+ };
876
+ pageEvents = [];
877
+ uut.addObserver((event) => pageEvents.push(event));
878
+ chromeApiMock.tabs.onActivated.dispatch({
879
+ tabId: TAB_ID,
880
+ windowId: WINDOW_ID,
881
+ });
882
+ });
883
+
884
+ it('should not cancel the page analysis', async function () {
885
+ beginPageLoad(PAGE_URL);
886
+ finishPageLoad(PAGE_URL);
887
+ changeTitle('(1) App');
888
+ await finishPageAnalysis();
889
+
890
+ expect(pageAnalysisEvents()).to.eql([
891
+ {
892
+ type: 'lazy-init',
893
+ field: 'pageStructure',
894
+ tabId: TAB_ID,
895
+ cancelled: false,
896
+ },
897
+ ]);
898
+ const page = uut.describeTab(TAB_ID);
899
+ expect(page.title).to.eql('(1) App');
900
+ expect(page.preDoublefetch).to.include({
901
+ title: 'App',
902
+ noindex: false,
903
+ });
904
+ });
905
+
906
+ it('should still report the new title', function () {
907
+ beginPageLoad(PAGE_URL);
908
+ finishPageLoad(PAGE_URL);
909
+ changeTitle('(1) App');
910
+
911
+ expect(pageEvents).to.deep.include({
912
+ type: 'page-updated',
913
+ tabId: TAB_ID,
914
+ });
915
+ });
916
+
917
+ it('should cancel the page analysis if the tab loads another page', async function () {
918
+ beginPageLoad(PAGE_URL);
919
+ finishPageLoad(PAGE_URL);
920
+ beginPageLoad(OTHER_URL);
921
+ await finishPageAnalysis();
922
+
923
+ expect(pageAnalysisEvents()).to.eql([
924
+ {
925
+ type: 'lazy-init',
926
+ field: 'pageStructure',
927
+ tabId: TAB_ID,
928
+ cancelled: true,
929
+ },
930
+ ]);
931
+ const page = uut.describeTab(TAB_ID);
932
+ expect(page.url).to.eql(OTHER_URL);
933
+ expect(page.preDoublefetch).to.be.undefined;
934
+ });
935
+ });
936
+
805
937
  // This are optional tests that can be enabled if the REPLAY_FIXTURES_URL
806
938
  // environment variable is defined. Karma lacks access to the filesystem,
807
939
  // but we can fetch fixtures over the network.