Firefox WebExtension弹出窗口-间歇性焦点

时间:2018-12-09 15:35:17

标签: javascript firefox firefox-webextensions

我正在玩一个Firefox扩展程序:

1)当我按create or replace view task_statistics as select user , count(distinct id) as total_completed_tasks , avg(completion_time) as avg_completion_time , avg(length) as avg_task_length , avg(difficulty) as avg_difficulty , avg(cost) as avg_cost from task group by user;

时,显示扩展名弹出页面

2)弹出页面侦听Ctrl+Space事件。根据键的不同,在关闭弹出窗口之前,会将新网站加载到新的浏览器选项卡中。

问题

当我按keydown时,弹出窗口将按预期方式显示。但是,有时看起来好像弹出窗口不在焦点上,这意味着将错过所有按键事件。当我在弹出窗口中单击以使其重新聚焦时,将按需捕获按键事件。

如果我通过单击扩展程序的按钮显示弹出窗口,则不会出现这种间歇性行为。

我不确定这是否是Firefox问题。有没有人在解决此问题之前和/或知道解决方法?

编辑:经过进一步调查,间歇性行为的发生主要是在事件处理程序加载后立即快速按下Ctrl+Space并打开一个新标签页,该标签页包含Ctrl+Spacehttps://www.youtube.com之类的网站。事件处理程序加载Google或StackOverflow时似乎没有发生。也许媒体重磅网站正在以某种方式窃取焦点?

manifest.json

https://www.bbc.com/news

popup.html

{
    "manifest_version": 2,
    "name": "QuickLinks",
    "version": "0.2",

    "description": "Create your own set of links for very quick access to your favorite sites.",

    "icons": {
        "48": "icons/QuickLinks48.png",
        "96": "icons/QuickLinks96.png",
        "128": "icons/QuickLinks128.png"
    },

    "permissions":
    [
        "activeTab",
        "storage"
    ],

    "browser_action": {
        "browser_style": true,
        "default_icon": "icons/QuickLinks48.png",
        "default_title": "QuickLinks",
        "default_popup": "popup/popup.html"
    },

    "options_ui": {
        "browser_style": true,
        "page": "options/options.html"
    },

    "applications": {
        "gecko": {
            "id": "58e78ac522594027d5362a36033ee5d0fdb48db1@quicklinks",
            "strict_min_version": "57.0"
        }
    },

    "commands": {
        "_execute_browser_action": {
            "suggested_key": {
                "default": "Ctrl+Space"
            }
        }
    }
}

popup.js

<html>
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="popup.css"/>
    </head>

    <body>
        <div class="buttons">
            <table id="links"></table>
            <div class="options row">Show options</div>
        </div>

        <script src="popup.js"></script>
    </body>
</html>

0 个答案:

没有答案