Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block-network-request command #600

Conversation

notriddle
Copy link
Contributor

This provides a reasonable way to simulate a flakey network, busted deploy, or ad blocker. It lets us actively block a network request that the page makes.

// to simulate JS that is enabled, but fails to load
block-network-request: "*.js"

This is the simplest case, but is not the only useful one. It can also block specific files, and it can stack:

block-network-request: "*/search-index.js"
block-network-request: "*/search.js"

Once a block list is added, there's no way to remove it. Flakey network tests will probably be in separate test files, so that shouldn't be a serious weakness.

CC rust-lang/rust#123407

This provides a reasonable way to simulate a flakey network,
busted deploy, or ad blocker. It lets us actively block a
network request that the page makes.

    // to simulate JS that is enabled, but fails to load
    block-network-request: "*.js"

This is the simplest case, but is not the only useful one.
It can also block specific files, and it can stack:

    block-network-request: "*/search-index.js"
    block-network-request: "*/search.js"

Once a block list is added, there's no way to remove it.
Flakey network tests will probably be in separate test files,
so that shouldn't be a serious weakness.
@@ -0,0 +1,13 @@
// This test is meant to ensure that we can block an external script request.
// Since we are intentionally causing request errors, don't block them.
fail-on-request-error: false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you mention this in the documentation as well please? Could be surprising that a test fails if you block a request in another command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've addressed both nits.

@GuillaumeGomez
Copy link
Owner

Awesome, thanks!

@GuillaumeGomez GuillaumeGomez merged commit 9fdd000 into GuillaumeGomez:master Apr 4, 2024
2 checks passed
@GuillaumeGomez
Copy link
Owner

I'll make a new release soon and update rust-lang/rust#123407.

@notriddle notriddle deleted the notriddle/block-network-request branch April 4, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants