chore(screenshotter): Improve screenshotter for Safari (#3015)

* Fix when Docker returns IPv4 and IPv6 addresses

* Ensure images load before screenshotting

* Fix bugs from review

* Update test/screenshotter/test.html

Co-authored-by: ylemkimon <y@ylem.kim>
This commit is contained in:
Erik Demaine
2021-05-17 18:45:11 -04:00
committed by GitHub
parent 2658e26f64
commit 93b56cfb0b
2 changed files with 19 additions and 4 deletions

View File

@@ -172,7 +172,8 @@ if (!seleniumURL && opts.container) {
guessDockerIPs();
}
seleniumPort = cmd("docker", "port", opts.container, seleniumPort);
seleniumPort = seleniumPort.replace(/^.*:/, "");
// Docker can output two lines, such as "0.0.0.0:49156\n:::49156"
seleniumPort = seleniumPort.replace(/[^]*:([0-9]+)[^]*/, "$1");
}
if (!seleniumURL && seleniumIP) {
seleniumURL = "http://" + seleniumIP + ":" + seleniumPort + "/wd/hub";
@@ -493,7 +494,7 @@ function takeScreenshot(key) {
function loadFonts() {
driver.executeAsyncScript(
"var callback = arguments[arguments.length - 1]; " +
"load_fonts(callback);")
"load_fonts_and_images(callback);")
.then(waitThenScreenshot);
}