Skip to content

Commit

Permalink
AG-23697 'log-addEventListener' prints a lot of errors to console. #335
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit a8d88dd
Author: Adam Wróblewski <adam@adguard.com>
Date:   Thu Jun 29 15:04:02 2023 +0200

    Fix log-addEventListener
    do not print unnecessary logs to the console
  • Loading branch information
AdamWr committed Jul 6, 2023
1 parent 2b35bd5 commit 7386438
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- issue with printing unnecessary logs to the console in `log-addEventListener` scriptlet
[#335](https://github.com/AdguardTeam/Scriptlets/issues/335)
- error throwing in `prevent-fetch` and `prevent-xhr` scriptlets when a request is blocked
[#334](https://github.com/AdguardTeam/Scriptlets/issues/334)

Expand Down
12 changes: 6 additions & 6 deletions src/scriptlets/log-addEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ export function logAddEventListener(source) {
const message = `addEventListener("${type}", ${listenerToString(listener)})`;
logMessage(source, message, true);
hit(source);
} else {
// logging while debugging
const message = `Invalid event type or listener passed to addEventListener:
type: ${convertTypeToString(type)}
listener: ${convertTypeToString(listener)}`;
logMessage(source, message, true);
}

// logging while debugging
const message = `Invalid event type or listener passed to addEventListener:
type: ${convertTypeToString(type)}
listener: ${convertTypeToString(listener)}`;
logMessage(source, message, true);

// Avoid illegal invocations due to lost context
// https://github.com/AdguardTeam/Scriptlets/issues/271
let context = this;
Expand Down
1 change: 1 addition & 0 deletions tests/scriptlets/log-addEventListener.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ test('logs events to console', (assert) => {
}
assert.ok(input.includes(eventName), 'console.hit input should be equal');
assert.ok(input.includes(callback.toString()), 'console.hit input should be equal');
assert.notOk(input.includes(INVALID_MESSAGE_START), 'Invalid message should not be displayed');
};

runScriptlet(name);
Expand Down

0 comments on commit 7386438

Please sign in to comment.