Bug 1526822 - Fix headless screenshot that has redirects. r=mossop

The changes in bug 1507352 caused onLocationChange events to be ignored
when there was an http redirect. This caused the screenshot command to hang
since it never attached an event listener on the page it was redirected to.

Differential Revision: https://phabricator.services.mozilla.com/D22220

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brendan Dahl 2019-03-13 20:47:13 +00:00
Родитель 7fbff6df10
Коммит e78452ab54
5 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -41,8 +41,8 @@ function loadContentWindow(webNavigation, url, principal) {
if (flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) {
return;
}
// Ignore the initial about:blank
if (uri.spec != location.spec) {
// Ignore the initial about:blank, unless about:blank is requested
if (location.spec == "about:blank" && uri.spec != "about:blank") {
return;
}
let contentWindow = docShell.domWindow;

Просмотреть файл

@ -1,5 +1,8 @@
[DEFAULT]
support-files = headless.html
support-files =
headless.html
headless_redirect.html
headless_redirect.html^headers^
[test_headless_screenshot.html]
skip-if = toolkit == 'android'

Просмотреть файл

Просмотреть файл

@ -0,0 +1,2 @@
HTTP 302 Moved Temporarily
Location: headless.html

Просмотреть файл

@ -137,6 +137,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1378010
await testFileCreationNegative(["-url", "http://mochi.test:8888/chrome/browser/components/shell/test/headless.html", "-screenshot", "-window-size", "hello"], "screenshot.png");
await testFileCreationNegative(["-url", "http://mochi.test:8888/chrome/browser/components/shell/test/headless.html", "-screenshot", "-window-size", "800,"], "screenshot.png");
// Test when the requested URL redirects
await testFileCreationPositive(["-url", "http://mochi.test:8888/chrome/browser/components/shell/test/headless_redirect.html", "-screenshot", screenshotPath], screenshotPath);
SimpleTest.finish();
})();
</script>