[WebExtensions] Allow acces to nsIDOMWindowUtils::isHandlingUserInput

RESOLVED INVALID

Status

RESOLVED INVALID
2 years ago
4 months ago

People

(Reporter: kernp25, Unassigned)

Tracking

Trunk

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

2 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Build ID: 20160612030220

Steps to reproduce:

Allow webextensions to acces nsIDOMWindowUtils::isHandlingUserInput

Updated

2 years ago
OS: Unspecified → All
Hardware: Unspecified → All
Summary: nsIDOMWindowUtils::isHandlingUserInput → [WebExtensions] Allow acces to nsIDOMWindowUtils::isHandlingUserInput
Version: unspecified → Trunk
Can you be a bit clearer about what exactly you're looking for?
(Reporter)

Comment 2

2 years ago
I just want to know, if we're handling user input or not.
All that function does is tell internal code whether it's being called from an input event handler. It doesn't tell you anything you can't already find out for yourself.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → INVALID
(Reporter)

Comment 4

2 years ago
But, i need more code then (listeners etc. (more memory usage/high performance?)).
Why i must put more code if the browser already does this?

    function UserInputEventMonitor() { // Records the time of the latest user input event. Workaround for determining whether play() calls are from the user or not
        var self = this;

        function input_callback(event) {
            self.last_event = performance.now();
        };

        function init_handlers() {
            for (event_type of ["keydown", "keyup", "mousedown", "mouseup", "touchstart", "touchend"]) {
                window.addEventListener(event_type, input_callback, true);
            };
        };
        init_handlers();
        // In the case of running in an iframe: When the contents of the current iframe are set, event listeners are removed
        var document_observer = new MutationObserver(function(mutation_records) {
            init_handlers();
        });
        document_observer.observe(document, { childList: true });

        self.reached_timeout = function() {
            return (performance.now() - self.last_event) < TIMEOUT;
        };

        var TIMEOUT = 1500; // TODO: Make this configurable

        self.last_event = -2000;
    };

Why this extra more code, if the browser already tells u this?
The browser does it for a very specific, internal purpose. Adding a public API means designing, documenting, and maintaining that API, and maintaining a separate version of the same code when our internal logic needs to change.

This is simple enough to implement on the client side (and the mutation observer is not necessary), so adding a new public API is not necessary.

Updated

4 months ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.