Open Bug 926303 Opened 11 years ago Updated 2 years ago

Implement a less clunky way of allowing script to cancel directory picker scans

Categories

(Core :: DOM: Forms, defect)

defect

Tracking

()

People

(Reporter: jwatt, Assigned: jwatt)

References

Details

Spinning this out from bug 923926 comment 6, where Jonas says about allowing cancelling of directory picker scans by calling preventDefault() on the progress events:

The code flow for authors with this API is a bit weird. Basically you end up with code looking something like:


var cancelPendingScan = false;
$("cancelScanButton").onclick = function() {
  cancelPendingScan = true;
}
$("fileInput").onprogress = function(e) {
  if (cancelPendingScan) {
    e.preventDefault();
    cancelPendingScan = false;
  }
}

It seems much better if you can cancel the scan directly. Both from a code-flow point of view, and from a resource-use point of view.


I think a better solution is to provide some sort of object representing the directory scan whenever we start a scan. We could fire progress notifications as well as expose an abort() function on this object. The object would be exposed through a "directorypicked" event or some such.

In fact, the object could likely simply be a AbortableProgressPromise.
Bug 923926 was the API we agreed on with Mounir, but that's a valid issue.

ProgressPromise was something we decided against in the end because we wanted to expose progress to script, even in the case that the user opens the directory picker (in which case openDirectoryPicker() would not have been called by script so no ProgressPromise would exist for script). Besides that, discussion on the list seemed to conclude that ProgressPromise is not an API that is likely to make it onto the Web.

If we add a "directorypicked" event and expose a setable "buildingFileList" property on that to allow script to check if the scan is in progress and cancel the scan, that would work for me. Thoughts?
Component: DOM: Core & HTML → DOM: Forms
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.