Skip to content

Commit a04d882

Browse files
authored
Fix syntax error in the autoconsent binding (#150)
1 parent b7c35b4 commit a04d882

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

collectors/CookiePopupsCollector.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class CookiePopupsCollector extends ContentScriptCollector {
8787
* @param {import('devtools-protocol/types/protocol').Protocol.Runtime.ExecutionContextDescription} context
8888
*/
8989
async onIsolatedWorldCreated(session, context) {
90-
const bindingName = `${BINDING_NAME_PREFIX}${context.uniqueId}`;
90+
const bindingName = `${BINDING_NAME_PREFIX}${context.uniqueId.replace(/\W/g, '_')}`;
9191
session.on('Runtime.bindingCalled', async ({name, payload}) => {
9292
if (name === bindingName) {
9393
try {
@@ -111,10 +111,13 @@ class CookiePopupsCollector extends ContentScriptCollector {
111111
}
112112
}
113113
try {
114-
await session.send('Runtime.evaluate', {
114+
const evalResult = await session.send('Runtime.evaluate', {
115115
expression: getAutoconsentContentScript(bindingName),
116116
uniqueContextId: context.uniqueId,
117117
});
118+
if (evalResult.exceptionDetails) {
119+
throw new Error(`Content script injection failed: ${evalResult.exceptionDetails.text}`);
120+
}
118121
} catch (e) {
119122
if (!this.isIgnoredCdpError(e)) {
120123
this.log(`Error injecting Autoconsent in ${context.uniqueId}: ${e}`);

0 commit comments

Comments
 (0)