browser(firefox): report navigation request failure for downloads (#1688)

This commit is contained in:
Yury Semikhatsky 2020-04-07 00:38:27 -07:00 committed by GitHub
parent 4cf5cf6c0e
commit becf97f30d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -1 +1 @@
1073
1074

View file

@ -2953,10 +2953,10 @@ index 0000000000000000000000000000000000000000..268fbc361d8053182bb6c27f626e853d
+
diff --git a/juggler/content/FrameTree.js b/juggler/content/FrameTree.js
new file mode 100644
index 0000000000000000000000000000000000000000..5a1df2837d70531a670163b7c860108895bc9106
index 0000000000000000000000000000000000000000..8a87dabd37e83cba0f1dfac07d8fd18875c042ef
--- /dev/null
+++ b/juggler/content/FrameTree.js
@@ -0,0 +1,462 @@
@@ -0,0 +1,471 @@
+"use strict";
+const Ci = Components.interfaces;
+const Cr = Components.results;
@ -3149,12 +3149,19 @@ index 0000000000000000000000000000000000000000..5a1df2837d70531a670163b7c8601088
+ const isTransferring = flag & Ci.nsIWebProgressListener.STATE_TRANSFERRING;
+ const isStop = flag & Ci.nsIWebProgressListener.STATE_STOP;
+
+ let isDownload = false;
+ try {
+ isDownload = (channel.contentDisposition === Ci.nsIChannel.DISPOSITION_ATTACHMENT);
+ } catch(e) {
+ // The method is expected to throw if it's not an attachment.
+ }
+
+ if (isStart) {
+ // Starting a new navigation.
+ frame._pendingNavigationId = this._channelId(channel);
+ frame._pendingNavigationURL = channel.URI.spec;
+ this.emit(FrameTree.Events.NavigationStarted, frame);
+ } else if (isTransferring || (isStop && frame._pendingNavigationId && !status)) {
+ } else if (isTransferring || (isStop && frame._pendingNavigationId && !status && !isDownload)) {
+ // Navigation is committed.
+ for (const subframe of frame._children)
+ this._detachFrame(subframe);
@ -3166,12 +3173,14 @@ index 0000000000000000000000000000000000000000..5a1df2837d70531a670163b7c8601088
+ this.emit(FrameTree.Events.NavigationCommitted, frame);
+ if (frame === this._mainFrame)
+ this.forcePageReady();
+ } else if (isStop && frame._pendingNavigationId && status) {
+ } else if (isStop && frame._pendingNavigationId && (status || isDownload)) {
+ // Navigation is aborted.
+ const navigationId = frame._pendingNavigationId;
+ frame._pendingNavigationId = null;
+ frame._pendingNavigationURL = null;
+ this.emit(FrameTree.Events.NavigationAborted, frame, navigationId, helper.getNetworkErrorStatusText(status));
+ // Always report download navigation as failure to match other browsers.
+ const errorText = isDownload ? 'Will download to file' : helper.getNetworkErrorStatusText(status);
+ this.emit(FrameTree.Events.NavigationAborted, frame, navigationId, errorText);
+ }
+ }
+