Backed out changeset 120838b58449 (bug 1771867) Backed out changeset aea7ca0bbd17 (bug 1771867) Backed out changeset 2fe2afdee09d (bug 1771867) Backed out changeset 8bdb1f682d22 (bug 1771867) Backed out changeset a9f3158ed688 (bug 1771867) Backed out changeset 1177913e1edf (bug 1771867) Backed out changeset d33ccbbf407d (bug 1771867) Backed out changeset 110ac12e16f5 (bug 1771867) Backed out changeset 7f20525f5e94 (bug 1771867) Backed out changeset b3d65b1aa872 (bug 1771867) Backed out changeset 7cdf3cef2773 (bug 1771867) Backed out changeset 5090eae24a5c (bug 1771867) Backed out changeset f8a03d226c73 (bug 1771867)
65 lines
2.1 KiB
JavaScript
65 lines
2.1 KiB
JavaScript
/* 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();
|
|
});
|