Skip to content

Commit becf97f

Browse files
authored
browser(firefox): report navigation request failure for downloads (#1688)
1 parent 4cf5cf6 commit becf97f

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

browser_patches/firefox/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1073
1+
1074

browser_patches/firefox/patches/bootstrap.diff

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,10 +2953,10 @@ index 0000000000000000000000000000000000000000..268fbc361d8053182bb6c27f626e853d
29532953
+
29542954
diff --git a/juggler/content/FrameTree.js b/juggler/content/FrameTree.js
29552955
new file mode 100644
2956-
index 0000000000000000000000000000000000000000..5a1df2837d70531a670163b7c860108895bc9106
2956+
index 0000000000000000000000000000000000000000..8a87dabd37e83cba0f1dfac07d8fd18875c042ef
29572957
--- /dev/null
29582958
+++ b/juggler/content/FrameTree.js
2959-
@@ -0,0 +1,462 @@
2959+
@@ -0,0 +1,471 @@
29602960
+"use strict";
29612961
+const Ci = Components.interfaces;
29622962
+const Cr = Components.results;
@@ -3149,12 +3149,19 @@ index 0000000000000000000000000000000000000000..5a1df2837d70531a670163b7c8601088
31493149
+ const isTransferring = flag & Ci.nsIWebProgressListener.STATE_TRANSFERRING;
31503150
+ const isStop = flag & Ci.nsIWebProgressListener.STATE_STOP;
31513151
+
3152+
+ let isDownload = false;
3153+
+ try {
3154+
+ isDownload = (channel.contentDisposition === Ci.nsIChannel.DISPOSITION_ATTACHMENT);
3155+
+ } catch(e) {
3156+
+ // The method is expected to throw if it's not an attachment.
3157+
+ }
3158+
+
31523159
+ if (isStart) {
31533160
+ // Starting a new navigation.
31543161
+ frame._pendingNavigationId = this._channelId(channel);
31553162
+ frame._pendingNavigationURL = channel.URI.spec;
31563163
+ this.emit(FrameTree.Events.NavigationStarted, frame);
3157-
+ } else if (isTransferring || (isStop && frame._pendingNavigationId && !status)) {
3164+
+ } else if (isTransferring || (isStop && frame._pendingNavigationId && !status && !isDownload)) {
31583165
+ // Navigation is committed.
31593166
+ for (const subframe of frame._children)
31603167
+ this._detachFrame(subframe);
@@ -3166,12 +3173,14 @@ index 0000000000000000000000000000000000000000..5a1df2837d70531a670163b7c8601088
31663173
+ this.emit(FrameTree.Events.NavigationCommitted, frame);
31673174
+ if (frame === this._mainFrame)
31683175
+ this.forcePageReady();
3169-
+ } else if (isStop && frame._pendingNavigationId && status) {
3176+
+ } else if (isStop && frame._pendingNavigationId && (status || isDownload)) {
31703177
+ // Navigation is aborted.
31713178
+ const navigationId = frame._pendingNavigationId;
31723179
+ frame._pendingNavigationId = null;
31733180
+ frame._pendingNavigationURL = null;
3174-
+ this.emit(FrameTree.Events.NavigationAborted, frame, navigationId, helper.getNetworkErrorStatusText(status));
3181+
+ // Always report download navigation as failure to match other browsers.
3182+
+ const errorText = isDownload ? 'Will download to file' : helper.getNetworkErrorStatusText(status);
3183+
+ this.emit(FrameTree.Events.NavigationAborted, frame, navigationId, errorText);
31753184
+ }
31763185
+ }
31773186
+

0 commit comments

Comments
 (0)