Content scripts don't work on file:// scheme

427 views
Skip to first unread message

Nikita Vasilyev

unread,
Apr 8, 2010, 10:29:58 AM4/8/10
to Chromium-extensions
But they did work!
http://code.google.com/chrome/extensions/dev/match_patterns.html

manifest.json:
{
"name": "XRefresh",
"version": "0.1",
"content_scripts": [
{
"matches": ["http://*/*", "file://*/*"],
"js": ["xrefresh.js"]
}
]
}

xrefresh.js:
console.log("Yay!");


I see nothing on file://localhost/Users/.../index.html, but on this
page I see "Yay!" in the console as expected.

Google Chrome 5.0.366.0 dev, Mac OS X.

krtulmay

unread,
Apr 8, 2010, 12:00:26 PM4/8/10
to Chromium-extensions
I could be wrong, but it looks like according to the API file: scheme
should have three slashes following the colon?

So may file:///* or file:///*/*

On Apr 8, 10:29 am, Nikita Vasilyev <alter.el...@gmail.com> wrote:
> But they did work!http://code.google.com/chrome/extensions/dev/match_patterns.html

Nikita Vasilyev

unread,
Apr 8, 2010, 3:50:58 PM4/8/10
to Chromium-extensions
I've found the problem. "file://*/*" pattern is okay, the problem with
the link.

file://localhost/Users/.../index.html doesn't work, but
file:///Users/.../index.html do work!

I consider it as a bug, and very annoying one, because by default
local html files opens on file://localhost/ , not file:///

Arne Roomann-Kurrik

unread,
Apr 8, 2010, 4:14:31 PM4/8/10
to Nikita Vasilyev, Chromium-extensions
Which version of chrome do you use?  When I open a local file in the Linux dev channel, it loads via file:///<path>

~Arne

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


Nikita Vasilyev

unread,
Apr 8, 2010, 4:22:13 PM4/8/10
to Chromium-extensions
Google Chrome 5.0.366.0 dev, Mac OS X

On Apr 9, 12:14 am, Arne Roomann-Kurrik <kur...@chromium.org> wrote:
> Which version of chrome do you use?  When I open a local file in the Linux
> dev channel, it loads via file:///<path>
>
> ~Arne
>
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > .

Arne Roomann-Kurrik

unread,
Apr 8, 2010, 4:27:59 PM4/8/10
to Nikita Vasilyev, Chromium-extensions
Just tested on my mac with the dev channel - it also loads local files using file:///<path> - how are you getting the file://localhost/<path> URL?

~Arne

Nikita Vasilyev

unread,
Apr 8, 2010, 4:32:59 PM4/8/10
to Chromium-extensions
Important addition. If I double-click on some_file.html it loads via
file:///<path>, but if I drag-and-drop some_file.html into Chrome
window it loads via file://localhost/<path>. Bizarre!

Arne Roomann-Kurrik

unread,
Apr 8, 2010, 5:04:15 PM4/8/10
to Nikita Vasilyev, Chromium-extensions
There we go, now I'm able to reproduce :)  This looks like a bug, although I'm not sure whether extensions should support this scheme, or mac should just use file:/// for dropped files.

http://crbug.com/40846 if you want to star it for updates.

~Arne
Reply all
Reply to author
Forward
0 new messages