Bug 1774404 - Split up 103 preload tests even further to avoid intermittent timeouts r=necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D151709
This commit is contained in:
Manuel Bucher 2022-07-25 11:27:54 +00:00
Родитель 9e0b14ad60
Коммит fd701272db
4 изменённых файлов: 125 добавлений и 95 удалений

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

@ -80,10 +80,20 @@ support-files =
file_lnk.lnk
[browser_post_auth.js]
skip-if = socketprocess_networking # Bug 1772209
[browser_103_csp.js]
support-files =
early_hint_preload_test_helper.jsm
skip-if =
os == 'linux' && bits == 64 && !debug # Bug 1744028 and Bug 1746324
[browser_103_telemetry.js]
skip-if =
os == 'linux' && bits == 64 # Bug 1744028 and Bug 1746324
[browser_103_preload.js]
support-files =
early_hint_preload_test_helper.jsm
skip-if =
os == 'linux' && bits == 64 && !debug # Bug 1744028 and Bug 1746324
[browser_103_redirect.js]
support-files =
early_hint_preload_test_helper.jsm
skip-if =

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

@ -0,0 +1,64 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { lax_request_count_checking } = ChromeUtils.import(
"resource://testing-common/early_hint_preload_test_helper.jsm"
);
// csp header with "img-src: 'none'" only on main html response, don't show the image on the page
add_task(async function test_preload_csp_imgsrc_none() {
// reset the count
let headers = new Headers();
headers.append("X-Early-Hint-Count-Start", "");
await fetch(
"https://example.com/browser/netwerk/test/browser/early_hint_pixel_count.sjs",
{ headers }
);
let requestUrl =
"https://example.com/browser/netwerk/test/browser/103_preload_csp_imgsrc_none.html";
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: requestUrl,
waitForLoad: true,
},
async function(browser) {
let noImgLoaded = await SpecialPowers.spawn(browser, [], function() {
let loadInfo = content.performance.getEntriesByName(
"https://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs?1ac2a5e1-90c7-4171-b0f0-676f7d899af3"
);
return loadInfo.every(entry => entry.decodedBodySize === 0);
});
await Assert.ok(
noImgLoaded,
"test_preload_csp_imgsrc_none: Image dislpayed unexpectedly"
);
}
);
let gotRequestCount = await fetch(
"https://example.com/browser/netwerk/test/browser/early_hint_pixel_count.sjs"
).then(response => response.json());
let expectedRequestCount = { hinted: 1, normal: 0 };
// TODO: Switch to stricter counting method after fixing https://bugzilla.mozilla.org/show_bug.cgi?id=1753730#c11
await lax_request_count_checking(
"test_preload_csp_imgsrc_none",
gotRequestCount,
expectedRequestCount
);
/* stricter counting method:
await Assert.deepEqual(
gotRequestCount,
{ hinted: 1, normal: 0 },
"test_preload_csp_imgsrc_none: Unexpected amount of requests made"
);
*/
Services.cache2.clear();
});

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

@ -169,36 +169,6 @@ add_task(async function test_103_insecure_preload() {
);
});
// Early hint to redirect to same origin in secure context
add_task(async function test_103_redirect_same_origin() {
await test_hint_preload(
"test_103_redirect_same_origin",
"https://example.com",
"https://example.com/browser/netwerk/test/browser/early_hint_redirect.sjs?https://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 2, normal: 0 } // successful preload of redirect and resulting image
);
});
// Early hint to redirect to cross origin in secure context
add_task(async function test_103_redirect_cross_origin() {
await test_hint_preload(
"test_103_redirect_cross_origin",
"https://example.com",
"https://example.com/browser/netwerk/test/browser/early_hint_redirect.sjs?https://example.net/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 2, normal: 0 } // successful load of redirect in preload, but image loaded via normal load
);
});
// Early hint to redirect to cross origin in insecure context
add_task(async function test_103_redirect_insecure_cross_origin() {
await test_hint_preload(
"test_103_redirect_insecure_cross_origin",
"https://example.com",
"https://example.com/browser/netwerk/test/browser/early_hint_redirect.sjs?http://mochi.test:8888/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 1, normal: 1 }
);
});
// Cross origin preload from secure context to insecure context on same domain
add_task(async function test_103_preload_mixed_content() {
await test_hint_preload(
@ -209,16 +179,6 @@ add_task(async function test_103_preload_mixed_content() {
);
});
// Cross origin preload from secure context to redirected insecure context on same domain
add_task(async function test_103_preload_redirect_mixed_content() {
await test_hint_preload(
"test_103_preload_redirect_mixed_content",
"https://example.org",
"https://example.org/browser/netwerk/test/browser/early_hint_redirect.sjs?http://example.org/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 1, normal: 1 }
);
});
// Relative url, correct file for requested uri
add_task(async function test_103_preload_only_file() {
await test_hint_preload(
@ -229,61 +189,6 @@ add_task(async function test_103_preload_only_file() {
);
});
// csp header with "img-src: 'none'" only on main html response, don't show the image on the page
add_task(async function test_preload_csp_imgsrc_none() {
// reset the count
let headers = new Headers();
headers.append("X-Early-Hint-Count-Start", "");
await fetch(
"https://example.com/browser/netwerk/test/browser/early_hint_pixel_count.sjs",
{ headers }
);
let requestUrl =
"https://example.com/browser/netwerk/test/browser/103_preload_csp_imgsrc_none.html";
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: requestUrl,
waitForLoad: true,
},
async function(browser) {
let noImgLoaded = await SpecialPowers.spawn(browser, [], function() {
let loadInfo = content.performance.getEntriesByName(
"https://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs?1ac2a5e1-90c7-4171-b0f0-676f7d899af3"
);
return loadInfo.every(entry => entry.decodedBodySize === 0);
});
await Assert.ok(
noImgLoaded,
"test_preload_csp_imgsrc_none: Image dislpayed unexpectedly"
);
}
);
let gotRequestCount = await fetch(
"https://example.com/browser/netwerk/test/browser/early_hint_pixel_count.sjs"
).then(response => response.json());
let expectedRequestCount = { hinted: 1, normal: 0 };
// TODO: Switch to stricter counting method after fixing https://bugzilla.mozilla.org/show_bug.cgi?id=1753730#c11
await lax_request_count_checking(
"test_preload_csp_imgsrc_none",
gotRequestCount,
expectedRequestCount
);
/* stricter counting method:
await Assert.deepEqual(
gotRequestCount,
{ hinted: 1, normal: 0 },
"test_preload_csp_imgsrc_none: Unexpected amount of requests made"
);
*/
Services.cache2.clear();
});
// Test that preloads in iframes don't get triggered
add_task(async function test_103_iframe() {
// reset the count

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

@ -0,0 +1,51 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
Services.prefs.setBoolPref("network.early-hints.enabled", true);
const { test_hint_preload } = ChromeUtils.import(
"resource://testing-common/early_hint_preload_test_helper.jsm"
);
// Early hint to redirect to same origin in secure context
add_task(async function test_103_redirect_same_origin() {
await test_hint_preload(
"test_103_redirect_same_origin",
"https://example.com",
"https://example.com/browser/netwerk/test/browser/early_hint_redirect.sjs?https://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 2, normal: 0 } // successful preload of redirect and resulting image
);
});
// Early hint to redirect to cross origin in secure context
add_task(async function test_103_redirect_cross_origin() {
await test_hint_preload(
"test_103_redirect_cross_origin",
"https://example.com",
"https://example.com/browser/netwerk/test/browser/early_hint_redirect.sjs?https://example.net/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 2, normal: 0 } // successful load of redirect in preload, but image loaded via normal load
);
});
// Early hint to redirect to cross origin in insecure context
add_task(async function test_103_redirect_insecure_cross_origin() {
await test_hint_preload(
"test_103_redirect_insecure_cross_origin",
"https://example.com",
"https://example.com/browser/netwerk/test/browser/early_hint_redirect.sjs?http://mochi.test:8888/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 1, normal: 1 }
);
});
// Cross origin preload from secure context to redirected insecure context on same domain
add_task(async function test_103_preload_redirect_mixed_content() {
await test_hint_preload(
"test_103_preload_redirect_mixed_content",
"https://example.org",
"https://example.org/browser/netwerk/test/browser/early_hint_redirect.sjs?http://example.org/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 1, normal: 1 }
);
});