Commit 3ef27120 authored by Jérome Perrin's avatar Jérome Perrin

ui_test_core: fix verifyImageMatchSnapshot for pages using css fonts

We are using html2canvas to render the page in a canvas element, but
because the canvas element was created in the selenium runner frame (and
not the tested frame), if some extra css fonts were loaded in the custom
page they did not apply.

To make the snapshot use proper fonts, we create the canvas in the
tested page.
parent 949f4a95
......@@ -299,12 +299,19 @@ Selenium.prototype.doVerifyImageMatchSnapshot = (
/** @type {Promise<HTMLCanvasElement>} */
var canvasPromise;
/** @type {HTMLElement} */
var element = selenium.browserbot.findElement(locator);
if (element.nodeName == 'CANVAS' /* instanceof HTMLCanvasElement XXX ? */) {
canvasPromise = Promise.resolve(element);
} else {
canvasPromise = html2canvas(element);
// create a canvas in the same document, so that if this document has loaded
// extra fonts they are also available.
// As suggested on https://github.com/niklasvh/html2canvas/issues/1772
var destinationCanvas = element.ownerDocument.createElement("canvas");
destinationCanvas.width = element.scrollWidth;
destinationCanvas.height = element.scrollHeight;
canvasPromise = html2canvas(element, { canvas: destinationCanvas });
}
return wrapPromise(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment