Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

browser(firefox): allow to override request url (#4436)

Yury Semikhatsky0167f8c18250
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER
index 20368e38d4..e6256d5dbb 100644
--- a/browser_patches/firefox/BUILD_NUMBER
+++ b/browser_patches/firefox/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1207
-Changed: [email protected] Fri Nov 13 14:41:15 PST 2020
+1208
+Changed: [email protected] Fri 13 Nov 2020 02:55:31 PM PST
diff --git a/browser_patches/firefox/juggler/NetworkObserver.js b/browser_patches/firefox/juggler/NetworkObserver.js
index 274e117ebe..df7b7bb97f 100644
--- a/browser_patches/firefox/juggler/NetworkObserver.js
+++ b/browser_patches/firefox/juggler/NetworkObserver.js
@@ -73,8 +73,8 @@ class PageNetwork {
this._interceptedRequests.clear();
}
- resumeInterceptedRequest(requestId, method, headers, postData) {
- this._takeIntercepted(requestId).resume(method, headers, postData);
+ resumeInterceptedRequest(requestId, url, method, headers, postData) {
+ this._takeIntercepted(requestId).resume(url, method, headers, postData);
}
fulfillInterceptedRequest(requestId, status, statusText, headers, base64body) {
@@ -180,9 +180,10 @@ class NetworkRequest {
}
// Public interception API.
- resume(method, headers, postData) {
+ resume(url, method, headers, postData) {
this._expectingResumedRequest = { method, headers, postData };
- this._interceptedChannel.resetInterception();
+ const newUri = url ? Services.io.newURI(url) : null;
+ this._interceptedChannel.resetInterceptionWithURI(newUri);
this._interceptedChannel = undefined;
}
diff --git a/browser_patches/firefox/juggler/protocol/PageHandler.js b/browser_patches/firefox/juggler/protocol/PageHandler.js
index fe5ccbd191..43e8519e1c 100644
--- a/browser_patches/firefox/juggler/protocol/PageHandler.js
+++ b/browser_patches/firefox/juggler/protocol/PageHandler.js
@@ -106,7 +106,7 @@ class PageHandler {
pageNavigationAborted: emitProtocolEvent('Page.navigationAborted'),
pageNavigationCommitted: emitProtocolEvent('Page.navigationCommitted'),
pageNavigationStarted: emitProtocolEvent('Page.navigationStarted'),
- pageReady: this._onPageReady.bind(this),
+ pageReady: this._onPageReady.bind(this),
pageSameDocumentNavigation: emitProtocolEvent('Page.sameDocumentNavigation'),
pageUncaughtError: emitProtocolEvent('Page.uncaughtError'),
pageWorkerCreated: this._onWorkerCreated.bind(this),
@@ -237,8 +237,8 @@ class PageHandler {
this._pageNetwork.disableRequestInterception();
}
- async ['Network.resumeInterceptedRequest']({requestId, method, headers, postData}) {
- this._pageNetwork.resumeInterceptedRequest(requestId, method, headers, postData);
+ async ['Network.resumeInterceptedRequest']({requestId, url, method, headers, postData}) {
+ this._pageNetwork.resumeInterceptedRequest(requestId, url, method, headers, postData);
}
async ['Network.abortInterceptedRequest']({requestId, errorCode}) {
diff --git a/browser_patches/firefox/juggler/protocol/Protocol.js b/browser_patches/firefox/juggler/protocol/Protocol.js
index 99414d2013..55842a7a15 100644
--- a/browser_patches/firefox/juggler/protocol/Protocol.js
+++ b/browser_patches/firefox/juggler/protocol/Protocol.js
@@ -491,6 +491,7 @@ const Network = {
'resumeInterceptedRequest': {
params: {
requestId: t.String,
+ url: t.Optional(t.String),
method: t.Optional(t.String),
headers: t.Optional(t.Array(networkTypes.HTTPHeader)),
postData: t.Optional(t.String),
diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diff
index 826ef84817..001e86f2d8 100644
--- a/browser_patches/firefox/patches/bootstrap.diff
+++ b/browser_patches/firefox/patches/bootstrap.diff
@@ -1595,6 +1595,37 @@ index 25c5b01fc54c8d45da8ceb7cf6ba163bee3c5361..490c5ce49cd9b5f804df59abbfb0450f
void updateTimeZone();
void internalResyncICUDefaultTimeZone();
+diff --git a/netwerk/base/nsINetworkInterceptController.idl b/netwerk/base/nsINetworkInterceptController.idl
+index 64a4a71b03b28872f376aac8eee12805bebd1bd8..f6fa7d731f3b0c7c4fcb26babad3fc2cdb29aec1 100644
+--- a/netwerk/base/nsINetworkInterceptController.idl
++++ b/netwerk/base/nsINetworkInterceptController.idl
+@@ -56,6 +56,7 @@ interface nsIInterceptedChannel : nsISupports
+ * network request.
+ */
+ void resetInterception();
++ void resetInterceptionWithURI(in nsIURI aURI);
+
+ /**
+ * Set the status and reason for the forthcoming synthesized response.
+diff --git a/netwerk/protocol/http/InterceptedHttpChannel.cpp b/netwerk/protocol/http/InterceptedHttpChannel.cpp
+index 86dfc4c832ab53b2dab6ac2ca7c63bd9ef326d4a..b004db5e5effd9bbcb0c4c530c13d33120a9da44 100644
+--- a/netwerk/protocol/http/InterceptedHttpChannel.cpp
++++ b/netwerk/protocol/http/InterceptedHttpChannel.cpp
+@@ -601,6 +601,14 @@ void InterceptedHttpChannel::DoAsyncAbort(nsresult aStatus) {
+ Unused << AsyncAbort(aStatus);
+ }
+
++NS_IMETHODIMP
++InterceptedHttpChannel::ResetInterceptionWithURI(nsIURI* aURI) {
++ if (aURI) {
++ mURI = aURI;
++ }
++ return ResetInterception();
++}
++
+ NS_IMETHODIMP
+ InterceptedHttpChannel::ResetInterception(void) {
+ if (mCanceled) {
diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp
index 1296a8b380f1ae1bb53ee25d1b2374dbf060fbb6..c1bea93fc8e7e9459f6f358bc91da820702197d2 100644
--- a/parser/html/nsHtml5TreeOpExecutor.cpp