Проблема с вводом type = "file" в веб-расширении Mozilla - PullRequest
0 голосов
/ 28 октября 2019

Я портирую расширение с Chrome на Firefox.

Есть HTML с

<input type="file" id="protocol-file"/>

После нажатия кнопки расширения я вижу свой ввод. Затем начинайте выбирать локальный файл с диска - на моем диске появляется окно со списком файлов, но окна расширения исчезли (только в Firefox, в Chrome он все еще остается видимым).

Я пытался добавить

document.getElementById('protocol-file').onchange = function() {
    alert('protocol-file changed');
};

но это не работает - я не вижу оповещения после выбора файла.

Кажется, расширение заканчивает работу по выбору файлов в Firefox. В Chrome все в порядке.

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <script src="main.js"></script>
  <body>
    <div id="container">
        <div class="file-input-block">
            <span class="file-label">Файл:</span>
            <input type="file" id="protocol-file"/>
       </div>    
    </div>    
  </body>
</html>

main.js

document.addEventListener('DOMContentLoaded', function(){
    document.getElementById('protocol-file').onchange = function() {
        alert('protocol-file changed');
    };
});

manifest.json

{
  "name": "Example",
  "version": "0.1",
  "description": "Mozilla ext example",
  "manifest_version": 2,
  "permissions": [
    "activeTab",
    "tabs",
    "notifications",
    "http://*/",
    "https://*/"
  ],
  "browser_action": {
    "default_title": "Example file select",
    "default_popup": "index.html"
  },
  "browser_specific_settings": {
    "gecko": {
      "id": "my@examle.com",
      "strict_min_version": "49.0"
    }
  }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...