1+ import { STACK_WITH_INIT_IN_EXTENSION , STACK_WITH_INIT_IN_PAGE } from '../../test'
12import { display } from '../tools/display'
23import {
34 isAllowedTrackingOrigins ,
@@ -21,7 +22,7 @@ describe('checkForAllowedTrackingOrigins', () => {
2122 } )
2223
2324 it ( 'should not warn if not in extension environment' , ( ) => {
24- const result = isAllowedTrackingOrigins ( DEFAULT_CONFIG , 'https://app.example.com' )
25+ const result = isAllowedTrackingOrigins ( DEFAULT_CONFIG , STACK_WITH_INIT_IN_PAGE , 'https://app.example.com' )
2526 expect ( displayWarnSpy ) . not . toHaveBeenCalled ( )
2627 expect ( displayErrorSpy ) . not . toHaveBeenCalled ( )
2728 expect ( result ) . toBe ( true )
@@ -34,6 +35,7 @@ describe('checkForAllowedTrackingOrigins', () => {
3435 ...DEFAULT_CONFIG ,
3536 allowedTrackingOrigins : [ 'https://app.example.com' ] ,
3637 } ,
38+ STACK_WITH_INIT_IN_PAGE ,
3739 'https://app.example.com'
3840 )
3941 expect ( displayWarnSpy ) . not . toHaveBeenCalled ( )
@@ -47,6 +49,7 @@ describe('checkForAllowedTrackingOrigins', () => {
4749 ...DEFAULT_CONFIG ,
4850 allowedTrackingOrigins : [ / ^ h t t p s : \/ \/ .* \. e x a m p l e \. c o m $ / ] ,
4951 } ,
52+ STACK_WITH_INIT_IN_PAGE ,
5053 'https://app.example.com'
5154 )
5255 expect ( displayWarnSpy ) . not . toHaveBeenCalled ( )
@@ -60,6 +63,7 @@ describe('checkForAllowedTrackingOrigins', () => {
6063 ...DEFAULT_CONFIG ,
6164 allowedTrackingOrigins : [ ( origin : string ) => origin . includes ( 'example.com' ) ] ,
6265 } ,
66+ STACK_WITH_INIT_IN_PAGE ,
6367 'https://app.example.com'
6468 )
6569 expect ( displayWarnSpy ) . not . toHaveBeenCalled ( )
@@ -77,6 +81,7 @@ describe('checkForAllowedTrackingOrigins', () => {
7781 ( origin : string ) => origin . startsWith ( 'https://app.' ) ,
7882 ] ,
7983 } ,
84+ STACK_WITH_INIT_IN_PAGE ,
8085 'https://app.example.com'
8186 )
8287 expect ( displayWarnSpy ) . not . toHaveBeenCalled ( )
@@ -92,8 +97,8 @@ describe('checkForAllowedTrackingOrigins', () => {
9297 ...DEFAULT_CONFIG ,
9398 allowedTrackingOrigins : [ 'https://different.com' ] ,
9499 } ,
95- 'https://example.com' ,
96- 'Error: at chrome-extension://abcdefghijklmno/content.js:10:15 '
100+ STACK_WITH_INIT_IN_EXTENSION ,
101+ 'https://example.com '
97102 )
98103 expect ( displayErrorSpy ) . toHaveBeenCalledWith ( ERROR_NOT_ALLOWED_TRACKING_ORIGIN )
99104 expect ( result ) . toBe ( false )
@@ -105,8 +110,8 @@ describe('checkForAllowedTrackingOrigins', () => {
105110 ...DEFAULT_CONFIG ,
106111 allowedTrackingOrigins : [ / ^ h t t p s : \/ \/ s p e c i f i c - [ a - z ] + \. c o m $ / ] ,
107112 } ,
108- 'https://example.com' ,
109- 'Error: at chrome-extension://abcdefghijklmno/content.js:10:15 '
113+ STACK_WITH_INIT_IN_EXTENSION ,
114+ 'https://example.com '
110115 )
111116 expect ( displayErrorSpy ) . toHaveBeenCalledWith ( ERROR_NOT_ALLOWED_TRACKING_ORIGIN )
112117 expect ( result ) . toBe ( false )
@@ -118,8 +123,8 @@ describe('checkForAllowedTrackingOrigins', () => {
118123 ...DEFAULT_CONFIG ,
119124 allowedTrackingOrigins : [ ( origin : string ) => origin . includes ( 'specific-id' ) ] ,
120125 } ,
121- 'https://example.com' ,
122- 'Error: at chrome-extension://abcdefghijklmno/content.js:10:15 '
126+ STACK_WITH_INIT_IN_EXTENSION ,
127+ 'https://example.com '
123128 )
124129 expect ( displayErrorSpy ) . toHaveBeenCalledWith ( ERROR_NOT_ALLOWED_TRACKING_ORIGIN )
125130 expect ( result ) . toBe ( false )
@@ -135,8 +140,8 @@ describe('checkForAllowedTrackingOrigins', () => {
135140 ( origin : string ) => origin . includes ( 'specific-id' ) ,
136141 ] ,
137142 } ,
138- 'https://example.com' ,
139- 'Error: at chrome-extension://abcdefghijklmno/content.js:10:15 '
143+ STACK_WITH_INIT_IN_EXTENSION ,
144+ 'https://example.com '
140145 )
141146 expect ( displayErrorSpy ) . toHaveBeenCalledWith ( ERROR_NOT_ALLOWED_TRACKING_ORIGIN )
142147 expect ( result ) . toBe ( false )
@@ -148,8 +153,8 @@ describe('checkForAllowedTrackingOrigins', () => {
148153 ...DEFAULT_CONFIG ,
149154 allowedTrackingOrigins : [ 'https://example.com' ] ,
150155 } ,
151- 'https://example.com.extra.com' ,
152- 'Error: at chrome-extension://abcdefghijklmno/content.js:10:15 '
156+ STACK_WITH_INIT_IN_EXTENSION ,
157+ 'https://example.com.extra.com '
153158 )
154159 expect ( displayErrorSpy ) . toHaveBeenCalledWith ( ERROR_NOT_ALLOWED_TRACKING_ORIGIN )
155160 expect ( result ) . toBe ( false )
@@ -161,8 +166,8 @@ describe('checkForAllowedTrackingOrigins', () => {
161166 ...DEFAULT_CONFIG ,
162167 allowedTrackingOrigins : [ / ^ c h r o m e - e x t e n s i o n : \/ \/ / ] ,
163168 } ,
164- 'chrome-extension://abcdefghijklmno' ,
165- 'Error: at chrome-extension://abcdefghijklmno/content.js:10:15 '
169+ STACK_WITH_INIT_IN_EXTENSION ,
170+ 'chrome-extension://abcdefghijklmno'
166171 )
167172 expect ( displayErrorSpy ) . not . toHaveBeenCalled ( )
168173 expect ( result ) . toBe ( true )
@@ -176,8 +181,8 @@ describe('checkForAllowedTrackingOrigins', () => {
176181 ...DEFAULT_CONFIG ,
177182 allowedTrackingOrigins : undefined ,
178183 } ,
179- 'https://example.com' ,
180- 'Error: at chrome-extension://abcdefghijklmno/content.js:10:15 '
184+ STACK_WITH_INIT_IN_EXTENSION ,
185+ 'https://example.com '
181186 )
182187 expect ( displayWarnSpy ) . toHaveBeenCalledWith ( WARN_DOES_NOT_HAVE_ALLOWED_TRACKING_ORIGIN )
183188 expect ( result ) . toBe ( true )
@@ -189,8 +194,8 @@ describe('checkForAllowedTrackingOrigins', () => {
189194 ...DEFAULT_CONFIG ,
190195 allowedTrackingOrigins : [ ] ,
191196 } ,
192- 'https://example.com' ,
193- 'Error: at chrome-extension://abcdefghijklmno/content.js:10:15 '
197+ STACK_WITH_INIT_IN_EXTENSION ,
198+ 'https://example.com '
194199 )
195200 expect ( displayErrorSpy ) . toHaveBeenCalledWith ( ERROR_NOT_ALLOWED_TRACKING_ORIGIN )
196201 expect ( result ) . toBe ( false )
@@ -202,8 +207,8 @@ describe('checkForAllowedTrackingOrigins', () => {
202207 ...DEFAULT_CONFIG ,
203208 allowedTrackingOrigins : undefined ,
204209 } ,
205- 'https://example.com' ,
206- 'Error: at https://example.com/script.js:10:15 '
210+ STACK_WITH_INIT_IN_PAGE ,
211+ 'https://example.com'
207212 )
208213 expect ( displayWarnSpy ) . not . toHaveBeenCalled ( )
209214 expect ( displayErrorSpy ) . not . toHaveBeenCalled ( )
0 commit comments