chromium-bidi
chromium-bidi copied to clipboard
Implement `browsingContext.print` (print to PDF)
Implement Add browsingContext.print command by jgraham · Pull Request #363 · w3c/webdriver-bidi.
CDP method: Page.printToPDF.
Spec: https://w3c.github.io/webdriver-bidi/#command-browsingContext-print
Tracking
- [x] Basic implementation
- [x] ~CDP does not have a
shrinkToFitequivalent (c.f. comment)~ it is calledpreferCSSPageSize - [x] Implement
shrinkToFit - [x] #577
- [x] Issue 1430696: CDP
Page.printToPDFcrashes on tiny pages - [x] CDP
Page.printToPDFthrows invalid parameters exception on pages with tiny dimensions (e.g. 1x1 pixel) (cont.) - [x] (optional) Add E2E test: print to pdf -> open it in the browser (either
application/pdforfile:///) -> take screenshot -> compare golden: https://chat.google.com/room/AAAAw7biRSY/UdLyoDHCNgM. Or similar: https://github.com/GoogleChromeLabs/chromium-bidi/pull/912 and #914 - [ ] Fix WPT tests
/webdriver/tests/bidi/browsing_context/print/
@sadym-chromium shrinkToFit does not have a CDP equivalent. What do we do in these situations? File a FR against CDP?
What do we do in these situations?
In general there are 3 options:
- Implement in CDP.
- Implement on top of existing CDP functionality + some extra logic.
- Roll back the spec part.
- Implement in CDP.
How can we do so? This was also suggested by @whimboo on https://github.com/web-platform-tests/wpt/pull/38931#issuecomment-1468350079
Could you give me a pointer to the CDP repo?
- Implement in CDP.
How can we do so? This was also suggested by @whimboo on web-platform-tests/wpt#38931 (comment)
Could you give me a pointer to the CDP repo?
sent you PM
@thiagowfx FYI there are bunch of new failing tests in WPT: https://github.com/GoogleChromeLabs/chromium-bidi/pull/625/files
Test fails:
bidiMapper:mapperDebug:CDP sent ▸ {
"id": 11,
"method": "Page.navigate",
"params": {
"url": "data:application/pdf;base64,JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9DcmVhdG9yIChDaHJvbWl1bSkKL1Byb2R1Y2VyIChTa2lhL1BERiBtMTE2KQovQ3JlYXRpb25EYXRlIChEOjIwMjMwNjEyMjEwNjM4KzAwJzAwJykKL01vZERhdGUgKEQ6MjAyMzA2MTIyMTA2MzgrMDAnMDAnKT4+CmVuZG9iagozIDAgb2JqCjw8L0xlbmd0aCAwPj4gc3RyZWFtCgplbmRzdHJlYW0KZW5kb2JqCjIgMCBvYmoKPDwvVHlwZSAvUGFnZQovUmVzb3VyY2VzIDw8L1Byb2NTZXQgWy9QREYgL1RleHQgL0ltYWdlQiAvSW1hZ2VDIC9JbWFnZUldPj4KL01lZGlhQm94IFswIDAgMjI2NzcuMTE5IDE3MDA4LjA4XQovQ29udGVudHMgMyAwIFIKL1N0cnVjdFBhcmVudHMgMAovUGFyZW50IDQgMCBSPj4KZW5kb2JqCjQgMCBvYmoKPDwvVHlwZSAvUGFnZXMKL0NvdW50IDEKL0tpZHMgWzIgMCBSXT4+CmVuZG9iago1IDAgb2JqCjw8L1R5cGUgL0NhdGFsb2cKL1BhZ2VzIDQgMCBSPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAxNSAwMDAwMCBuIAowMDAwMDAwMjAyIDAwMDAwIG4gCjAwMDAwMDAxNTUgMDAwMDAgbiAKMDAwMDAwMDM3NiAwMDAwMCBuIAowMDAwMDAwNDMxIDAwMDAwIG4gCnRyYWlsZXIKPDwvU2l6ZSA2Ci9Sb290IDUgMCBSCi9JbmZvIDEgMCBSPj4Kc3RhcnR4cmVmCjQ3OAolJUVPRgo=",
"frameId": "A45327FAB30B9B82E7B22502D73B7520"
},
"sessionId": "9371436D303A35CD0D25C2B137D48C64"
} +0ms
bidiMapper:mapperDebug:CDP received ◂ {
"id": 11,
"result": {
"frameId": "A45327FAB30B9B82E7B22502D73B7520",
"loaderId": "4C7ADCE66AA34C1EE27626ABB37C38EA",
"errorText": "net::ERR_ABORTED"
},
"sessionId": "9371436D303A35CD0D25C2B137D48C64"
} +0ms
FAILED [100%]
Accessing the URL manually works though.
When will this feature be released? And will this support generating pdf files from large html files?