[regression] browser.downloads.search return an empty array
Categories
(WebExtensions :: General, defect)
Tracking
(firefox-esr60 unaffected, firefox64 unaffected, firefox65+ fixed, firefox66+ fixed, firefox70 wontfix, firefox71 wontfix)
Tracking | Status | |
---|---|---|
firefox-esr60 | --- | unaffected |
firefox64 | --- | unaffected |
firefox65 | + | fixed |
firefox66 | + | fixed |
firefox70 | --- | wontfix |
firefox71 | --- | wontfix |
People
(Reporter: yfdyh000, Assigned: aswan)
References
Details
(Keywords: regression)
Attachments
(1 file)
47 bytes,
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-beta+
|
Details | Review |
STR:
- Install the https://addons.mozilla.org/firefox/addon/scrapbee/ (ver 1.1.0).
- Click the DOWNLOAD button on moz-extension://8f7ca8d0-7897-4cb0-beef-3d28436b45b6/options.html#initiate.
The code:
var exec = "scrapbee_backend" + (settings.platform=="windows"?".exe":"");
browser.downloads.download({
url: "moz-extension://" + settings.extension_id + "/" + exec,
filename: "scrapbee/" + exec,
conflictAction: "overwrite",
saveAs: false
}).then(function(id){
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/DownloadItem
var searching = browser.downloads.search({
id: id
}).then(function(downloads){
var fn = function(downloadDelta){
if(downloadDelta.id == id && (downloadDelta.state && downloadDelta.state.current == "complete")){
browser.downloads.onChanged.removeListener(fn);
var filename = downloads[0].filename;
.....
Actual results:
You get a file that has been downloaded.
Browser Console error: downloads[0] is undefined; can't access its "filename" property
Expected results:
You get three files to be downloaded.
Regression range:
bug 1503760.
Comment 1•5 years ago
|
||
Hey Andrew, flagging you for needinfo since you were the mentor for bug 1503760. Could you take a look at this for beta65?
Updated•5 years ago
|
Assignee | ||
Comment 2•5 years ago
|
||
The fixes in bug 1503760 inadvertently broke searches of downloads that
have not yet started receiving data (which have a value of -1 for the
totalBytes property). That regression is fixed here.
Updated•5 years ago
|
Pushed by aswan@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ee03992cef6e Fix a regression with browser.downloads.search() r=kmag
Assignee | ||
Comment 4•5 years ago
|
||
Comment on attachment 9037338 [details]
Bug 1519762 Fix a regression with browser.downloads.search()
[Beta/Release Uplift Approval Request]
Feature/Bug causing the regression: Bug 1503760
User impact if declined: The webextension function browser.downloads.search() fails to return results for newly created downloads until they start receiving data. This can break extensions that don't expect this, the initial report for this bug is a typical example.
Is this code covered by automated tests?: Yes
Has the fix been verified in Nightly?: No
Needs manual test from QE?: No
If yes, steps to reproduce:
List of other uplifts needed: None
Risk to taking this patch: Low
Why is the change risky/not risky? (and alternatives if risky): The change is limited to the webextensions browser.download.search() function which has decent existing automated test coverage. That coverage is extended to cover this particular regression in this patch.
String changes made/needed:
Comment 5•5 years ago
|
||
Backed out changeset ee03992cef6e (Bug 1519762) for test_ext_downloads_search.js failures.
Push with failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=ee03992cef6e9e16a3bb99ab81d3b0468ff85faa&selectedJob=222544385
Backout link: https://hg.mozilla.org/integration/autoland/rev/cc2853aad2c4180fdfc0504afd84f94d2ef1371f
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=222544385&repo=autoland&lineNumber=9121
20:54:21 INFO - TEST-START | toolkit/components/url-classifier/tests/unit/test_digest256.js
20:54:22 INFO - TEST-PASS | toolkit/components/url-classifier/tests/unit/test_digest256.js | took 349ms
20:54:22 INFO - TEST-START | xpcshell-remote.ini:toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js
20:59:22 WARNING - TEST-UNEXPECTED-TIMEOUT | xpcshell-remote.ini:toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js | Test timed out
20:59:22 INFO - TEST-INFO took 300001ms
20:59:22 INFO - >>>>>>>
20:59:22 INFO - PID 12292 | Unable to load \untrusted-startup-test-dll.dll; LoadLibraryW failed: 126[12292, Main Thread] WARNING: Failed to get directory to cache.: file z:/build/build/src/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp, line 80
20:59:22 INFO - PID 12292 | [12292, Main Thread] WARNING: Failed to get directory to cache.: file z:/build/build/src/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp, line 80
20:59:22 INFO - PID 12292 | [12292, Main Thread] WARNING: Failed to get directory to cache.: file z:/build/build/src/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp, line 80
20:59:22 INFO - PID 12292 | [12292, Main Thread] WARNING: Failed to get directory to cache.: file z:/build/build/src/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp, line 80
20:59:22 INFO - PID 12292 | [12292, Main Thread] WARNING: Failed to get directory to cache.: file z:/build/build/src/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp, line 80
20:59:22 INFO - PID 12292 | [12292, Main Thread] WARNING: Couldn't get the user appdata directory. Crash events may not be produced.: file z:/build/build/src/toolkit/crashreporter/nsExceptionHandler.cpp, line 2534
20:59:22 INFO - PID 12292 | JavaScript strict warning: resource://testing-common/AddonTestUtils.jsm, line 307: ReferenceError: reference to undefined property "testScope"
20:59:22 INFO - PID 12292 | JavaScript strict warning: resource://testing-common/AddonTestUtils.jsm, line 313: ReferenceError: reference to undefined property "testScope"
20:59:22 INFO - "CONSOLE_MESSAGE: (warn) [JavaScript Warning: "ReferenceError: reference to undefined property "testScope"" {file: "resource://testing-common/AddonTestUtils.jsm" line: 307}]"
20:59:22 INFO - "CONSOLE_MESSAGE: (warn) [JavaScript Warning: "ReferenceError: reference to undefined property "testScope"" {file: "resource://testing-common/AddonTestUtils.jsm" line: 313}]"
20:59:22 INFO - (xpcshell/head.js) | test MAIN run_test pending (1)
20:59:22 INFO - (xpcshell/head.js) | test run_next_test 0 pending (2)
20:59:22 INFO - (xpcshell/head.js) | test MAIN run_test finished (2)
20:59:22 INFO - running event loop
20:59:22 INFO - xpcshell-remote.ini:toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js | Starting check_remote
20:59:22 INFO - (xpcshell/head.js) | test check_remote pending (2)
20:59:22 INFO - TEST-PASS | xpcshell-remote.ini:toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js | check_remote - [check_remote : 1436] useRemoteWebExtensions matches - true == true
20:59:22 INFO - TEST-PASS | xpcshell-remote.ini:toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js | check_remote - [check_remote : 1436] testing from extension process - false == false
20:59:22 INFO - (xpcshell/head.js) | test run_next_test 0 finished (2)
20:59:22 INFO - (xpcshell/head.js) | test run_next_test 1 pending (2)
20:59:22 INFO - (xpcshell/head.js) | test check_remote finished (2)
20:59:22 INFO - xpcshell-remote.ini:toolkit/components/extensions/test/xpcshell/test_ext_downloads_search.js | Starting test_search
20:59:22 INFO - (xpcshell/head.js) | test test_search pending (2)
20:59:22 INFO - "downloadDir c:\users\task_1547756142\appdata\local\temp\xpc-profile-z0xvcn\temp\downloads"
20:59:22 INFO - (xpcshell/head.js) | test run_next_test 1 finished (2)
20:59:22 INFO - "removed 0 pre-existing downloads from history"
20:59:22 INFO - "Extension attached"
Assignee | ||
Comment 6•5 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/dd74d02dfc11bd73afe4a3e3ae2def4c866fa98f Bug 1519762 Fix a regression with browser.downloads.search() r=kmag
Comment 7•5 years ago
|
||
bugherder |
Assignee | ||
Updated•5 years ago
|
Comment 8•5 years ago
|
||
Comment on attachment 9037338 [details]
Bug 1519762 Fix a regression with browser.downloads.search()
[Triage Comment]
Fixes the browser.downloads.search() function to account for new downloads which haven't received data yet. Thanks for adding tests for this. Approved for 65.0rc1.
Comment 9•5 years ago
|
||
bugherder uplift |
Comment 10•5 years ago
|
||
browser.downloads.search
70 dev beta and 71 Nightly: it always returns an empty list of downloads.
example from developer.mozilla.org:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/search#Get_all_downloads
===============
function logDownloads(downloads) {
for (let download of downloads) {
console.log(download.id);
console.log(download.url);
}
}
function onError(error) {
console.log(Error: ${error}
);
}
var searching = browser.downloads.search({});
searching.then(logDownloads, onError);
Comment 11•5 years ago
|
||
PS: there is no problem in the current version 69.0.2
Description
•