|
163 | 163 | {"name":"browser","version":"0.1.0-alpha2","interface":{"category":"Engineering"}} |
164 | 164 | JSON |
165 | 165 | cat > "$resources_dir/plugins/openai-bundled/plugins/browser/scripts/browser-client.mjs" <<'JS' |
166 | | -function lu(e){let t=globalThis.nodeRepl?.env[e];return typeof t=="string"?t:void 0}function th(){let e=import.meta.__codexNativePipe;return e==null||typeof e.createConnection!="function"?null:e}var I2=new Set(["about:blank"]);function Gb(e){if(I2.has(e))return!0;let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}class Uf{async fetchBlocked(e){let r=await bS(e.endpoint,{method:"GET"});if(!r.ok)throw new Error(ae(`Browser Use cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await r.json();return TF(n)}}var Cb=kE(hV.platform()),EV=()=>_P()==="win32"?TV():CV(),CV=async()=>(await yP(Cb)).map(e=>wP.resolve(Cb,e)),TV=async()=>[];export function setupAtlasRuntime() {} |
| 166 | +function lu(e){let t=globalThis.nodeRepl?.env[e];return typeof t=="string"?t:void 0}function th(){let e=import.meta.__codexNativePipe;return e==null||typeof e.createConnection!="function"?null:e}var I2=new Set(["about:blank"]);function Gb(e){if(I2.has(e))return!0;let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}class Uf{async fetchBlocked(e,t){let r=await bS(e.endpoint,{method:"GET"});if(!r.ok)throw new Error(ae(`${t} cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await r.json();return TF(n)}}var Cb=kE(hV.platform()),EV=()=>_P()==="win32"?TV():CV(),CV=async()=>(await yP(Cb)).map(e=>wP.resolve(Cb,e)),TV=async()=>[];export function setupAtlasRuntime() {} |
167 | 167 | JS |
168 | 168 | } |
169 | 169 |
|
@@ -7144,6 +7144,120 @@ for (const [key, value] of Object.entries(expected)) { |
7144 | 7144 | NODE |
7145 | 7145 | } |
7146 | 7146 |
|
| 7147 | +test_browser_use_site_status_allowlist_fallback_patch_behavior() { |
| 7148 | + info "Checking Browser Use site_status allowlist fallback patch behavior" |
| 7149 | + local workspace="$TMP_DIR/browser-site-status-allowlist-fallback" |
| 7150 | + local client="$workspace/browser-client.mjs" |
| 7151 | + local first_patch="$workspace/browser-client.first-patch.mjs" |
| 7152 | + local output_log="$workspace/output.log" |
| 7153 | + |
| 7154 | + mkdir -p "$workspace" |
| 7155 | + cat > "$client" <<'JS' |
| 7156 | +var fetchImpl;function F(e,t){return fetchImpl(e,t)}function G(e){return e}function H(e){return e.blocked===!0}var policy={async fetchBlocked(e,t){let s=await F(e.endpoint,{method:"GET"});if(!s.ok)throw new Error(G(`${t} cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await s.json();return H(n)}}; |
| 7157 | +JS |
| 7158 | + |
| 7159 | + ( |
| 7160 | + warn() { echo "[WARN] $*" >&2; } |
| 7161 | + info() { echo "[INFO] $*" >&2; } |
| 7162 | + # shellcheck disable=SC1091 |
| 7163 | + source "$REPO_DIR/scripts/lib/bundled-plugins.sh" |
| 7164 | + patch_browser_use_site_status_allowlist_fallback "$client" |
| 7165 | + cp "$client" "$first_patch" |
| 7166 | + patch_browser_use_site_status_allowlist_fallback "$client" |
| 7167 | + ) >"$output_log" 2>&1 |
| 7168 | + |
| 7169 | + cmp -s "$first_patch" "$client" || fail "Expected Browser Use site_status fallback patch to be byte-identical on second application" |
| 7170 | + assert_occurrence_count "$client" "codexLinuxSiteStatusAllowlistFallback" 1 |
| 7171 | + assert_not_contains "$client" "console.warn" |
| 7172 | + assert_not_contains "$output_log" "Could not find Browser Use site_status allowlist fallback insertion point" |
| 7173 | + |
| 7174 | + node - "$client" <<'NODE' |
| 7175 | +const assert = require("node:assert/strict"); |
| 7176 | +const fs = require("node:fs"); |
| 7177 | +const vm = require("node:vm"); |
| 7178 | + |
| 7179 | +const client = process.argv[2]; |
| 7180 | +const source = fs.readFileSync(client, "utf8"); |
| 7181 | +const warnings = []; |
| 7182 | +const context = { |
| 7183 | + console: { |
| 7184 | + warn(...args) { |
| 7185 | + warnings.push(args); |
| 7186 | + }, |
| 7187 | + }, |
| 7188 | +}; |
| 7189 | +vm.createContext(context); |
| 7190 | +vm.runInContext(source, context); |
| 7191 | + |
| 7192 | +const matchingUrl = { |
| 7193 | + endpoint: "http://127.0.0.1/aura/site_status?url=https%3A%2F%2Fexample.com", |
| 7194 | + displayUrl: "https://example.com/", |
| 7195 | +}; |
| 7196 | +const otherUrl = { |
| 7197 | + endpoint: "http://127.0.0.1/aura/other", |
| 7198 | + displayUrl: "https://example.com/", |
| 7199 | +}; |
| 7200 | + |
| 7201 | +(async () => { |
| 7202 | + const allowlistError = new Error("native ALLOWLIST is unavailable"); |
| 7203 | + context.fetchImpl = async () => { |
| 7204 | + throw allowlistError; |
| 7205 | + }; |
| 7206 | + assert.strictEqual(await context.policy.fetchBlocked(matchingUrl, "Chrome"), false); |
| 7207 | + |
| 7208 | + await assert.rejects( |
| 7209 | + context.policy.fetchBlocked(otherUrl, "Chrome"), |
| 7210 | + (error) => error === allowlistError, |
| 7211 | + ); |
| 7212 | + |
| 7213 | + const otherError = new Error("native policy is unavailable"); |
| 7214 | + context.fetchImpl = async () => { |
| 7215 | + throw otherError; |
| 7216 | + }; |
| 7217 | + await assert.rejects( |
| 7218 | + context.policy.fetchBlocked(matchingUrl, "Chrome"), |
| 7219 | + (error) => error === otherError, |
| 7220 | + ); |
| 7221 | + |
| 7222 | + context.fetchImpl = async () => ({ ok: false }); |
| 7223 | + await assert.rejects( |
| 7224 | + context.policy.fetchBlocked(matchingUrl, "Chrome"), |
| 7225 | + (error) => error.message === "Chrome cannot determine if https://example.com/ is allowed. Please try again later or use another source.", |
| 7226 | + ); |
| 7227 | + |
| 7228 | + const jsonError = new Error("invalid site_status JSON"); |
| 7229 | + context.fetchImpl = async () => ({ |
| 7230 | + ok: true, |
| 7231 | + json: async () => { |
| 7232 | + throw jsonError; |
| 7233 | + }, |
| 7234 | + }); |
| 7235 | + await assert.rejects( |
| 7236 | + context.policy.fetchBlocked(matchingUrl, "Chrome"), |
| 7237 | + (error) => error === jsonError, |
| 7238 | + ); |
| 7239 | + |
| 7240 | + let fetchedEndpoint; |
| 7241 | + let fetchedMethod; |
| 7242 | + context.fetchImpl = async (endpoint, options) => { |
| 7243 | + fetchedEndpoint = endpoint; |
| 7244 | + fetchedMethod = options.method; |
| 7245 | + return { |
| 7246 | + ok: true, |
| 7247 | + json: async () => ({ blocked: true }), |
| 7248 | + }; |
| 7249 | + }; |
| 7250 | + assert.strictEqual(await context.policy.fetchBlocked(matchingUrl, "Chrome"), true); |
| 7251 | + assert.strictEqual(fetchedEndpoint, matchingUrl.endpoint); |
| 7252 | + assert.strictEqual(fetchedMethod, "GET"); |
| 7253 | + assert.strictEqual(warnings.length, 0); |
| 7254 | +})().catch((error) => { |
| 7255 | + console.error(error); |
| 7256 | + process.exitCode = 1; |
| 7257 | +}); |
| 7258 | +NODE |
| 7259 | +} |
| 7260 | + |
7147 | 7261 | test_browser_plugin_renamed_upstream_staging() { |
7148 | 7262 | info "Checking Browser plugin staging from renamed upstream resources" |
7149 | 7263 | local workspace="$TMP_DIR/browser-plugin-renamed" |
@@ -7834,7 +7948,7 @@ var Cb=kE(hV.platform()),EV=()=>_P()==="win32"?TV():CV(),CV=async()=>(await yP(C |
7834 | 7948 | function lu(e){let t=globalThis.nodeRepl?.env[e];return typeof t=="string"?t:void 0} |
7835 | 7949 | function Me(){let e=globalThis.nodeRepl;return e?.config==null?void 0:e} |
7836 | 7950 | import{platform as yT}from"node:os";function eh(){return"privileged native pipe bridge is not available; browser-client is not trusted"}function th(){let e=globalThis.nodeRepl?.nativePipe;return e==null||typeof e.createConnection!="function"?null:e}var ml=class e{constructor(t){this.socket=t}static async create(t){let r=th();if(r!=null){let n=await r.createConnection(t);return new e(n)}throw new Error(eh())}}; |
7837 | | -async fetchBlocked(e){let r=await bS(e.endpoint,{method:"GET"});if(!r.ok)throw new Error(ae(`Browser Use cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await r.json();return TF(n)} |
| 7951 | +async fetchBlocked(e,t){let r=await bS(e.endpoint,{method:"GET"});if(!r.ok)throw new Error(ae(`${t} cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await r.json();return TF(n)} |
7838 | 7952 | JS |
7839 | 7953 | cat > "$chrome_dir/scripts/check-native-host-manifest.js" <<'JS' |
7840 | 7954 | #!/usr/bin/env node |
@@ -10254,6 +10368,7 @@ main() { |
10254 | 10368 | test_bundled_plugin_system_computer_use_preserves_cosmic_helper_name |
10255 | 10369 | test_browser_use_node_repl_fallback_runtime |
10256 | 10370 | test_browser_use_file_url_policy_patch_behavior |
| 10371 | + test_browser_use_site_status_allowlist_fallback_patch_behavior |
10257 | 10372 | test_browser_plugin_renamed_upstream_staging |
10258 | 10373 | test_upstream_bundled_skills_staging |
10259 | 10374 | test_upstream_bundled_skills_validator_guards |
|
0 commit comments