[regression] browser.downloads.search return an empty array

RESOLVED FIXED in Firefox 65

Status

defect
RESOLVED FIXED
4 months ago
4 months ago

People

(Reporter: yfdyh000, Assigned: aswan)

Tracking

({regression})

65 Branch
mozilla66
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox-esr60 unaffected, firefox64 unaffected, firefox65+ fixed, firefox66+ fixed)

Details

Attachments

(1 attachment)

Reporter

Description

4 months ago

STR:

  1. Install the https://addons.mozilla.org/firefox/addon/scrapbee/ (ver 1.1.0).
  2. 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.

Reporter

Updated

4 months ago
Has Regression Range: --- → yes
Has STR: --- → yes

Hey Andrew, flagging you for needinfo since you were the mentor for bug 1503760. Could you take a look at this for beta65?

Flags: needinfo?(aswan)
Assignee

Comment 2

4 months 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.

Assignee: nobody → aswan

Comment 3

4 months 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

4 months 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:

Flags: needinfo?(aswan)
Attachment #9037338 - Flags: approval-mozilla-beta?

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"

Flags: needinfo?(aswan)

Comment 7

4 months ago
bugherder
Status: NEW → RESOLVED
Last Resolved: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
Assignee

Updated

4 months ago
Flags: needinfo?(aswan)

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.

Attachment #9037338 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.