@@ -49,14 +49,50 @@ var forbiddenTerms = {
4949 ]
5050 } ,
5151 // Service factories that should only be installed once.
52+ 'installActionService' : {
53+ message : privateServiceFactory ,
54+ whitelist : [
55+ 'src/service/action-impl.js' ,
56+ 'src/amp-core-service.js' ,
57+ ] ,
58+ } ,
59+ 'installActionHandler' : {
60+ message : privateServiceFactory ,
61+ whitelist : [
62+ 'src/service/action-impl.js' ,
63+ 'extensions/amp-access/0.1/amp-access.js' ,
64+ ] ,
65+ } ,
5266 'installCidService' : {
5367 message : privateServiceFactory ,
5468 whitelist : [
5569 'src/service/cid-impl.js' ,
5670 'extensions/amp-analytics/0.1/amp-analytics.js' ,
57- 'extensions/amp-analytics/0.1/test/test-amp-analytics.js' ,
58- 'test/functional/test-cid.js' ,
59- 'test/functional/test-url-replacements.js'
71+ ] ,
72+ } ,
73+ 'installViewerService' : {
74+ message : privateServiceFactory ,
75+ whitelist : [
76+ 'src/amp-core-service.js' ,
77+ 'src/service/history-impl.js' ,
78+ 'src/service/viewer-impl.js' ,
79+ 'src/service/viewport-impl.js' ,
80+ 'src/service/vsync-impl.js' ,
81+ ] ,
82+ } ,
83+ 'installViewportService' : {
84+ message : privateServiceFactory ,
85+ whitelist : [
86+ 'src/amp-core-service.js' ,
87+ 'src/service/viewport-impl.js' ,
88+ ] ,
89+ } ,
90+ 'installVsyncService' : {
91+ message : privateServiceFactory ,
92+ whitelist : [
93+ 'src/amp-core-service.js' ,
94+ 'src/service/viewport-impl.js' ,
95+ 'src/service/vsync-impl.js' ,
6096 ] ,
6197 } ,
6298 // Privacy sensitive
@@ -66,25 +102,21 @@ var forbiddenTerms = {
66102 'src/cid.js' ,
67103 'src/service/cid-impl.js' ,
68104 'src/url-replacements.js' ,
69- 'test/functional/test-cid .js' ,
105+ 'extensions/amp-user-notification/0.1/amp-user-notification .js' ,
70106 ] ,
71107 } ,
72108 'getBaseCid' : {
73109 message : requiresReviewPrivacy ,
74110 whitelist : [
75111 'src/service/cid-impl.js' ,
76- 'src/viewer.js' ,
77- 'test/functional/test-cid.js' ,
112+ 'src/service/viewer-impl.js' ,
78113 ] ,
79114 } ,
80115 'cookie\\W' : {
81116 message : requiresReviewPrivacy ,
82117 whitelist : [
83118 'src/cookies.js' ,
84119 'src/service/cid-impl.js' ,
85- 'test/functional/test-cid.js' ,
86- 'test/functional/test-cookies.js' ,
87- 'test/functional/test-experiments.js' ,
88120 ] ,
89121 } ,
90122 'getCookie\\W' : {
@@ -93,7 +125,6 @@ var forbiddenTerms = {
93125 'src/service/cid-impl.js' ,
94126 'src/cookies.js' ,
95127 'src/experiments.js' ,
96- 'test/functional/test-cookies.js' ,
97128 'tools/experiments/experiments.js' ,
98129 ]
99130 } ,
@@ -102,19 +133,14 @@ var forbiddenTerms = {
102133 whitelist : [
103134 'src/cookies.js' ,
104135 'src/experiments.js' ,
105- 'test/functional/test-cookies.js' ,
106- 'test/functional/test-url-replacements.js' ,
107136 'tools/experiments/experiments.js' ,
108137 ]
109138 } ,
110139 'eval\\(' : '' ,
111140 'localStorage' : {
112141 message : requiresReviewPrivacy ,
113142 whitelist : [
114- 'extensions/amp-analytics/0.1/test/test-amp-analytics.js' ,
115- 'test/_init_tests.js' ,
116143 'src/service/cid-impl.js' ,
117- 'test/functional/test-cid.js' ,
118144 ] ,
119145 } ,
120146 'sessionStorage' : requiresReviewPrivacy ,
@@ -227,6 +253,18 @@ var requiredTerms = {
227253 dedicatedCopyrightNoteSources ,
228254} ;
229255
256+
257+ /**
258+ * Check if root of path is test/ or file is in a folder named test.
259+ * @param {string } path
260+ * @return {boolean }
261+ */
262+ function isInTestFolder ( path ) {
263+ var dirs = path . split ( '/' ) ;
264+ var folder = dirs [ dirs . length - 2 ] ;
265+ return path . startsWith ( 'test/' ) || folder == 'test' ;
266+ }
267+
230268/**
231269 * Logs any issues found in the contents of file based on terms (regex
232270 * patterns), and provides any possible fix information for matched terms if
@@ -247,7 +285,8 @@ function matchTerms(file, terms) {
247285 var whitelist = terms [ term ] . whitelist ;
248286 // NOTE: we could do a glob test instead of exact check in the future
249287 // if needed but that might be too permissive.
250- if ( Array . isArray ( whitelist ) && whitelist . indexOf ( relative ) != - 1 ) {
288+ if ( Array . isArray ( whitelist ) && ( whitelist . indexOf ( relative ) != - 1 ||
289+ isInTestFolder ( relative ) ) ) {
251290 return false ;
252291 }
253292 // we can't optimize building the `RegExp` objects early unless we build
0 commit comments