api: honor interception Continue overrides and fix pre-navigation enable
op_fetch_url ignored the url/method/headers/body fields on InterceptResolution::Continue, so the interception channel could pass, mock, or block a request but not rewrite it. Apply them: shadow url/method/body and derive custom_headers from the override after the channel resolves Continue. Also fix enable_interception() called before the first navigation: init_js propagated intercept_tx to the new runtime but not intercept_enabled, so the runtime started with interception disabled and op_fetch_url never intercepted. Propagate intercept_enabled in init_js as well. Add a test that rewrites a fetch's url via Continue and asserts the rewritten response is captured.
This commit is contained in:
1 parent
1f5066fc30
commit
c19a21c142
3 files changed
+88
-3
No files matched your search
@@ -327,6 +327,11 @@ impl Page {
|
||||
if let Some(tx) = &self.intercept_tx {
|
||||
rt.set_intercept_tx(tx.clone());
|
||||
}
|
||||
// Re-apply intercept_enabled: enable_interception()/enable_intercept()
|
||||
// called before the first navigation sets this on the Page while the
|
||||
// runtime does not exist yet, so the new runtime would otherwise start
|
||||
// with interception disabled and op_fetch_url would never intercept.
|
||||
rt.set_intercept_enabled(self.intercept_enabled);
|
||||
|
||||
if let Some(dom) = self.dom.take() {
|
||||
rt.set_dom(dom);
|
||||
|
||||
Reference in new issue
Block a user