fix(stealth): avoid matchMedia Illegal invocation
- bind MediaQueryList methods when proxied for prefers-color-scheme light patch - add regression test for addEventListener/removeEventListener - bump version to 0.14.0-fork.6 and sync Cargo metadata
This commit is contained in:
Generated
+1
-1
@@ -4,7 +4,7 @@ version = 4
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "agent-browser-stealth"
|
name = "agent-browser-stealth"
|
||||||
version = "0.14.0-fork.5"
|
version = "0.14.0-fork.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "agent-browser-stealth"
|
name = "agent-browser-stealth"
|
||||||
version = "0.14.0-fork.5"
|
version = "0.14.0-fork.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Stealth browser automation CLI for AI agents with anti-bot evasions"
|
description = "Stealth browser automation CLI for AI agents with anti-bot evasions"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "agent-browser-stealth",
|
"name": "agent-browser-stealth",
|
||||||
"version": "0.14.0-fork.5",
|
"version": "0.14.0-fork.6",
|
||||||
"description": "Stealth browser automation CLI for AI agents with anti-bot evasions",
|
"description": "Stealth browser automation CLI for AI agents with anti-bot evasions",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/daemon.js",
|
"main": "dist/daemon.js",
|
||||||
|
|||||||
@@ -127,12 +127,24 @@ describe('Stealth mode', () => {
|
|||||||
activeTextColor,
|
activeTextColor,
|
||||||
prefersLight: matchMedia('(prefers-color-scheme: light)').matches,
|
prefersLight: matchMedia('(prefers-color-scheme: light)').matches,
|
||||||
prefersDark: matchMedia('(prefers-color-scheme: dark)').matches,
|
prefersDark: matchMedia('(prefers-color-scheme: dark)').matches,
|
||||||
|
lightListenerCalls: (() => {
|
||||||
|
try {
|
||||||
|
const mql = matchMedia('(prefers-color-scheme: light)');
|
||||||
|
const handler = () => {};
|
||||||
|
mql.addEventListener('change', handler);
|
||||||
|
mql.removeEventListener('change', handler);
|
||||||
|
return 'ok';
|
||||||
|
} catch (error) {
|
||||||
|
return String(error);
|
||||||
|
}
|
||||||
|
})(),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(signals.activeTextColor).not.toBe('rgb(255, 0, 0)');
|
expect(signals.activeTextColor).not.toBe('rgb(255, 0, 0)');
|
||||||
expect(signals.prefersLight).toBe(false);
|
expect(signals.prefersLight).toBe(false);
|
||||||
expect(typeof signals.prefersDark).toBe('boolean');
|
expect(typeof signals.prefersDark).toBe('boolean');
|
||||||
|
expect(signals.lightListenerCalls).toBe('ok');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('exposes realistic mimeTypes/pdf/share signals', async () => {
|
it('exposes realistic mimeTypes/pdf/share signals', async () => {
|
||||||
|
|||||||
+6
-2
@@ -856,9 +856,13 @@ function patchPrefersColorSchemeHeuristic(): string {
|
|||||||
const patchMediaQueryList = (mql) => {
|
const patchMediaQueryList = (mql) => {
|
||||||
if (!mql || typeof mql !== 'object') return mql;
|
if (!mql || typeof mql !== 'object') return mql;
|
||||||
return new Proxy(mql, {
|
return new Proxy(mql, {
|
||||||
get(target, prop, receiver) {
|
get(target, prop) {
|
||||||
if (prop === 'matches') return false;
|
if (prop === 'matches') return false;
|
||||||
return Reflect.get(target, prop, receiver);
|
const value = Reflect.get(target, prop, target);
|
||||||
|
if (typeof value === 'function') {
|
||||||
|
return value.bind(target);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user