Gemini JavaScript Test
This is a test page to see if Gemini using URL context uses a user agent that executes JavaScript.
It does this by including a JavaScript script which replaces the text in the next paragraph. If Gemini URL grounding does execute Javascript, then the text will be different to if it doesn’t. You can see the different by viewing this page in a graphical browser and by using a text based browser such as lynx. The script is inline (so the user-agent doesn’t have to support fetching resources) and the replacement text is encrypted so the user-agent can’t infer the answer. It has to be encrypted and not just base64 encoded because LLMs can decode/encode base64.
The call I’ll use to test this with Gemini is:
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"parts": [
{"text": "What kind of fruit is Jonathan according to https://jbarber.github.io/posts/gemini-js-test/"}
]
}
],
"tools": [
{
"url_context": {}
}
]
}'
Results
The API call indicates that the JavaScript didn’t run.