Closed Bug 1388041 Opened 7 years ago Closed 7 years ago

Allow Marionette to resolve the "cancel running downloads" confirmation dialogue on in_app shutdown request

Categories

(Remote Protocol :: Marionette, defect)

Version 3
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: j1095945, Unassigned)

References

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20170613225334

Steps to reproduce:

0. create marionette instance
1. download some file that takes a while

2. a)
# can be called with marionette.quit(in_app=True)
marionette._request_in_app_shutdown()

2. b)
# second try, same problem
# 3 = eForceQuit
marionette._request_in_app_shutdown(shutdown_flags=3)


Actual results:

confirmation dialogue "do you want to cancel 1 running download" appears


Expected results:

add some mechanism in the sense of _request_in_app_shutdown(cancel_downloads=True)
this way, a running browser can be quit even if a download is running.

currently, i found there to be no mechanism to quit an external browser instance that wasn't started by marionette. It seems the _request_in_app_shutdown() function does not return while the confirmation dialogue is open.

sadly, doing this via preferences is impossible since that feature got removed:
https://bugzilla.mozilla.org/show_bug.cgi?id=1384559
Lets wait for a reply / solution on bug 1384559 first.
Given the discussion on bug 1384559 I'm going to wontfix this bug. If you have a test which has such a huge download you will have to cancel it before quitting Firefox. In case you want to continue it after restart, make sure that your test checks for the modal dialog. It's not the harness which has to care about it.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
(In reply to Henrik Skupin (:whimboo) from comment #2)
> If you
> have a test which has such a huge download you will have to cancel it before
> quitting Firefox.

Is there a possibility to interact with the downloads or, more specifically, cancel one (or all) downloads? I found noting in the marionette docs.
Please have a look at https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm#getList().

You want to fetch all the downloads, and then go through each of those and calling `cancel()` on it. Given that promises are involved you want to use the `execute_async_script` command of Marionette.
Code snipped should anyone stumble upon this (CC-0):

    marionette.set_context(client.CONTEXT_CHROME);
    marionette.execute_async_script('''
        Components.utils.import("resource://gre/modules/Downloads.jsm");

        Task.spawn(function () {
            var dlist = yield Downloads.getList(Downloads.ALL);
            var darray = yield dlist.getAll();
            for(i of darray){
                yield i.finalize(true);
            }
            marionetteScriptFinished(1);
        });
        ''');

    # reset context to Content
    marionette.set_context(client.CONTEXT_CONTENT);
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.