@whotracksme/reporting 5.1.17
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/.editorconfig +12 -0
- package/.eslintignore +3 -0
- package/.eslintrc +16 -0
- package/.github/workflows/release.yml +34 -0
- package/.github/workflows/tests.yml +20 -0
- package/.prettierrc +9 -0
- package/.tool-versions +1 -0
- package/CHANGELOG.md +795 -0
- package/LICENSE +373 -0
- package/README.md +1 -0
- package/communication/README.md +11 -0
- package/communication/example/index.js +43 -0
- package/communication/example/manifest.json +16 -0
- package/communication/karma.conf.cjs +19 -0
- package/communication/package.json +52 -0
- package/communication/rollup.common-config.cjs +17 -0
- package/communication/rollup.config.cjs +10 -0
- package/communication/src/encoding.js +54 -0
- package/communication/src/errors.js +84 -0
- package/communication/src/index.js +76 -0
- package/communication/src/logger.js +41 -0
- package/communication/src/padding.js +60 -0
- package/communication/src/proxied-http.js +231 -0
- package/communication/src/server-public-key-accessor.js +123 -0
- package/communication/src/timestamps.js +37 -0
- package/communication/src/trusted-clock.js +58 -0
- package/communication/src/utils.js +28 -0
- package/communication/src/zlib.js +17 -0
- package/communication/test/helpers/in-memory-database.js +43 -0
- package/communication/test/server-public-key-accessor.spec.js +135 -0
- package/communication/test/utils.spec.js +43 -0
- package/package.json +50 -0
- package/reporting/TODO.md +2 -0
- package/reporting/assets/request/bloom_filter.dat +0 -0
- package/reporting/assets/request/update.json +1 -0
- package/reporting/example/content.js +11 -0
- package/reporting/example/index.js +132 -0
- package/reporting/example/inspector/index.html +17 -0
- package/reporting/example/inspector/index.js +27 -0
- package/reporting/example/manifests/chromium.json +37 -0
- package/reporting/example/manifests/firefox.json +35 -0
- package/reporting/example/rules.json +62 -0
- package/reporting/example/setup.js +1 -0
- package/reporting/example/tests/test1.html +10 -0
- package/reporting/karma.conf.cjs +22 -0
- package/reporting/package.json +63 -0
- package/reporting/rollup.common-config.cjs +19 -0
- package/reporting/rollup.config.cjs +20 -0
- package/reporting/src/LRU.js +149 -0
- package/reporting/src/activity-estimator.js +298 -0
- package/reporting/src/alive-check.js +139 -0
- package/reporting/src/alive-message-generator.js +142 -0
- package/reporting/src/bloom-filters.js +345 -0
- package/reporting/src/country-provider.js +295 -0
- package/reporting/src/cyrb53.js +32 -0
- package/reporting/src/digest.js +33 -0
- package/reporting/src/doublefetch-page-handler.js +548 -0
- package/reporting/src/duplicate-detector.js +233 -0
- package/reporting/src/errors.js +84 -0
- package/reporting/src/event-listener-queue.js +121 -0
- package/reporting/src/fixed-size-cache.js +63 -0
- package/reporting/src/hash-detector.js +1526 -0
- package/reporting/src/html-parser.js +17 -0
- package/reporting/src/http.js +265 -0
- package/reporting/src/index.js +14 -0
- package/reporting/src/job-scheduler.js +912 -0
- package/reporting/src/logger.js +121 -0
- package/reporting/src/md5.js +334 -0
- package/reporting/src/message-sender.js +51 -0
- package/reporting/src/network.js +140 -0
- package/reporting/src/new-page-approver.js +119 -0
- package/reporting/src/page-aggregator.js +185 -0
- package/reporting/src/page-quorum-check-handler.js +200 -0
- package/reporting/src/page-structure.js +136 -0
- package/reporting/src/pagedb.js +671 -0
- package/reporting/src/pages.js +1798 -0
- package/reporting/src/patterns-updater.js +310 -0
- package/reporting/src/patterns.js +416 -0
- package/reporting/src/persisted-bitarray.js +265 -0
- package/reporting/src/persisted-hashes.js +189 -0
- package/reporting/src/quorum-checker.js +327 -0
- package/reporting/src/random.js +39 -0
- package/reporting/src/reporting.js +290 -0
- package/reporting/src/request/config.js +116 -0
- package/reporting/src/request/content-script.js +77 -0
- package/reporting/src/request/database.js +147 -0
- package/reporting/src/request/dnt.js +24 -0
- package/reporting/src/request/hash.js +101 -0
- package/reporting/src/request/index.js +874 -0
- package/reporting/src/request/page-telemetry.js +42 -0
- package/reporting/src/request/qs-whitelist2.js +247 -0
- package/reporting/src/request/resources/prob.js +601 -0
- package/reporting/src/request/steps/block-rules.js +40 -0
- package/reporting/src/request/steps/check-context.js +37 -0
- package/reporting/src/request/steps/cookie-context.js +209 -0
- package/reporting/src/request/steps/oauth-detector.js +101 -0
- package/reporting/src/request/steps/page-logger.js +177 -0
- package/reporting/src/request/steps/redirect-tagger.js +75 -0
- package/reporting/src/request/steps/subdomain-check.js +34 -0
- package/reporting/src/request/steps/token-checker/index.js +189 -0
- package/reporting/src/request/steps/token-checker/token-domain.js +129 -0
- package/reporting/src/request/steps/token-examiner.js +182 -0
- package/reporting/src/request/steps/token-telemetry/cached-entry-pipeline.js +210 -0
- package/reporting/src/request/steps/token-telemetry/index.js +234 -0
- package/reporting/src/request/steps/token-telemetry/key-pipeline.js +109 -0
- package/reporting/src/request/steps/token-telemetry/token-pipeline.js +105 -0
- package/reporting/src/request/time.js +73 -0
- package/reporting/src/request/utils/bloom-filter-packed.js +107 -0
- package/reporting/src/request/utils/chrome-storage-map.js +282 -0
- package/reporting/src/request/utils/subject.js +37 -0
- package/reporting/src/request/utils/temp-set.js +56 -0
- package/reporting/src/request/utils/tlds.js +55 -0
- package/reporting/src/request/utils.js +41 -0
- package/reporting/src/request-reporter.js +111 -0
- package/reporting/src/sanitizer.js +519 -0
- package/reporting/src/search-extractor.js +338 -0
- package/reporting/src/self-check.js +105 -0
- package/reporting/src/seq-executor.js +43 -0
- package/reporting/src/session-storage.js +399 -0
- package/reporting/src/url-analyzer.js +161 -0
- package/reporting/src/url-cleaner.js +60 -0
- package/reporting/src/utils/pacemaker.js +279 -0
- package/reporting/src/utils/url.js +114 -0
- package/reporting/src/utils.js +345 -0
- package/reporting/src/webrequest-pipeline/cname-uncloak.js +110 -0
- package/reporting/src/webrequest-pipeline/index.js +287 -0
- package/reporting/src/webrequest-pipeline/logger.js +14 -0
- package/reporting/src/webrequest-pipeline/page-store.js +282 -0
- package/reporting/src/webrequest-pipeline/page.js +140 -0
- package/reporting/src/webrequest-pipeline/pipeline.js +249 -0
- package/reporting/src/webrequest-pipeline/utils/webrequest.js +113 -0
- package/reporting/src/webrequest-pipeline/webrequest-context.js +153 -0
- package/reporting/test/README.md +2 -0
- package/reporting/test/activity-estimator.spec.js +356 -0
- package/reporting/test/alive-check.spec.js +156 -0
- package/reporting/test/alive-message-generator.spec.js +186 -0
- package/reporting/test/country-provider.spec.js +263 -0
- package/reporting/test/doublefetch-page-handler.spec.js +818 -0
- package/reporting/test/duplicate-detector.spec.js +689 -0
- package/reporting/test/helpers/dom-parsers.js +41 -0
- package/reporting/test/helpers/fake-session-storage.js +69 -0
- package/reporting/test/helpers/fast-check-utils.js +28 -0
- package/reporting/test/helpers/fetch-mock.js +57 -0
- package/reporting/test/helpers/in-memory-database.js +14 -0
- package/reporting/test/helpers/memory-map.js +72 -0
- package/reporting/test/helpers/pagedb-mocks.js +41 -0
- package/reporting/test/index.js +47 -0
- package/reporting/test/job-scheduler.spec.js +691 -0
- package/reporting/test/network.spec.js +72 -0
- package/reporting/test/page-aggregator.spec.js +104 -0
- package/reporting/test/page-quorum-check-handler.spec.js +86 -0
- package/reporting/test/pagedb.spec.js +250 -0
- package/reporting/test/pages.spec.js +693 -0
- package/reporting/test/patterns-updater.spec.js +446 -0
- package/reporting/test/patterns.spec.js +751 -0
- package/reporting/test/persisted-hashes.spec.js +169 -0
- package/reporting/test/reporting.spec.js +205 -0
- package/reporting/test/request/database.spec.js +59 -0
- package/reporting/test/request/hash.spec.js +108 -0
- package/reporting/test/request/index.spec.js +378 -0
- package/reporting/test/request/qs-whitelist2.spec.js +189 -0
- package/reporting/test/request/steps/check-context.spec.js +51 -0
- package/reporting/test/request/steps/oauth-detector.spec.js +339 -0
- package/reporting/test/request/test-pages.js +1246 -0
- package/reporting/test/request/utils/bloom-filter-packed.spec.js +37 -0
- package/reporting/test/request/utils/chrome-storage-map.spec.js +28 -0
- package/reporting/test/request/utils/tldts.spec.js +62 -0
- package/reporting/test/request/utils.spec.js +168 -0
- package/reporting/test/sanitizer.spec.js +1087 -0
- package/reporting/test/search-extractor.spec.js +590 -0
- package/reporting/test/seq-executor.spec.js +158 -0
- package/reporting/test/session-storage.spec.js +400 -0
- package/reporting/test/setup.js +24 -0
- package/reporting/test/url-analyzer.spec.js +451 -0
- package/reporting/test/url-cleaner.spec.js +102 -0
- package/reporting/test/utils/pacemaker.spec.js +222 -0
- package/reporting/test/utils/url.spec.js +660 -0
- package/reporting/test/utils.spec.js +299 -0
- package/reporting/test/webrequest-pipeline/pipeline.spec.js +251 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WhoTracks.Me
|
|
3
|
+
* https://whotracks.me/
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2017-present Ghostery GmbH. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
8
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
9
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import * as chai from 'chai';
|
|
13
|
+
|
|
14
|
+
import OAuthDetector from '../../../src/request/steps/oauth-detector.js';
|
|
15
|
+
import { parse } from '../../../src/utils/url.js';
|
|
16
|
+
// import FakeSessionApi from '../../helpers/fake-session-storage.js'; // TODO: see comments below
|
|
17
|
+
|
|
18
|
+
function mockSender(tab, url) {
|
|
19
|
+
return {
|
|
20
|
+
tab: {
|
|
21
|
+
id: tab,
|
|
22
|
+
url: url,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function delayedTest(test, done, delay) {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
try {
|
|
30
|
+
test();
|
|
31
|
+
done();
|
|
32
|
+
} catch (e) {
|
|
33
|
+
done(e);
|
|
34
|
+
}
|
|
35
|
+
}, delay);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe('request/steps/oauth-detector', function () {
|
|
39
|
+
let monkeyPatchedChromeStorage;
|
|
40
|
+
let oldChromeStorageSession;
|
|
41
|
+
let oldChromeStorage;
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
if (!chrome?.storage?.session) {
|
|
45
|
+
monkeyPatchedChromeStorage = true;
|
|
46
|
+
oldChromeStorage = chrome?.storage;
|
|
47
|
+
oldChromeStorageSession = chrome?.storage?.session;
|
|
48
|
+
chrome.storage = chrome.storage || {};
|
|
49
|
+
|
|
50
|
+
// Note: monkey patching with a real implementation fails.
|
|
51
|
+
// Thus, leaving the old way to monkey patch, even though it may
|
|
52
|
+
// indicate that there are bugs in the implementation or in the tests.
|
|
53
|
+
chrome.storage.session = chrome.storage.local;
|
|
54
|
+
chrome.storage.session.get.yields({});
|
|
55
|
+
|
|
56
|
+
// to test against a real (promised-based) in-memory implementation:
|
|
57
|
+
// chrome.storage.session = new FakeSessionApi();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
if (monkeyPatchedChromeStorage) {
|
|
63
|
+
chrome.storage.session = oldChromeStorageSession;
|
|
64
|
+
chrome.storage = oldChromeStorage;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('click tracking', () => {
|
|
69
|
+
let detectorInstance;
|
|
70
|
+
const CLICK_TIMEOUT = 20;
|
|
71
|
+
|
|
72
|
+
beforeEach(async function () {
|
|
73
|
+
detectorInstance = new OAuthDetector({ CLICK_TIMEOUT });
|
|
74
|
+
await detectorInstance.init();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
afterEach(function () {
|
|
78
|
+
detectorInstance.unload();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('registers clicks on tabs', (done) => {
|
|
82
|
+
const tab = 5;
|
|
83
|
+
const url = 'https://cliqz.com';
|
|
84
|
+
const sender = mockSender(tab, url);
|
|
85
|
+
detectorInstance.recordClick(null, '', '', sender);
|
|
86
|
+
delayedTest(
|
|
87
|
+
() => {
|
|
88
|
+
chai
|
|
89
|
+
.expect(
|
|
90
|
+
Object.fromEntries(detectorInstance.clickActivity.entries()),
|
|
91
|
+
)
|
|
92
|
+
.to.eql({
|
|
93
|
+
[tab]: url,
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
done,
|
|
97
|
+
1,
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('clicks in same tab overwrite', (done) => {
|
|
102
|
+
const tab = 5;
|
|
103
|
+
const url1 = 'https://cliqz.com';
|
|
104
|
+
const url2 = 'https://ghostery.com';
|
|
105
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab, url1));
|
|
106
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab, url2));
|
|
107
|
+
delayedTest(
|
|
108
|
+
() => {
|
|
109
|
+
chai
|
|
110
|
+
.expect(
|
|
111
|
+
Object.fromEntries(detectorInstance.clickActivity.entries()),
|
|
112
|
+
)
|
|
113
|
+
.to.eql({
|
|
114
|
+
[tab]: url2,
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
done,
|
|
118
|
+
5,
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('clicks different tabs', (done) => {
|
|
123
|
+
const tab1 = 5;
|
|
124
|
+
const tab2 = 6;
|
|
125
|
+
const url1 = 'https://cliqz.com';
|
|
126
|
+
const url2 = 'https://ghostery.com';
|
|
127
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab1, url1));
|
|
128
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab2, url2));
|
|
129
|
+
delayedTest(
|
|
130
|
+
() => {
|
|
131
|
+
chai
|
|
132
|
+
.expect(
|
|
133
|
+
Object.fromEntries(detectorInstance.clickActivity.entries()),
|
|
134
|
+
)
|
|
135
|
+
.to.eql({
|
|
136
|
+
[tab1]: url1,
|
|
137
|
+
[tab2]: url2,
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
done,
|
|
141
|
+
5,
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('clicks timeout', (done) => {
|
|
146
|
+
const tab = 5;
|
|
147
|
+
const url = 'https://cliqz.com';
|
|
148
|
+
const sender = mockSender(tab, url);
|
|
149
|
+
detectorInstance.recordClick(null, '', '', sender);
|
|
150
|
+
delayedTest(
|
|
151
|
+
() => {
|
|
152
|
+
chai
|
|
153
|
+
.expect(
|
|
154
|
+
Object.fromEntries(detectorInstance.clickActivity.entries()),
|
|
155
|
+
)
|
|
156
|
+
.to.eql({});
|
|
157
|
+
},
|
|
158
|
+
done,
|
|
159
|
+
CLICK_TIMEOUT + 5,
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('click timeout does not remove others', (done) => {
|
|
164
|
+
const tab1 = 5;
|
|
165
|
+
const tab2 = 6;
|
|
166
|
+
const url1 = 'https://cliqz.com';
|
|
167
|
+
const url2 = 'https://ghostery.com';
|
|
168
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab1, url1));
|
|
169
|
+
setTimeout(
|
|
170
|
+
() =>
|
|
171
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab2, url2)),
|
|
172
|
+
10,
|
|
173
|
+
);
|
|
174
|
+
delayedTest(
|
|
175
|
+
() => {
|
|
176
|
+
chai
|
|
177
|
+
.expect(
|
|
178
|
+
Object.fromEntries(detectorInstance.clickActivity.entries()),
|
|
179
|
+
)
|
|
180
|
+
.to.eql({
|
|
181
|
+
[tab2]: url2,
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
done,
|
|
185
|
+
CLICK_TIMEOUT + 5,
|
|
186
|
+
);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('subsequent click refreshes timeout', (done) => {
|
|
190
|
+
const tab1 = 5;
|
|
191
|
+
const tab2 = 6;
|
|
192
|
+
const url1 = 'https://cliqz.com';
|
|
193
|
+
const url2 = 'https://ghostery.com';
|
|
194
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab1, url1));
|
|
195
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab2, url2));
|
|
196
|
+
setTimeout(
|
|
197
|
+
() =>
|
|
198
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab1, url1)),
|
|
199
|
+
10,
|
|
200
|
+
);
|
|
201
|
+
delayedTest(
|
|
202
|
+
() => {
|
|
203
|
+
chai
|
|
204
|
+
.expect(
|
|
205
|
+
Object.fromEntries(detectorInstance.clickActivity.entries()),
|
|
206
|
+
)
|
|
207
|
+
.to.eql({
|
|
208
|
+
[tab1]: url1,
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
done,
|
|
212
|
+
CLICK_TIMEOUT + 5,
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe('checkIsOAuth', () => {
|
|
218
|
+
let detectorInstance;
|
|
219
|
+
|
|
220
|
+
function mockState(tabId, url, tabUrl, fullPage = false) {
|
|
221
|
+
return {
|
|
222
|
+
tabId,
|
|
223
|
+
url,
|
|
224
|
+
urlParts: parse(url),
|
|
225
|
+
tabUrlParts: parse(tabUrl),
|
|
226
|
+
isMainFrame: fullPage,
|
|
227
|
+
incrementStat: () => null,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
beforeEach(async function () {
|
|
232
|
+
detectorInstance = new OAuthDetector({
|
|
233
|
+
CLICK_TIMEOUT: 10,
|
|
234
|
+
VISIT_TIMEOUT: 8,
|
|
235
|
+
});
|
|
236
|
+
await detectorInstance.init();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
afterEach(function () {
|
|
240
|
+
detectorInstance.unload();
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('returns true when there has been no activity and the URL contains "/oauth"', () => {
|
|
244
|
+
const state = mockState(
|
|
245
|
+
5,
|
|
246
|
+
'https://auth.ghostery.com/oauth',
|
|
247
|
+
'https://cliqz.com/',
|
|
248
|
+
);
|
|
249
|
+
chai.expect(detectorInstance.checkIsOAuth(state)).to.be.true;
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('returns true when there has been no activity and the URL contains "/authorize"', () => {
|
|
253
|
+
const state = mockState(
|
|
254
|
+
5,
|
|
255
|
+
'https://auth.ghostery.com/authorize',
|
|
256
|
+
'https://cliqz.com/',
|
|
257
|
+
);
|
|
258
|
+
chai.expect(detectorInstance.checkIsOAuth(state)).to.be.true;
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('returns true when there is only a click', (done) => {
|
|
262
|
+
const tab = 5;
|
|
263
|
+
const tabUrl = 'https://cliqz.com/';
|
|
264
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab, tabUrl));
|
|
265
|
+
const state = mockState(tab, 'https://auth.ghostery.com/oauth', tabUrl);
|
|
266
|
+
delayedTest(
|
|
267
|
+
() => {
|
|
268
|
+
chai.expect(detectorInstance.checkIsOAuth(state)).to.be.true;
|
|
269
|
+
},
|
|
270
|
+
done,
|
|
271
|
+
5,
|
|
272
|
+
);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('returns false with click and page', (done) => {
|
|
276
|
+
const tab = 5;
|
|
277
|
+
const tabUrl = 'https://cliqz.com/';
|
|
278
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab, tabUrl));
|
|
279
|
+
const fullPageState = mockState(
|
|
280
|
+
tab + 1,
|
|
281
|
+
'https://auth.ghostery.com/',
|
|
282
|
+
'',
|
|
283
|
+
true,
|
|
284
|
+
);
|
|
285
|
+
const state = mockState(tab, 'https://auth.ghostery.com/oauth', tabUrl);
|
|
286
|
+
setTimeout(() => detectorInstance.checkMainFrames(fullPageState), 2);
|
|
287
|
+
delayedTest(
|
|
288
|
+
() => {
|
|
289
|
+
chai.expect(detectorInstance.checkIsOAuth(state)).to.be.false;
|
|
290
|
+
},
|
|
291
|
+
done,
|
|
292
|
+
5,
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('returns true if page domain does not match', (done) => {
|
|
297
|
+
const tab = 5;
|
|
298
|
+
const tabUrl = 'https://cliqz.com/';
|
|
299
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab, tabUrl));
|
|
300
|
+
const fullPageState = mockState(
|
|
301
|
+
tab + 1,
|
|
302
|
+
'https://www.ghostery.com/',
|
|
303
|
+
'',
|
|
304
|
+
true,
|
|
305
|
+
);
|
|
306
|
+
const state = mockState(tab, 'https://auth.ghostery.com/oauth', tabUrl);
|
|
307
|
+
setTimeout(() => detectorInstance.checkMainFrames(fullPageState), 2);
|
|
308
|
+
delayedTest(
|
|
309
|
+
() => {
|
|
310
|
+
chai.expect(detectorInstance.checkIsOAuth(state)).to.be.true;
|
|
311
|
+
},
|
|
312
|
+
done,
|
|
313
|
+
5,
|
|
314
|
+
);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('returns true if click domain does not match', (done) => {
|
|
318
|
+
const tab = 5;
|
|
319
|
+
const tabUrl = 'https://cliqz.com/';
|
|
320
|
+
const tabUrl2 = 'https://www.cliqz.com/';
|
|
321
|
+
detectorInstance.recordClick(null, '', '', mockSender(tab, tabUrl));
|
|
322
|
+
const fullPageState = mockState(
|
|
323
|
+
tab + 1,
|
|
324
|
+
'https://www.ghostery.com/',
|
|
325
|
+
'',
|
|
326
|
+
true,
|
|
327
|
+
);
|
|
328
|
+
const state = mockState(tab, 'https://auth.ghostery.com/oauth', tabUrl2);
|
|
329
|
+
setTimeout(() => detectorInstance.checkMainFrames(fullPageState), 2);
|
|
330
|
+
delayedTest(
|
|
331
|
+
() => {
|
|
332
|
+
chai.expect(detectorInstance.checkIsOAuth(state)).to.be.true;
|
|
333
|
+
},
|
|
334
|
+
done,
|
|
335
|
+
5,
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
});
|