Skip to content

Commit

Permalink
release v1.6. AG-11978
Browse files Browse the repository at this point in the history
* commit 'c06a8e539488e1ebfcf72c85a39a0ef5b9c028bb': (32 commits)
  AG-13382 update docs, validate noopjson
  push updated dist to github while release build. AG-13356
  remove tagcommander redirect AG-11959
  add readme info about testing ad debugging AG-12716
  add artifacts to scriptlets builds AG-12487
  improve set-constant scriptlet #65 AG-149
  improve prevent-xhr scriptlet #199 AG-13007
  improve googletagservices-gpt redirect #193 AG-12767
  add wcslog redirect #94 AG-3906
  improve ati-smarttag redirect #200 AG-13141
  improve json-prune scriptlet #171 AG-11879
  fix yandex metrika on avito #198 AG-12973
  improve metrika-yandex-tag redirect #189 AG-12550
  add prebid-ads redirect #190 AG-12558
  remove no-floc scriptlet AG-12869
  add noopjson redirect. AG-12796 #195
  Revert "revert tests and fix converter again"
  revert tests and fix converter again
  add conversion test for wildcard tld AG-12636
  add prevent-element-src-loading scriptlet #180 AG-12328
  ...
  • Loading branch information
slavaleleka committed Mar 24, 2022
2 parents e44fe5a + c06a8e5 commit 0921ef0
Show file tree
Hide file tree
Showing 56 changed files with 2,303 additions and 332 deletions.
91 changes: 69 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ AdGuard's Scriptlets and Redirect resources library which provides extended capa
* [Available redirect resources](https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-redirects.md#redirect-resources)
* [Redirect resources compatibility table](https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/compatibility-table.md#redirects)
* [How to build](#how-to-build)
* [How to test](#how-to-test)
* [Browser compatibility](#browser-compatibility)

* * *
Expand Down Expand Up @@ -99,25 +100,6 @@ Build dev (rebuild js files on every change)
yarn watch
```

Run node testing
```
yarn test
```

Run tests gui
```
yarn gui-test
```


To run browserstack tests create `.env` file or rename `.env-example`.

Fill in <username> and <key> with data from your Browserstack profile.
Run next command
```
yarn browserstack
```

### Build output

#### Scriptlets library
Expand Down Expand Up @@ -392,7 +374,72 @@ const redirect = redirect.getRedirect('noopjs');
*/
```

## <a id="how-to-test"></a> How to test

Run node testing
```
yarn test
```

Run tests gui
```
yarn gui-test
```

Watcher is available
```
yarn test-watch
```

Limit testing by commenting out corresponding values in `rollup.config.js`
```
const MULTIPLE_TEST_FILES_DIRS = [
// 'scriptlets',
// 'redirects',
];
const ONE_TEST_FILE_DIRS = [
'lib-tests',
// 'helpers',
];
```

or `index.test.js`
```
// import './scriptlets/index.test';
import './redirects/index.test';
// import './lib-tests/index.test';
// import './helpers/index.test';
```

> It is also possible to exclude libtests in `tests/lib-tests/index.test.js`
Run specific scriptlet or redirect test by editing `rollup.config.js`
```
.filter((el) => {
return el !== 'index.test.js'
// Uncomment next line and use required scriptlet/redirect name
// && el === 'gemius.test.js'
&& el.includes(TEST_FILE_NAME_MARKER);
});
```

To run browserstack tests create `.env` file or copy and rename `.env-example`.

Fill in <username> and <key> with data from your Browserstack profile.
Run next command
```
yarn browserstack
```

### Debugging

Use `debugger;` statement where you need it, run
```
yarn test
```
and open needed HTML file from `tests/dist` in your browser with devtools

## <a id="browser-compatibility"> Browser Compatibility
| Chrome | Edge | Firefox | IE | Opera | Safari |
|--|--|--|--|--|--|
| 55 | 15 | 52 | 11 | 42 | 10 |
| Chrome | Edge | Firefox | IE | Opera | Safari |
| ------ | ---- | ------- | --- | ----- | ------ |
| 55 | 15 | 52 | 11 | 42 | 10 |
5 changes: 5 additions & 0 deletions bamboo-specs/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Build:
rm -rf node_modules
environment: BROWSERSTACK_USER="${bamboo.browserstackUser}" \
BROWSERSTACK_KEY="${bamboo.browserstackPassword}"
- any-task:
plugin-key: com.atlassian.bamboo.plugins.vcs:task.vcs.commit
configuration:
commitMessage: 'skipci: Automatic dist update'
selectedRepository: defaultRepository
- inject-variables:
file: dist/build.txt
scope: RESULT
Expand Down
13 changes: 10 additions & 3 deletions bamboo-specs/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ Build:
yarn install
yarn test
yarn build
yarn prepare-builds
rm -rf node_modules
final-tasks:
- clean
artifacts:
- name: scriptlets.corelibs.json
location: dist
pattern: scriptlets.corelibs.json
required: true
- name: redirects.json
location: dist
pattern: redirects.json
required: true
requirements:
- adg-docker: 'true'

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adguard/scriptlets",
"version": "1.5.25",
"version": "1.6.0",
"description": "AdGuard's JavaScript library of Scriptlets and Redirect resources",
"scripts": {
"watch": "rollup -c -w",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && echo \"DO NOT FORGET ABOUT BUILDS UPDATE (yarn prepare-builds)\""
"pre-commit": "lint-staged"
}
},
"author": "AdGuard",
Expand Down
19 changes: 16 additions & 3 deletions scripts/compatibility-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@
"adg": "log-on-stack-trace"
},
{
"adg": "no-floc",
"ubo": "no-floc.js"
"adg": "naver-wcslog"
},
{
"adg": "noeval"
Expand Down Expand Up @@ -234,6 +233,9 @@
},
{
"ubo": "refresh-defuser.js"
},
{
"ubo": "no-floc.js"
}
],
"redirects": [
Expand Down Expand Up @@ -269,9 +271,13 @@
"ubo": "click2load.html"
},
{
"adg": "fingerprintjs",
"adg": "fingerprintjs2",
"ubo": "fingerprint2.js"
},
{
"adg": "fingerprint3js",
"ubo": "fingerprint3.js"
},
{
"adg": "google-analytics",
"ubo": "google-analytics_analytics.js"
Expand Down Expand Up @@ -318,6 +324,9 @@
"ubo": "noop.js",
"abp": "blank-js"
},
{
"adg": "noopjson"
},
{
"adg": "nooptext",
"ubo": "noop.txt",
Expand All @@ -343,6 +352,10 @@
{
"adg": "noopvast-3.0"
},
{
"adg": "prebid-ads",
"ubo": "prebid-ads.js"
},
{
"adg": "prevent-bab",
"ubo": "nobab.js"
Expand Down
27 changes: 25 additions & 2 deletions src/helpers/compatibility-redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@ const redirects = [
{
adg: 'ati-smarttag',
},
{
adg: 'didomi-loader',
},
{
adg: 'click2load.html',
ubo: 'click2load.html',
},
{
adg: 'fingerprintjs',
ubo: 'fingerprintjs2.js',
adg: 'fingerprintjs2',
ubo: 'fingerprint2.js',
},
{
adg: 'fingerprintjs3',
ubo: 'fingerprint3.js',
},
{
adg: 'google-analytics',
Expand Down Expand Up @@ -68,6 +75,9 @@ const redirects = [
adg: 'googletagservices-gpt',
ubo: 'googletagservices_gpt.js',
},
{
adg: 'google-ima3',
},
{
adg: 'gemius',
},
Expand All @@ -80,6 +90,9 @@ const redirects = [
{
adg: 'metrika-yandex-tag',
},
{
adg: 'naver-wcslog',
},
{
adg: 'noeval',
ubo: 'noeval-silent.js',
Expand All @@ -98,6 +111,9 @@ const redirects = [
ubo: 'noop.js',
abp: 'blank-js',
},
{
adg: 'noopjson',
},
{
adg: 'nooptext',
ubo: 'noop.txt',
Expand All @@ -123,6 +139,9 @@ const redirects = [
{
adg: 'noopvast-3.0',
},
{
adg: 'prebid',
},
{
adg: 'prevent-bab',
ubo: 'nobab.js',
Expand Down Expand Up @@ -151,6 +170,10 @@ const redirects = [
adg: 'empty',
ubo: 'empty',
},
{
adg: 'prebid-ads',
ubo: 'prebid-ads.js',
},
];

export default redirects;
13 changes: 13 additions & 0 deletions src/helpers/number-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ export const nativeIsFinite = (num) => {
const native = Number.isFinite || window.isFinite; // eslint-disable-line compat/compat
return native(num);
};

/**
* Parses string for a number, if possible, otherwise returns null.
* @param {*} rawDelay
* @returns {number|null}
*/
export const getNumberFromString = (rawString) => {
const parsedDelay = parseInt(rawString, 10);
const validDelay = nativeIsNaN(parsedDelay)
? null
: parsedDelay;
return validDelay;
};
14 changes: 14 additions & 0 deletions src/helpers/object-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,17 @@ export const getObjectFromEntries = (entries) => {
* @returns {boolean}
*/
export const isEmptyObject = (obj) => Object.keys(obj).length === 0;

/**
* Checks whether the obj is an empty object
* @param {Object} obj
* @param {string} prop
* @returns {Object|null}
*/
export const safeGetDescriptor = (obj, prop) => {
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
if (descriptor && descriptor.configurable) {
return descriptor;
}
return null;
};
5 changes: 4 additions & 1 deletion src/redirects/ati-smarttag.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export function ATInternetSmartTag(source) {

click: sendNoopFuncWrapper,
clickListener: sendNoopFuncWrapper,
internalSearch: sendNoopFuncWrapper,
internalSearch: {
set: noopFunc,
send: noopFunc,
},

ecommerce: ecommerceWrapper,

Expand Down
Loading

0 comments on commit 0921ef0

Please sign in to comment.