зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1719124 Split PDF data into chunks to avoid hitting function call argument limit r=webdriver-reviewers,jgraham,whimboo
Differential Revision: https://phabricator.services.mozilla.com/D121363
This commit is contained in:
Родитель
ece46d2b64
Коммит
9a9fb72c85
|
@ -2912,9 +2912,20 @@ GeckoDriver.prototype.print = async function(cmd) {
|
|||
}
|
||||
|
||||
// Each UCS2 character has an upper byte of 0 and a lower byte matching
|
||||
// the binary data
|
||||
// the binary data. Splitting the file into chunks to avoid hitting the
|
||||
// internal argument length limit.
|
||||
const chunks = [];
|
||||
// This is the largest power of 2 smaller than MAX_ARGS_LENGTH defined in Spidermonkey
|
||||
const argLengthLimit = 262144;
|
||||
|
||||
for (let offset = 0; offset < bytes.length; offset += argLengthLimit) {
|
||||
const chunkData = bytes.subarray(offset, offset + argLengthLimit);
|
||||
|
||||
chunks.push(String.fromCharCode.apply(null, chunkData));
|
||||
}
|
||||
|
||||
return {
|
||||
value: btoa(String.fromCharCode.apply(null, bytes)),
|
||||
value: btoa(chunks.join("")),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,50 @@ def test_html_document(session, inline):
|
|||
# TODO: Test that the output is reasonable
|
||||
assert_pdf(pdf)
|
||||
|
||||
def test_large_html_document(session, inline):
|
||||
session.url = inline("<div id=\"root\"></div>")
|
||||
|
||||
session.execute_script(
|
||||
"""
|
||||
const root = document.getElementById("root");
|
||||
|
||||
const width = 400;
|
||||
const height = 600;
|
||||
const rects = [];
|
||||
|
||||
for (let x = 0; x < width; ++x) {
|
||||
for (let y = 0; y < height; ++y) {
|
||||
const colourHex = Math.floor(Math.random() * 0xffffff).toString(16);
|
||||
|
||||
rects.push(`<rect x="${x}" y="${y}" width="1" height="1" fill="#${colourHex}" />`);
|
||||
}
|
||||
}
|
||||
|
||||
const svg = `
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 ${width} ${height}"
|
||||
width="${width}"
|
||||
height="${height}"
|
||||
>
|
||||
${rects.join("")}
|
||||
</svg>
|
||||
`;
|
||||
|
||||
root.insertAdjacentHTML("beforeend", svg);
|
||||
"""
|
||||
)
|
||||
|
||||
response = do_print(session, {})
|
||||
value = assert_success(response)
|
||||
pdf = decodebytes(value.encode())
|
||||
|
||||
# This was added to test the fix for a bug in firefox where a PDF larger
|
||||
# than 500kb would cause an error. If the resulting PDF is smaller than that
|
||||
# it could pass incorrectly.
|
||||
assert len(pdf) > 500000
|
||||
assert_pdf(pdf)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("options", [{"orientation": 0},
|
||||
{"orientation": "foo"},
|
||||
|
|
Загрузка…
Ссылка в новой задаче