-
Notifications
You must be signed in to change notification settings - Fork 10k
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 test cases for redirected responses #19074
base: master
Are you sure you want to change the base?
Conversation
pending("Cannot simulate cross-origin requests in Node.js"); | ||
} | ||
const params = buildGetDocumentParams(filename, options); | ||
const url = new URL(params.url); | ||
if (url.hostname === "localhost") { | ||
url.hostname = "127.0.0.1"; | ||
} else if (params.url.hostname === "127.0.0.1") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this params.url.hostname
was always incorrect, it should have been url.hostname
.
2e06cf6
to
bb89389
Compare
Note: rebase this when #19028 is merged. The new test is expected to fail right now because the fix has not been applied yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for helping out with the tests!
914df5d
to
1e53500
Compare
@Snuffleupagus I have addressed the nits, and also updated the PR to run the tests for all IPDFStream implementations where this is relevant, instead of just PDFNetworkStream - i.e. I repeated the test for PDFFetchStream. |
Some tests rely on the presence of a server that serves PDF files. When tests are run from a web browser, the test files and PDF files are served by the same server (WebServer), but in Node.js that server is not around. Currently, the tests that depend on it start a minimal Node.js server that re-implements part of the functionality from WebServer. To avoid code duplication when tests depend on more complex behaviors, this patch replaces createTemporaryNodeServer with the existing WebServer, wrapped in a new test utility that has the same interface in Node.js and non-Node.js environments (=TestPdfsServer). This patch has been tested by running the refactored tests in the following three configurations: 1. From the browser: - http://localhost:8888/test/unit/unit_test.html?spec=api - http://localhost:8888/test/unit/unit_test.html?spec=fetch_stream 2. Run specific tests directly with jasmine without legacy bundling: `JASMINE_CONFIG_PATH=test/unit/clitests.json ./node_modules/.bin/jasmine --filter='^api|^fetch_stream'` 3. `gulp unittestcli`
Regression tests for issue mozilla#12744 and PR mozilla#19028
1e53500
to
88f309c
Compare
@Snuffleupagus I've updated the test by moving it to a separate file. After doing that, I ran into a new issue: while the network_spec.js test ran in the browser only, the fetch_stream_spec.js test was also run in Node.js. I looked into re-using the existing "temporary node server" helper, but then I would have to re-implement the redirect functionality of webserver.mjs there. So in the end I decided to prepend another commit that replaces |
These are regression tests for issue #12744 and PR #19028.