From 927669b8906375be6bba70b15533b29b898abd70 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Sat, 14 Dec 2019 08:21:23 -0800 Subject: [PATCH] feat(firefox): provide navigationId for navigation requests (#249) --- .../firefox/patches/bootstrap.diff | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diff index 181a5bbbf9..06ffde5ca3 100644 --- a/browser_patches/firefox/patches/bootstrap.diff +++ b/browser_patches/firefox/patches/bootstrap.diff @@ -605,7 +605,7 @@ index 000000000000..673e93b0278a + diff --git a/testing/juggler/NetworkObserver.js b/testing/juggler/NetworkObserver.js new file mode 100644 -index 000000000000..cc8cb8fe9d83 +index 000000000000..2afbc74a4170 --- /dev/null +++ b/testing/juggler/NetworkObserver.js @@ -0,0 +1,450 @@ @@ -809,7 +809,7 @@ index 000000000000..cc8cb8fe9d83 + postData: readRequestPostData(httpChannel), + headers: requestHeaders(httpChannel), + method: httpChannel.requestMethod, -+ isNavigationRequest: httpChannel.isMainDocumentChannel, ++ navigationId: httpChannel.isMainDocumentChannel ? requestId(httpChannel) : undefined, + cause: causeTypeToString(causeType), + }); + } @@ -1465,10 +1465,10 @@ index 000000000000..f68780d529e7 + diff --git a/testing/juggler/content/FrameTree.js b/testing/juggler/content/FrameTree.js new file mode 100644 -index 000000000000..2931c75e60d2 +index 000000000000..640782151e30 --- /dev/null +++ b/testing/juggler/content/FrameTree.js -@@ -0,0 +1,232 @@ +@@ -0,0 +1,240 @@ +"use strict"; +const Ci = Components.interfaces; +const Cr = Components.results; @@ -1547,7 +1547,7 @@ index 000000000000..2931c75e60d2 + + if (isStart) { + // Starting a new navigation. -+ frame._pendingNavigationId = helper.generateId(); ++ frame._pendingNavigationId = this._channelId(channel); + frame._pendingNavigationURL = channel.URI.spec; + this.emit(FrameTree.Events.NavigationStarted, frame); + } else if (isTransferring || (isStop && frame._pendingNavigationId && !status)) { @@ -1579,6 +1579,14 @@ index 000000000000..2931c75e60d2 + } + } + ++ _channelId(channel) { ++ if (channel instanceof Ci.nsIHttpChannel) { ++ const httpChannel = channel.QueryInterface(Ci.nsIHttpChannel); ++ return String(httpChannel.channelId); ++ } ++ return helper.generateId(); ++ } ++ + _onDocShellCreated(docShell) { + // Bug 1142752: sometimes, the docshell appears to be immediately + // destroyed, bailout early to prevent random exceptions. @@ -4126,7 +4134,7 @@ index 000000000000..78b6601b91d0 +this.EXPORTED_SYMBOLS = ['t', 'checkScheme']; diff --git a/testing/juggler/protocol/Protocol.js b/testing/juggler/protocol/Protocol.js new file mode 100644 -index 000000000000..829576c5a48c +index 000000000000..700571aeed45 --- /dev/null +++ b/testing/juggler/protocol/Protocol.js @@ -0,0 +1,668 @@ @@ -4355,7 +4363,7 @@ index 000000000000..829576c5a48c + suspended: t.Optional(t.Boolean), + url: t.String, + method: t.String, -+ isNavigationRequest: t.Boolean, ++ navigationId: t.Optional(t.String), + cause: t.String, + }, + 'responseReceived': {