@whotracksme/reporting 5.1.26 → 5.1.27

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.
@@ -9,277 +9,346 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import logger from './logger.js';
13
- import {
14
- setActive,
15
- create as makeTabContext,
16
- PAGE_LOADING_STATE,
17
- } from './page.js';
18
12
  import ChromeStorageMap from '../request/utils/chrome-storage-map.js';
19
13
 
20
14
  const PAGE_TTL = 1000 * 60 * 60; // 1 hour
21
15
 
16
+ const PAGE_LOADING_STATE = {
17
+ CREATED: 'created',
18
+ NAVIGATING: 'navigating',
19
+ COMMITTED: 'committed',
20
+ COMPLETE: 'complete',
21
+ };
22
+
23
+ class Page {
24
+ constructor(page) {
25
+ this.id = page.id;
26
+ this.url = page.url;
27
+ this.isPrivate = page.incognito || false;
28
+ this.isPrivateServer = page.isPrivateServer || false;
29
+ this.created = page.created || Date.now();
30
+ this.destroyed = page.destroyed || null;
31
+ this.frames = page.frames || {
32
+ 0: {
33
+ parentFrameId: -1,
34
+ url: page.url,
35
+ },
36
+ };
37
+ this.state = page.state || PAGE_LOADING_STATE.CREATED;
38
+
39
+ this.activeTime = page.activeTime || 0;
40
+ this.activeFrom = page.active ? Date.now() : 0;
41
+
42
+ this.requestStats = page.requestStats || {};
43
+ this.annotations = page.annotations || {};
44
+ this.counter = page.counter || 0;
45
+ this.previous = page.previous;
46
+ }
47
+
48
+ setActive(active) {
49
+ if (active && this.activeFrom === 0) {
50
+ this.activeFrom = Date.now();
51
+ } else if (!active && this.activeFrom > 0) {
52
+ this.activeTime += Date.now() - this.activeFrom;
53
+ this.activeFrom = 0;
54
+ }
55
+ }
56
+
57
+ getStatsForDomain(domain) {
58
+ return (this.requestStats[domain] ||= {});
59
+ }
60
+ }
61
+
22
62
  export default class PageStore {
63
+ #notifyPageStageListeners;
64
+ #pages;
65
+
23
66
  constructor({ notifyPageStageListeners }) {
24
- this.tabs = new ChromeStorageMap({
67
+ this.#pages = new ChromeStorageMap({
25
68
  storageKey: 'wtm-url-reporting:page-store:tabs',
26
69
  ttlInMs: PAGE_TTL,
27
70
  });
28
- this.staged = [];
29
- this.notifyPageStageListeners = notifyPageStageListeners;
71
+ this.#notifyPageStageListeners = notifyPageStageListeners;
30
72
  }
31
73
 
32
74
  async init() {
33
- await this.tabs.isReady;
34
- chrome.tabs.onCreated.addListener(this.onTabCreated);
35
- chrome.tabs.onUpdated.addListener(this.onTabUpdated);
36
- chrome.tabs.onRemoved.addListener(this.onTabRemoved);
37
- chrome.tabs.onActivated.addListener(this.onTabActivated);
38
- chrome.webNavigation.onBeforeNavigate.addListener(this.onBeforeNavigate);
39
- chrome.webNavigation.onCommitted.addListener(this.onNavigationCommitted);
40
- chrome.webNavigation.onCompleted.addListener(this.onNavigationComplete);
41
- if (chrome.windows && chrome.windows.onFocusChanged) {
42
- chrome.windows.onFocusChanged.addListener(this.onWindowFocusChanged);
43
- }
75
+ await this.#pages.isReady;
76
+ chrome.tabs.onCreated.addListener(this.#onTabCreated);
77
+ chrome.tabs.onUpdated.addListener(this.#onTabUpdated);
78
+ chrome.tabs.onRemoved.addListener(this.#onTabRemoved);
79
+ chrome.tabs.onActivated.addListener(this.#onTabActivated);
80
+ chrome.webNavigation.onBeforeNavigate.addListener(this.#onBeforeNavigate);
81
+ chrome.webNavigation.onCommitted.addListener(this.#onNavigationCommitted);
82
+ chrome.webNavigation.onCompleted.addListener(this.#onNavigationCompleted);
83
+ chrome.windows.onFocusChanged?.addListener(this.#onWindowFocusChanged);
84
+
44
85
  // popupate initially open tabs
45
- chrome.tabs.query({}, (openTabs) => {
46
- openTabs.forEach((tab) => {
47
- this.onTabCreated(tab);
48
- });
49
- });
86
+ (await chrome.tabs.query({})).forEach((tab) => this.#onTabCreated(tab));
50
87
  }
51
88
 
52
89
  unload() {
53
- this.tabs.forEach((page) => this.stagePage(page));
54
- this.tabs.clear();
55
-
56
- chrome.tabs.onCreated.removeListener(this.onTabCreated);
57
- chrome.tabs.onUpdated.removeListener(this.onTabUpdated);
58
- chrome.tabs.onRemoved.removeListener(this.onTabRemoved);
59
- chrome.tabs.onActivated.removeListener(this.onTabActivated);
60
- chrome.webNavigation.onBeforeNavigate.removeListener(this.onBeforeNavigate);
61
- chrome.webNavigation.onCommitted.removeListener(this.onNavigationCommitted);
62
- chrome.webNavigation.onCompleted.removeListener(this.onNavigationComplete);
63
- if (chrome.windows && chrome.windows.onFocusChanged) {
64
- chrome.windows.onFocusChanged.removeListener(this.onWindowFocusChanged);
65
- }
90
+ this.#pages.forEach((serializedPage) => {
91
+ const page = new Page(serializedPage);
92
+ this.#stagePage(page);
93
+ });
94
+ this.#pages.clear();
95
+
96
+ chrome.tabs.onCreated.removeListener(this.#onTabCreated);
97
+ chrome.tabs.onUpdated.removeListener(this.#onTabUpdated);
98
+ chrome.tabs.onRemoved.removeListener(this.#onTabRemoved);
99
+ chrome.tabs.onActivated.removeListener(this.#onTabActivated);
100
+ chrome.webNavigation.onBeforeNavigate.removeListener(
101
+ this.#onBeforeNavigate,
102
+ );
103
+ chrome.webNavigation.onCommitted.removeListener(
104
+ this.#onNavigationCommitted,
105
+ );
106
+ chrome.webNavigation.onCompleted.removeListener(
107
+ this.#onNavigationCompleted,
108
+ );
109
+ chrome.windows.onFocusChanged?.removeListener(this.#onWindowFocusChanged);
66
110
  }
67
111
 
68
- stagePage(page) {
69
- if (this.staged.push(page) > 5) {
70
- this.staged.shift();
71
- }
72
- setActive(page, false);
112
+ checkIfEmpty() {
113
+ // this operations can potentially be expensive
114
+ return this.#pages.countNonExpiredKeys() === 0;
115
+ }
116
+
117
+ #stagePage(page) {
118
+ page.setActive(false);
73
119
  page.destroyed = Date.now();
74
120
  // unset previous (to prevent history chain memory leak)
75
121
  page.previous = undefined;
76
- this.notifyPageStageListeners(page);
122
+ this.#pages.set(page.id, page);
123
+ this.#notifyPageStageListeners(page);
77
124
  }
78
125
 
79
126
  /**
80
127
  * Create a new `tabContext` for the new tab
81
128
  */
82
- onTabCreated = (tab) => {
83
- this.tabs.set(tab.id, makeTabContext(tab));
129
+ #onTabCreated = (tab) => {
130
+ this.#pages.set(tab.id, new Page(tab));
84
131
  };
85
132
 
86
133
  /**
87
134
  * Update an existing tab or create it if we do not have a context yet.
88
135
  */
89
- onTabUpdated = (tabId, info, tab) => {
90
- let tabContext = this.tabs.get(tabId);
91
- if (!tabContext) {
92
- tabContext = makeTabContext(tab);
93
- this.tabs.set(tabId, tabContext);
94
- }
136
+ #onTabUpdated = (tabId, info, tab) => {
137
+ const page = new Page(this.#pages.get(tabId) || tab);
95
138
 
96
139
  // Update `isPrivate` and `url` if available
97
- tabContext.isPrivate = tab.incognito;
98
- setActive(tabContext, tab.active);
140
+ page.isPrivate = tab.incognito;
141
+ page.setActive(tab.active);
99
142
  if (info.url !== undefined) {
100
- tabContext.url = info.url;
143
+ page.url = info.url;
101
144
  }
145
+
146
+ this.#pages.set(tabId, page);
102
147
  };
103
148
 
104
149
  /**
105
150
  * Remove tab context for `tabId`.
106
151
  */
107
- onTabRemoved = (tabId) => {
108
- const tabContext = this.tabs.get(tabId);
109
- if (tabContext && tabContext.state === PAGE_LOADING_STATE.COMPLETE) {
110
- this.stagePage(tabContext);
152
+ #onTabRemoved = (tabId) => {
153
+ const serializedPage = this.#pages.get(tabId);
154
+ if (!serializedPage) {
155
+ return;
111
156
  }
112
- this.tabs.delete(tabId);
157
+ const page = new Page(serializedPage);
158
+ if (page.state === PAGE_LOADING_STATE.COMPLETE) {
159
+ this.#stagePage(page);
160
+ }
161
+ this.#pages.delete(tabId);
113
162
  };
114
163
 
115
- onTabActivated = ({ previousTabId, tabId }) => {
164
+ #onTabActivated = (details) => {
165
+ const { previousTabId, tabId } = details;
116
166
  // if previousTabId is not set (e.g. on chrome), set all tabs to inactive
117
167
  // otherwise, we only have to mark the previous tab as inactive
118
168
  if (!previousTabId) {
119
- for (const tab of this.tabs.values()) {
120
- setActive(tab, false);
169
+ for (const serializedPage of this.#pages.values()) {
170
+ const page = new Page(serializedPage);
171
+ page.setActive(false);
172
+ this.#pages.set(page.id, page);
121
173
  }
122
- } else if (this.tabs.has(previousTabId)) {
123
- setActive(this.tabs.get(previousTabId), false);
174
+ } else if (this.#pages.has(previousTabId)) {
175
+ const page = new Page(previousTabId);
176
+ page.setActive(false);
177
+ this.#pages.set(page.id, page);
124
178
  }
125
- if (this.tabs.has(tabId)) {
126
- setActive(this.tabs.get(tabId), true);
179
+
180
+ if (this.#pages.has(tabId)) {
181
+ const page = new Page(this.#pages.get(tabId));
182
+ page.setActive(true);
183
+ this.#pages.set(page.id, page);
127
184
  }
128
185
  };
129
186
 
130
- onWindowFocusChanged = (focusedWindow) => {
131
- chrome.tabs.query({ active: true }, (activeTabs) => {
132
- activeTabs.forEach(({ id, windowId }) => {
133
- const tabContext = this.tabs.get(id);
134
- if (!tabContext) {
135
- return;
136
- }
137
- if (windowId === focusedWindow) {
138
- setActive(tabContext, true);
139
- } else {
140
- setActive(tabContext, false);
141
- }
142
- });
143
- });
187
+ #onWindowFocusChanged = async (focusedWindowId) => {
188
+ const activeTabs = await chrome.tabs.query({ active: true });
189
+ for (const { id, windowId } of activeTabs) {
190
+ const serializedPage = this.#pages.get(id);
191
+ if (!serializedPage) {
192
+ continue;
193
+ }
194
+ const page = new Page(serializedPage);
195
+ page.setActive(windowId === focusedWindowId);
196
+ this.#pages.set(id, page);
197
+ }
144
198
  };
145
199
 
146
- onBeforeNavigate = (details) => {
200
+ #onBeforeNavigate = (details) => {
147
201
  const { frameId, tabId, url, timeStamp } = details;
148
- const tabContext = this.tabs.get(tabId);
149
- if (frameId === 0) {
150
- // ignore duplicated onBeforeNavigate https://bugzilla.mozilla.org/show_bug.cgi?id=1732564
202
+
203
+ if (frameId !== 0) {
204
+ return;
205
+ }
206
+
207
+ const page = this.#pages.has(tabId)
208
+ ? new Page(this.#pages.get(tabId))
209
+ : null;
210
+
211
+ if (page) {
212
+ // ignore duplicated #onBeforeNavigate https://bugzilla.mozilla.org/show_bug.cgi?id=1732564
151
213
  if (
152
- tabContext &&
153
- tabContext.id === tabId &&
154
- tabContext.url === url &&
155
- tabContext.created + 200 > timeStamp
214
+ page.id === tabId &&
215
+ page.url === url &&
216
+ page.created + 200 > timeStamp
156
217
  ) {
157
218
  return;
158
219
  }
159
220
  // We are starting a navigation to a new page - if the previous page is complete (i.e. fully
160
221
  // loaded), stage it before we create the new page info.
161
- if (tabContext && tabContext.state === PAGE_LOADING_STATE.COMPLETE) {
162
- this.stagePage(tabContext);
222
+ if (page.state === PAGE_LOADING_STATE.COMPLETE) {
223
+ this.#stagePage(page);
163
224
  }
164
- // create a new page for the navigation
165
- this.tabs.delete(tabId);
166
- const nextContext = makeTabContext({
167
- id: tabId,
168
- active: false,
169
- url,
170
- incognito: tabContext ? tabContext.isPrivate : false,
171
- created: timeStamp,
172
- });
173
- nextContext.previous = tabContext;
174
- this.tabs.set(tabId, nextContext);
175
- nextContext.state = PAGE_LOADING_STATE.NAVIGATING;
176
225
  }
226
+
227
+ // create a new page for the navigation
228
+ this.#pages.delete(tabId);
229
+
230
+ const nextPage = new Page({
231
+ id: tabId,
232
+ active: false,
233
+ url,
234
+ incognito: page ? page.isPrivate : false,
235
+ created: timeStamp,
236
+ });
237
+ nextPage.previous = page;
238
+ nextPage.state = PAGE_LOADING_STATE.NAVIGATING;
239
+ this.#pages.set(tabId, nextPage);
177
240
  };
178
241
 
179
- onNavigationCommitted = (details) => {
242
+ #onNavigationCommitted = (details) => {
180
243
  const { frameId, tabId } = details;
181
- const tabContext = this.tabs.get(tabId);
182
- if (frameId === 0 && tabContext) {
183
- tabContext.state = PAGE_LOADING_STATE.COMMITTED;
184
- } else if (tabContext && !tabContext.frames[frameId]) {
244
+ const serializedPage = this.#pages.get(tabId);
245
+
246
+ if (!serializedPage) {
247
+ return;
248
+ }
249
+
250
+ const page = new Page(serializedPage);
251
+
252
+ if (frameId === 0) {
253
+ page.state = PAGE_LOADING_STATE.COMMITTED;
254
+ this.#pages.set(tabId, page);
255
+ } else if (!page.frames[frameId]) {
185
256
  // frame created without request
186
257
  this.onSubFrame(details);
187
258
  }
188
259
  };
189
260
 
190
- onNavigationComplete = ({ frameId, tabId }) => {
191
- const tabContext = this.tabs.get(tabId);
192
- if (frameId === 0 && tabContext) {
193
- tabContext.state = PAGE_LOADING_STATE.COMPLETE;
261
+ #onNavigationCompleted = (details) => {
262
+ const { frameId, tabId } = details;
263
+ const serializedPage = this.#pages.get(tabId);
264
+ if (!serializedPage) {
265
+ return;
266
+ }
267
+ const page = new Page(serializedPage);
268
+ if (frameId === 0) {
269
+ page.state = PAGE_LOADING_STATE.COMPLETE;
194
270
  }
271
+ this.#pages.set(tabId, page);
195
272
  };
196
273
 
197
- onMainFrame = ({ tabId, url, requestId }, event) => {
274
+ onMainFrame = (details, event) => {
275
+ const { tabId, url } = details;
198
276
  // main frame from tabId -1 is from service worker and should not be saved
199
277
  if (tabId === -1) {
200
278
  return;
201
279
  }
280
+
202
281
  // Update last request id from the tab
203
- let tabContext = this.tabs.get(tabId);
204
- if (!tabContext) {
205
- tabContext = makeTabContext({ url, incognito: false });
206
- this.tabs.set(tabId, tabContext);
207
- }
282
+ const page = new Page(
283
+ this.#pages.get(tabId) || { url, incognito: false, id: tabId },
284
+ );
208
285
 
209
286
  if (event === 'onBeforeRequest') {
210
- tabContext.frames = {};
211
- // Detect redirect: if the last request on this tab had the same id and
212
- // this was from the same `onBeforeRequest` hook, we can assume this is a
213
- // redirection.
214
- if (tabContext.lastRequestId === requestId) {
215
- tabContext.isRedirect = true;
216
- }
217
-
218
- // Only keep track of `lastRequestId` with `onBeforeRequest` listener
219
- // since we need this information for redirect detection only and this can
220
- // be detected with this hook.
221
- tabContext.lastRequestId = requestId;
287
+ page.frames = {};
222
288
  }
223
289
 
224
290
  // Update context of tab with `url` and main frame information
225
- tabContext.url = url;
226
- tabContext.frames[0] = {
291
+ page.url = url;
292
+ page.frames[0] = {
227
293
  parentFrameId: -1,
228
294
  url,
229
295
  };
296
+
297
+ this.#pages.set(tabId, page);
230
298
  };
231
299
 
232
300
  onSubFrame = (details) => {
233
301
  const { tabId, frameId, parentFrameId, url } = details;
234
- const tab = this.tabs.get(tabId);
235
- if (!tab) {
236
- logger.log('Could not find tab for sub_frame request', details);
302
+ const serializedPage = this.#pages.get(tabId);
303
+ if (!serializedPage) {
237
304
  return;
238
305
  }
239
-
306
+ const page = new Page(serializedPage);
240
307
  // Keep track of frameUrl as well as parent frame
241
- tab.frames[frameId] = {
308
+ page.frames[frameId] = {
242
309
  parentFrameId,
243
310
  url,
244
311
  };
312
+ this.#pages.set(tabId, page);
245
313
  };
246
314
 
247
315
  getPageForRequest(context) {
248
316
  const { tabId, frameId, originUrl, type, initiator } = context;
249
- const tab = this.tabs.get(tabId);
250
- if (!tab) {
317
+ const serializedPage = this.#pages.get(tabId);
318
+ if (!serializedPage) {
251
319
  return null;
252
320
  }
321
+ const page = new Page(serializedPage);
253
322
  // check if the current page has the given frame id, otherwise check if it belongs to the
254
323
  // previous page
255
- if (!tab.frames[frameId]) {
256
- if (tab.previous && tab.previous.frames[frameId]) {
257
- return tab.previous;
324
+ if (!page.frames[frameId]) {
325
+ if (page.previous && page.previous.frames[frameId]) {
326
+ return page.previous;
258
327
  }
259
328
  return null;
260
329
  }
261
330
 
262
331
  const couldBePreviousPage =
263
- frameId === 0 && type !== 'main_frame' && tab.previous;
332
+ frameId === 0 && type !== 'main_frame' && page.previous;
264
333
 
265
334
  // for main frame requests: check if the origin url is from the previous page (Firefox)
266
335
  if (
267
336
  couldBePreviousPage &&
268
- tab.url !== originUrl &&
269
- tab.previous.url === originUrl
337
+ page.url !== originUrl &&
338
+ page.previous.url === originUrl
270
339
  ) {
271
- return tab.previous;
340
+ return page.previous;
272
341
  }
273
342
  // on Chrome we have `initiator` which only contains the origin. In this case, check for a
274
343
  // different origin
275
344
  if (
276
345
  couldBePreviousPage &&
277
346
  initiator &&
278
- !tab.url.startsWith(initiator) &&
279
- tab.previous.url.startsWith(initiator)
347
+ !page.url.startsWith(initiator) &&
348
+ page.previous.url.startsWith(initiator)
280
349
  ) {
281
- return tab.previous;
350
+ return page.previous;
282
351
  }
283
- return tab;
352
+ return page;
284
353
  }
285
354
  }
@@ -11,7 +11,6 @@
11
11
 
12
12
  import { parse } from '../utils/url.js';
13
13
  import logger from './logger.js';
14
- import { getFrameUrl, getFrameAncestors } from './page.js';
15
14
 
16
15
  /**
17
16
  * Transform an array of headers (i.e.: `{ name, value }`) into a `Map`.
@@ -59,38 +58,17 @@ export default class WebRequestContext {
59
58
  // Get context on this page
60
59
  const page = pageStore.getPageForRequest(context);
61
60
 
62
- // **Chromium addition**
63
- // frameAncestors
64
- if (context.frameAncestors === undefined) {
65
- context.frameAncestors = page ? getFrameAncestors(page, context) : [];
66
- }
67
-
68
- // Cliqz-specific extensions to webRequest details
61
+ // Ghostery-specific extensions to webRequest details
69
62
  context.page = page;
70
63
  context.tabUrl = context.tabUrl || (page && page.url);
71
- context.frameUrl = context.frameUrl || (page && getFrameUrl(page, context));
72
64
  context.isPrivate = page ? page.isPrivate : null;
73
65
  context.isMainFrame = context.type === 'main_frame';
74
- context.isRedirect = page && context.isMainFrame && page.isRedirect;
75
66
 
76
67
  if (!context.tabUrl) {
77
68
  context.tabUrl =
78
69
  context.originUrl || context.initiator || context.documentUrl;
79
70
  }
80
71
 
81
- if (!context.frameUrl) {
82
- context.frameUrl =
83
- context.documentUrl || context.originUrl || context.initiator;
84
- }
85
-
86
- if (!context.originUrl) {
87
- context.originUrl =
88
- context.initiator ||
89
- context.documentUrl ||
90
- context.frameUrl ||
91
- context.tabUrl;
92
- }
93
-
94
72
  return new WebRequestContext(context);
95
73
  }
96
74
 
@@ -98,15 +76,11 @@ export default class WebRequestContext {
98
76
  Object.assign(this, details);
99
77
 
100
78
  // Lazy attributes
101
- this._frameUrlParts = null;
102
-
103
79
  this._requestHeadersMap = null;
104
80
  this._responseHeadersMap = null;
105
81
 
106
82
  this.urlParts = parse(this.url);
107
- this.frameUrlParts = parse(this.frameUrl);
108
83
  this.tabUrlParts = parse(this.tabUrl);
109
- this.originUrlParts = parse(this.originUrl);
110
84
  }
111
85
 
112
86
  /**
@@ -145,10 +119,4 @@ export default class WebRequestContext {
145
119
  getReferrer() {
146
120
  return this.getRequestHeader('Referer');
147
121
  }
148
-
149
- isBackgroundRequest() {
150
- return (
151
- this.tabId === -1 && this.originUrlParts?.protocol.endsWith('extension:')
152
- );
153
- }
154
122
  }
@@ -72,14 +72,33 @@ export async function playScenario(
72
72
  throw new Error('specify scenario release');
73
73
  }
74
74
 
75
+ const seenTabIds = new Set();
75
76
  const scenarioPath = await download(scenarioRelease, scenarioName, browser);
76
77
  const events = loadScenario(scenarioPath);
77
78
  for (const event of events) {
78
79
  try {
79
80
  const args = event.args.map(rewriteIp);
81
+
82
+ if (events.api === 'tabs' && event.event === 'onCreated') {
83
+ seenTabIds.add(args[0].id);
84
+ } else {
85
+ if (Object.prototype.hasOwnProperty.call(args[0], 'tabId')) {
86
+ seenTabIds.add(args[0].tabId);
87
+ }
88
+
89
+ if (
90
+ Object.prototype.hasOwnProperty.call(args[0], 'successorTabId') &&
91
+ args[0].successorTabId !== -1
92
+ ) {
93
+ seenTabIds.add(args[0].successorTabId);
94
+ }
95
+ }
96
+
80
97
  chrome[event.api][event.event].dispatch(...args);
81
98
  } catch (e) {
82
99
  console.error(`Could not dispatch event`, event, e);
83
100
  }
84
101
  }
102
+
103
+ return { seenTabIds };
85
104
  }
@@ -11,6 +11,7 @@
11
11
 
12
12
  import * as chai from 'chai';
13
13
  import sinon from 'sinon';
14
+
14
15
  // import FakeSessionApi from '../helpers/fake-session-storage.js'; // TODO: see comments below
15
16
 
16
17
  import testPages from './test-pages.js';
@@ -82,7 +83,6 @@ describe('request/index', function () {
82
83
  afterEach(() => {
83
84
  pipeline?.unload();
84
85
  pipeline = null;
85
-
86
86
  if (monkeyPatchedChromeStorage) {
87
87
  chrome.storage.session = oldChromeStorageSession;
88
88
  chrome.storage = oldChromeStorage;
@@ -139,9 +139,7 @@ describe('request/index', function () {
139
139
  });
140
140
 
141
141
  function simulatePageLoad(pageSpec) {
142
- pipeline.pageStore.onTabCreated({
143
- ...pageSpec.tab,
144
- });
142
+ chrome.tabs.onCreated.dispatch(pageSpec.tab);
145
143
  return {
146
144
  onBeforeRequest: pageSpec.onBeforeRequest.map(function (reqData) {
147
145
  const response = pipeline.onBeforeRequest(reqData);
@@ -296,7 +294,6 @@ describe('request/index', function () {
296
294
  type: 'main_frame',
297
295
  url: 'http://cliqztest.com/',
298
296
  requestHeaders: mockRequestHeaders,
299
- frameAncestors: [],
300
297
  });
301
298
  chai.expect(mainDoc).to.not.have.property('cancel');
302
299
  chai.expect(mainDoc).to.not.have.property('redirectUrl');
@@ -313,7 +310,6 @@ describe('request/index', function () {
313
310
  requestHeaders: mockRequestHeaders,
314
311
  initiator: 'http://cliqztest.com',
315
312
  isPrivate: false,
316
- frameAncestors: [],
317
313
  });
318
314
  chai.expect(response).to.have.property('redirectUrl');
319
315
  chai.expect(response.redirectUrl).to.not.contain(uid);
@@ -331,7 +327,6 @@ describe('request/index', function () {
331
327
  requestHeaders: mockRequestHeaders,
332
328
  originUrl: '',
333
329
  tabUrl: '',
334
- frameAncestors: [],
335
330
  });
336
331
  chai.expect(mainDoc).to.not.have.property('cancel');
337
332
  chai.expect(mainDoc).to.not.have.property('redirectUrl');
@@ -349,7 +344,6 @@ describe('request/index', function () {
349
344
  originUrl: 'http://cliqztest.com',
350
345
  tabUrl: 'http://cliqztest.com',
351
346
  isPrivate: false,
352
- frameAncestors: [],
353
347
  });
354
348
  chai.expect(response).to.have.property('redirectUrl');
355
349
  chai.expect(response.redirectUrl).to.not.contain(uid);
@@ -368,7 +362,6 @@ describe('request/index', function () {
368
362
  originUrl: 'http://cliqztest.com',
369
363
  tabUrl: 'http://cliqztest.com',
370
364
  isPrivate: false,
371
- frameAncestors: [],
372
365
  });
373
366
  chai.expect(response).to.have.property('redirectUrl');
374
367
  chai.expect(response.redirectUrl).to.not.contain(uid);