-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Enabled "read with streaming" unit test for browsers that support streaming #9268
Conversation
test/unit/network_spec.js
Outdated
/Mozilla\/5.0.*?rv:(?:\d+).*? Gecko/.test(userAgent); | ||
let isFetchWithStreamSupport = (typeof Response !== 'undefined' && | ||
'body' in Response.prototype && | ||
typeof ReadableStream !== 'undefined'); |
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.
Nit: Please align these lines vertically, like so:
let isFetchWithStreamSupport = (typeof Response !== 'undefined' &&
'body' in Response.prototype &&
typeof ReadableStream !== 'undefined');
test/unit/network_spec.js
Outdated
typeof ReadableStream !== 'undefined'); | ||
|
||
if (!isFirefoxWithMozChunkedEncodingSupport && | ||
!isFetchWithStreamSupport) { |
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.
Nit: Insufficient indentation on this line, please make sure that the two lines are aligned like below:
if (!isFirefoxWithMozChunkedEncodingSupport &&
!isFetchWithStreamSupport) {
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.
Yeah Sure I'll do that rightway. Thanks for reviewing .
test/unit/network_spec.js
Outdated
@@ -67,11 +67,15 @@ describe('network', function() { | |||
// The test is valid for FF only: the XHR has support of the | |||
// 'moz-chunked-array' response type. | |||
// TODO enable for other browsers, e.g. when fetch/streams API is supported. |
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.
As mentioned in https://github.com/mozilla/pdf.js/pull/9050/files/#r154503634, these comments are no longer necessary.
test/unit/network_spec.js
Outdated
var isFirefoxWithMozChunkedEncodingSupport = | ||
/Mozilla\/5.0.*?rv:(?:\d+).*? Gecko/.test(userAgent); | ||
let isFetchWithStreamSupport = (typeof Response !== 'undefined' && | ||
'body' in Response.prototype && |
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.
There's one space too many on this line, please remove it.
Finally, you need to squash the commits when addressing review feedback; please see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits.
test/unit/network_spec.js
Outdated
expect(true).toEqual(true); | ||
done(); | ||
return; | ||
var isFirefoxWithMozChunkedEncodingSupport = |
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.
Change var
to let
here too.
Please squash the commits into one commit after you've made these changes. Refer to https://github.com/mozilla/pdf.js/wiki/Squashing-Commits for how to do that easily. |
improved indentation changes done as required
f236ad2
to
2626cf0
Compare
@timvandermeij |
/botio unittest |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/28ef1909f36ab6a/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/23352ba67bd399d/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/23352ba67bd399d/output.txt Total script time: 2.92 mins
|
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/28ef1909f36ab6a/output.txt Total script time: 6.56 mins
|
@Snuffleupagus Why is the unit tests failing in either of the OS? TEST-UNEXPECTED-FAIL | read with streaming | Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. TEST-UNEXPECTED-FAIL | read with streaming | Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. |
I don't know offhand, but they seem to fail locally as well. Did you successfully run the unit-tests locally with this patch? |
Initially while commiting I did and it was working perfectly. However after squashing i didnt perform the unit test. Also I tried commiting again in order to check if any difference has been made in any other file. However, On branch enable-read-with-stream Running gulp unittest now renders this gulp unittest Getting extension build number[15:01:32] Starting 'locale'... Building localization filesExtension build number: 204 Creating generic components[15:01:37] Version: webpack 3.10.0 Creating generic viewerBundling files into pdf.js[15:01:52] Version: webpack 3.10.0 Running unit testsWARNING: File was not downloaded. See "pdfs/bug951051.pdf.error" file. Server running at http://127.0.0.1:43871/ Error: ENOENT: no such file or directory, lstat '/path' Also I tried commiting again in order to check if any difference has been made in any other file. However, |
@Snuffleupagus An HTTP 504 error gets generated at "pdfs/bug951051.pdf.error" in the test folder. |
The following snippet was picked from the previous long text only. WARNING: File was not downloaded. See "pdfs/bug951051.pdf.error" file. (sorry I dont know how to add a specific reply text) @Snuffleupagus |
I'm not sure if the errors mentioned above are that relevant to the unit tests that we're concerned with here. However, now that I look at the code in https://github.com/mozilla/pdf.js/blob/master/src/display/network.js, I'm not really sure how this unit-test would work in non-Firefox browsers, given that the Since the unit-tests in the @timvandermeij Any ideas here? |
@Snuffleupagus I guess this new error that has occurred remained hidden initially because of the error which was reported in issue #8851 . Now that #8851 is corrected (hopefully) this error re-surfaced (which it originally should have had on its own). |
The @Rob--W Could you chime in here? |
Any updates? |
When I run the tests with this patch, it passes in Firefox but faiils in Chrome. To help with debugging, run only this test, by starting a server with I put a pdf.js/test/unit/network_spec.js Line 42 in 546cd2b
getFullReader().read() never resolves.
That promise is created here: Lines 459 to 461 in 546cd2b
If I search in that file, the only location where this promise is fulfilled is at: Lines 387 to 391 in 546cd2b
And Lines 315 to 322 in 546cd2b
These functions are used in Lines 86 to 139 in 546cd2b
I stopped looking further, because I was expecting the test to use the In Chrome, the following logic should have been called in the test, in order to test streaming. pdf.js/src/display/fetch_stream.js Lines 44 to 48 in 546cd2b
@yurydelendik wrote this unit test. Why is the test unconditionally using the |
You are right. We are doing wrong here. We should detect for the support of Lines 34 to 44 in 546cd2b
If you look into pdf.js/test/unit/jasmine-boot.js Lines 83 to 89 in 546cd2b
PDFNetworkStream by feature-detection, but it is only applicable for test/unit/api_spec.js
|
@Snuffleupagus any updates? |
Please read #9268 (comment) and #9268 (comment) above. The gist of it though, is that the code that we're attempting to test here isn't implemented that way was initially assumed. Hence we need to figure out how to reconcile this first, probably in a separate issue/PR, before these unit-test can be enabled. So currently, it seems to me that this PR unfortunately needs to be put on hold for the time being. |
@Snuffleupagus Uhm Okay. |
I would start with ensuring that |
Closing since the change is not in a mergable state at the moment and there has been no more follow-up. The issue will remain open and new pull requests to address the issue are welcome. For anyone willing to work on this, I suggest to read the comments above and make the necessary changes in small chunks (perhaps multiple pull requests). Thanks. |
😞 |
As mentioned by @timvandermeij 3 days ago, I have made the required changes, also referring to the comments mentioned by @Snuffleupagus here.
This hopefully closes #8851 .