Skip to content

Commit

Permalink
browser(firefox): report navigation request failure for downloads (#1688
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yury-s authored Apr 7, 2020
1 parent 4cf5cf6 commit becf97f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion browser_patches/firefox/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1073
1074
19 changes: 14 additions & 5 deletions browser_patches/firefox/patches/bootstrap.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
+ }
+ }
+
Expand Down

0 comments on commit becf97f

Please sign in to comment.