forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1774404 - Split up 103 preload tests even further to avoid interm…
…ittent timeouts r=necko-reviewers,dragana Differential Revision: https://phabricator.services.mozilla.com/D151709
- Loading branch information
Showing
4 changed files
with
125 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } | ||
); | ||
}); |