|
|
Chromium Code Reviews
DescriptionValidate generated MHTML in mhtml_generation_browsertest.cc tests.
Attempts to load the generated MHTML file after creating it for all tests in
mhtml_generation_browsertest.cc. This allows for validation of its contents
being well formed by verifying that the newly added console message is not
reported.
Also simplifies the checking for the MHTML generation succeeding by asserting
from inside the generation call instead of having checks for test failure in
multiple tests.
BUG=672313
Review-Url: https://codereview.chromium.org/2866873002
Cr-Commit-Position: refs/heads/master@{#472939}
Committed: https://chromium.googlesource.com/chromium/src/+/656b9cae0b536ee2f9b8a2777f76ba4a4d775173
Patch Set 1 #
Total comments: 8
Patch Set 2 : Moved console logging to ResourceFetcher; new layout test; updates. #Patch Set 3 : Removed empty line. #Patch Set 4 : Fixed MHTMLGenerationTest errors. #
Total comments: 2
Patch Set 5 : Textual changes. #Patch Set 6 : Fixed layout test expectation. #
Messages
Total messages: 37 (20 generated)
The CQ bit was checked by carlosk@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
carlosk@chromium.org changed reviewers: + lukasza@chromium.org, nasko@chromium.org
lukasza@, nasko@: PTAL. https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/loader/DocumentLoader.cpp (right): https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/loader/DocumentLoader.cpp:444: CommitData(0, 0); IIUC the local frame is only initialized when data is first committed. As for empty documents (precisely the case for invalid MHTML) this only happens right above I chose to have the console message reported here in FinishedLoading instead of MaybeCreateArchive where I initially thought I would add it.
Thanks for tackling this - I think this (verifying in browser tests by looking out for the console error message) is indeed the best possible option. Could you please add a test for presence of the new console message? I think you could just add a test under third_party/WebKit/LayoutTests/mhtml (I can help with overall layout test question if needed :-). https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/loader/DocumentLoader.cpp (right): https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/loader/DocumentLoader.cpp:444: CommitData(0, 0); On 2017/05/05 23:46:27, carlosk wrote: > IIUC the local frame is only initialized when data is first committed. As for > empty documents (precisely the case for invalid MHTML) this only happens right > above I chose to have the console message reported here in FinishedLoading > instead of MaybeCreateArchive where I initially thought I would add it. Thank you for the comment above. Unfortunately, I still fail to understand why the console error is reported here and not in MaybeCreateArchive (in the |!main_resource| case). It seems wrong (and I think the current CL does this) to report the console error when there is a writer (i.e. we have a non-empty document?) which I think (?) would happen when returning false from MaybeCreateArchive in |!frame_| case. https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/loader/DocumentLoader.cpp:450: "Malformed multipart archive: " + response_.Url().ElidedString())); I see that KURL::ElidedString returns an empty string if the url is shorter than 1024. I would not have expected (maybe KURL::ElidedString is wrong?), but in any case, I think the developers would prefer to see a full URL in an error message.
https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/loader/DocumentLoader.cpp (right): https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/loader/DocumentLoader.cpp:450: "Malformed multipart archive: " + response_.Url().ElidedString())); On 2017/05/06 00:14:48, Łukasz A. wrote: > I see that KURL::ElidedString returns an empty string if the url is shorter than > 1024. Ooops. I think I misread the code - what I said above is incorrect. > I would not have expected (maybe KURL::ElidedString is wrong?), but in > any case, I think the developers would prefer to see a full URL in an error > message. Still - I wanted to check - do you think it is better to report elided string VS full string?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
I'd defer this review to lukasza@ and am happy to stamp it once he is happy with it. https://codereview.chromium.org/2866873002/diff/1/content/browser/download/mh... File content/browser/download/mhtml_generation_browsertest.cc (right): https://codereview.chromium.org/2866873002/diff/1/content/browser/download/mh... content/browser/download/mhtml_generation_browsertest.cc:137: NavigateToURL(shell(), net::FilePathToFileURL(params.file_path)); EXPECT_TRUE, otherwise failure to load, such as file not found, will not be detected.
The CQ bit was checked by carlosk@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Thanks. The mhtml_in_iframe.html layout test showed an inconsistency with the solution: the log was reporting a policy/security issue -- no MHTML allowed in iframes -- as a malformed MHTML. That check is enforced in ResourceFetcher::CreateArchive and returns the same null value we were interpreting in DocumentLoader::MaybeCreateArchive as "invalid MHTML". One option is to move the iframe check one level up, into DocumentLoader::MaybeCreateArchive. But reading ResourceFetcher's class doc it seems it is supposed to be responsible for security checks, what seems to be the case here. Another, is to move the console log into ResourceFetcher::CreateArchive. There is already another occurrence of console logging from ResourceFetcher::WarnUnusedPreloads. I went with this one as it seemed a safer bet. And as I was already changing that code I also included another log error for the policy error, now verified by the mhtml_in_iframe.html test. https://codereview.chromium.org/2866873002/diff/1/content/browser/download/mh... File content/browser/download/mhtml_generation_browsertest.cc (right): https://codereview.chromium.org/2866873002/diff/1/content/browser/download/mh... content/browser/download/mhtml_generation_browsertest.cc:137: NavigateToURL(shell(), net::FilePathToFileURL(params.file_path)); On 2017/05/08 17:16:58, nasko (out) wrote: > EXPECT_TRUE, otherwise failure to load, such as file not found, will not be > detected. Done. https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/loader/DocumentLoader.cpp (right): https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/loader/DocumentLoader.cpp:444: CommitData(0, 0); On 2017/05/06 00:14:48, Łukasz A. wrote: > On 2017/05/05 23:46:27, carlosk wrote: > > IIUC the local frame is only initialized when data is first committed. As for > > empty documents (precisely the case for invalid MHTML) this only happens right > > above I chose to have the console message reported here in FinishedLoading > > instead of MaybeCreateArchive where I initially thought I would add it. > > Thank you for the comment above. Unfortunately, I still fail to understand why > the console error is reported here and not in MaybeCreateArchive (in the > |!main_resource| case). It seems wrong (and I think the current CL does this) > to report the console error when there is a writer (i.e. we have a non-empty > document?) which I think (?) would happen when returning false from > MaybeCreateArchive in |!frame_| case. I was confused by all the checks for |frame_| not being null and I need it to be able to log. I assumed the CommitData call above would take care of the writer and the frame. Upon further looking into the code I now see the frame is supposed to be passed in upon initialization. Note that the final outcome in case of an invalid MHTML is an empty document so that CommitData and further |writer_| creation will happen anyway. But anyway, as explained before, this all moved to ResourceFetcher::CreateArchive. https://codereview.chromium.org/2866873002/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/loader/DocumentLoader.cpp:450: "Malformed multipart archive: " + response_.Url().ElidedString())); On 2017/05/06 00:42:47, Łukasz A. wrote: > On 2017/05/06 00:14:48, Łukasz A. wrote: > > I see that KURL::ElidedString returns an empty string if the url is shorter > than > > 1024. > > Ooops. I think I misread the code - what I said above is incorrect. > > > I would not have expected (maybe KURL::ElidedString is wrong?), but in > > any case, I think the developers would prefer to see a full URL in an error > > message. > > Still - I wanted to check - do you think it is better to report elided string VS > full string? This is me copy/pasting without fully understanding what I'm doing. The total lack of documentation on KURL doesn't help either. :/ You are right, it's detrimental to the developer to not see the full URL. Changed to GetString().
The CQ bit was checked by carlosk@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
lgtm - thanks!
carlosk@chromium.org changed reviewers: + japhet@chromium.org
japhet@: PTAL at ResourceFetcher.
I take it there's no .html file from which the .mhtml archive was generated (since it's intentionally malformed)? If so, lgtm. Optional: have the test start at a valid html page that calls testRunner.dumpAsText(), then redirects to the malformed mhtml archive, so that you don't have the spurious .png expectation. https://codereview.chromium.org/2866873002/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp (right): https://codereview.chromium.org/2866873002/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp:1162: "Attempt to load a multipart archive into an subframe: " + Attempt->Attempted ?
Thanks. As I'm unable to call any Javascript from the final MHTML page I was unable to create a HTML based test. So I'm keeping the PNG cruft for simplicity. https://codereview.chromium.org/2866873002/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp (right): https://codereview.chromium.org/2866873002/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp:1162: "Attempt to load a multipart archive into an subframe: " + On 2017/05/16 22:55:33, Nate Chapin wrote: > Attempt->Attempted ? Done.
carlosk@chromium.org changed reviewers: + dtrainor@chromium.org
dtrainor@: PTAL at mhtml_generation_browsertest.cc. Adding dtrainor@ for owner's review as nasko@ is out.
mhtml_generation_browsertest.cc lgtm
The CQ bit was checked by carlosk@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from lukasza@chromium.org, japhet@chromium.org Link to the patchset: https://codereview.chromium.org/2866873002/#ps80001 (title: "Textual changes.")
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by carlosk@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from lukasza@chromium.org, dtrainor@chromium.org, japhet@chromium.org Link to the patchset: https://codereview.chromium.org/2866873002/#ps100001 (title: "Fixed layout test expectation.")
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by carlosk@chromium.org
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 100001, "attempt_start_ts": 1495139100641490,
"parent_rev": "c85a0ce422acb66d6cc3c2824b5a01f9b36d0fcf", "commit_rev":
"656b9cae0b536ee2f9b8a2777f76ba4a4d775173"}
Message was sent while issue was closed.
Description was changed from ========== Validate generated MHTML in mhtml_generation_browsertest.cc tests. Attempts to load the generated MHTML file after creating it for all tests in mhtml_generation_browsertest.cc. This allows for validation of its contents being well formed by verifying that the newly added console message is not reported. Also simplifies the checking for the MHTML generation succeeding by asserting from inside the generation call instead of having checks for test failure in multiple tests. BUG=672313 ========== to ========== Validate generated MHTML in mhtml_generation_browsertest.cc tests. Attempts to load the generated MHTML file after creating it for all tests in mhtml_generation_browsertest.cc. This allows for validation of its contents being well formed by verifying that the newly added console message is not reported. Also simplifies the checking for the MHTML generation succeeding by asserting from inside the generation call instead of having checks for test failure in multiple tests. BUG=672313 Review-Url: https://codereview.chromium.org/2866873002 Cr-Commit-Position: refs/heads/master@{#472939} Committed: https://chromium.googlesource.com/chromium/src/+/656b9cae0b536ee2f9b8a2777f76... ==========
Message was sent while issue was closed.
Committed patchset #6 (id:100001) as https://chromium.googlesource.com/chromium/src/+/656b9cae0b536ee2f9b8a2777f76... |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
