Open tab with file:// prefix

Avi Steiner asteiner at varonis.com
Tue Oct 24 09:09:15 UTC 2017


Thanks for your reply,
I’ve tried this tutorial as I wrote.
I’m using browser.tabs.create() in the same way, but it works only for http:/https: URLs but no file: URLs

From: Hello / Sector One [mailto:hellosct1 at gmail.com]
Sent: Monday, October 23, 2017 7:48 PM
To: Avi Steiner <asteiner at varonis.com>
Cc: dev-addons at mozilla.org
Subject: Re: Open tab with file:// prefix

hi,



Regarding the porting of Chrome to Firefox, there is this tutorial

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Porting_a_Google_Chrome_extension<https://urldefense.proofpoint.com/v2/url?u=https-3A__developer.mozilla.org_en-2DUS_Add-2Dons_WebExtensions_Porting-5Fa-5FGoogle-5FChrome-5Fextension&d=DwMFaQ&c=TxO9TIZxM1NIgbR_44vEiALc2o8uaxixBRc1BtwrN08&r=N8Ef6xGR2eDgjA8I5q1SOErZhf616XiV4IPj4Ncf1w0&m=KEUjj7i52sXdyDEYB1S_1R2AGyyaY6_1e5mItRY7WsU&s=_k2ExcW7np85FsQYbflGyir_9vCGQHDKTYgkHRfaxec&e=>

Concerning your problem, to create new tab, you have to use

function openMyPage() {
   browser.tabs.create({
     url: "file://///server///folder<file://server/folder>"
   });
}

browser.browserAction.onClicked.addListener(openMyPage);


you have an example with "open-my-page-button" in https://github.com/mdn/webextensions-examples<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_mdn_webextensions-2Dexamples&d=DwMFaQ&c=TxO9TIZxM1NIgbR_44vEiALc2o8uaxixBRc1BtwrN08&r=N8Ef6xGR2eDgjA8I5q1SOErZhf616XiV4IPj4Ncf1w0&m=KEUjj7i52sXdyDEYB1S_1R2AGyyaY6_1e5mItRY7WsU&s=xrCAdl79kWZhQfAZwapc9VyeioqpBMH3NXBkpshlnS0&e=>

best regard

Chrsitophe






2017-10-22 16:28 GMT+02:00 Avi Steiner <asteiner at varonis.com<mailto:asteiner at varonis.com>>:
Hello
I have an extension that was written as XUL/XPCOM.
As you may know, the extension will be unavailable since next Firefox version (November 2017).
I have the same extension for Chrome which is working. I tried to rename the Chrome extension from *.crx to *.xpi and installed in my Firefox browser.
I also tried to create my new xpi extension.

The extension is running but fails to do what it should do:
Open a new tab with a URL with file:\\ URI scheme.

chrome.tabs.create({ url: "file://///server///folder<file://server/folder>" });
or
browser.tabs.create({ url: "file://///server///folder<file://server/folder>" });

This statement is called within a background script.
It fails with the following error:

Unchecked lastError value: Error: Illegal URL: file://///server///folder<file://server/folder>

This statement works as expected in Chrome browser.

From documentation of tabs.create():

For security reasons, in Firefox, this may not be a privileged URL. So passing any of the following URLs will fail:
chrome: URLs
javascript: URLs
data: URLs
file: URLs (i.e., files on the filesystem. However, to use a file packaged inside the extension, see below)
privileged about: URLs (for example, about:config, about:addons, about:debugging). Non-privileged URLs (e.g., about:blank) are allowed.
The New Tab page (about:newtab) can be opened if no value for URL is provided.

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/create<https://urldefense.proofpoint.com/v2/url?u=https-3A__developer.mozilla.org_en-2DUS_Add-2Dons_WebExtensions_API_tabs_create&d=DwMFaQ&c=TxO9TIZxM1NIgbR_44vEiALc2o8uaxixBRc1BtwrN08&r=N8Ef6xGR2eDgjA8I5q1SOErZhf616XiV4IPj4Ncf1w0&m=KEUjj7i52sXdyDEYB1S_1R2AGyyaY6_1e5mItRY7WsU&s=sAroAp6CFYAT_b2cEEl8UvZarRnBB86CqVZEzXyVJUs&e=>

Is there any way for work around?

________________________________
This email and any attachments thereto may contain private, confidential, and privileged material for the sole use of the intended recipient. Any review, copying, or distribution of this email (or any attachments thereto) by others is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete the original and any copies of this email and any attachments thereto.

_______________________________________________
Dev-addons mailing list
Dev-addons at mozilla.org<mailto:Dev-addons at mozilla.org>
https://mail.mozilla.org/listinfo/dev-addons<https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.mozilla.org_listinfo_dev-2Daddons&d=DwMFaQ&c=TxO9TIZxM1NIgbR_44vEiALc2o8uaxixBRc1BtwrN08&r=N8Ef6xGR2eDgjA8I5q1SOErZhf616XiV4IPj4Ncf1w0&m=KEUjj7i52sXdyDEYB1S_1R2AGyyaY6_1e5mItRY7WsU&s=BZTjr8GQhN6bRTL6O1NFM1jg8wb1I3iCNkohFZJWQWo&e=>



--

Christophe Villeneuve (aka Hello)
--------------------------------------------------------
* Mes derniers livres :"Drupal avancé" aux Editions Eyrolles //
"Construisez votre application : PHP & MySQL - MySQLi - PDO" aux Editions ENI
* Membre : PHP (AFUP) - MariaDB (LeMug) - Drupal - MozillaReps - Libre at toi
* Rédacteur pour Programmez, Linux pratique, ...
* blog : http://blog.hello-design.fr<https://urldefense.proofpoint.com/v2/url?u=http-3A__blog.hello-2Ddesign.fr&d=DwMFaQ&c=TxO9TIZxM1NIgbR_44vEiALc2o8uaxixBRc1BtwrN08&r=N8Ef6xGR2eDgjA8I5q1SOErZhf616XiV4IPj4Ncf1w0&m=KEUjj7i52sXdyDEYB1S_1R2AGyyaY6_1e5mItRY7WsU&s=XbSGff8MUHgxVr8bb_1bNNENIOcAS29-9OAjaB2sq-A&e=>
* Consultant/Integrateur : http://www.hello-design.fr<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.hello-2Ddesign.fr_&d=DwMFaQ&c=TxO9TIZxM1NIgbR_44vEiALc2o8uaxixBRc1BtwrN08&r=N8Ef6xGR2eDgjA8I5q1SOErZhf616XiV4IPj4Ncf1w0&m=KEUjj7i52sXdyDEYB1S_1R2AGyyaY6_1e5mItRY7WsU&s=Cu_vJTN0eAVORjRUbnkgquhcSgG5q_xBqU-Ud_ofGJo&e=>

________________________________
This email and any attachments thereto may contain private, confidential, and privileged material for the sole use of the intended recipient. Any review, copying, or distribution of this email (or any attachments thereto) by others is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete the original and any copies of this email and any attachments thereto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/dev-addons/attachments/20171024/443c5578/attachment-0001.html>


More information about the Dev-addons mailing list