Bug 1800485 - Reuse nsMixedContentBlocker::IsPotentiallyTrustworthyOrigin to decide whether to preload assets r=necko-reviewers,valentin

To make test setups involing localhost easier

Differential Revision: https://phabricator.services.mozilla.com/D168065
This commit is contained in:
Manuel Bucher 2023-01-27 15:43:28 +00:00
parent 94ce0daaa8
commit e96a77794d
2 changed files with 12 additions and 1 deletions

View file

@ -13,6 +13,7 @@
#include "mozilla/CORSMode.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/nsCSPContext.h"
#include "mozilla/dom/nsMixedContentBlocker.h"
#include "mozilla/dom/ReferrerInfo.h"
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/ipc/BackgroundUtils.h"
@ -232,7 +233,7 @@ void EarlyHintPreloader::MaybeCreateAndInsertPreload(
}
// only preload secure context urls
if (!uri->SchemeIs("https")) {
if (!nsMixedContentBlocker::IsPotentiallyTrustworthyOrigin(uri)) {
return;
}

View file

@ -116,6 +116,16 @@ add_task(async function test_103_preload_mixed_content() {
);
});
// Same preload from localhost to localhost should preload
add_task(async function test_103_preload_localhost_to_localhost() {
await test_hint_preload(
"test_103_preload_localhost_to_localhost",
"http://127.0.0.1:8888",
"http://127.0.0.1:8888/browser/netwerk/test/browser/early_hint_pixel.sjs",
{ hinted: 1, normal: 0 }
);
});
// Relative url, correct file for requested uri
add_task(async function test_103_preload_only_file() {
await test_hint_preload(