/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// On debug osx test machine, verify chaos mode takes slightly too long
requestLongerTimeout(2);
// - testName is just there to be printed during Asserts when failing // - asset is the asset type, see early_hint_asset_html.sjs for possible values // for the asset type fetch see test_hint_fetch due to timing issues // - variant: // - "normal": no early hints, expects one normal request expected // - "hinted": early hints sent, expects one hinted request // - "reload": early hints sent, resources non-cacheable, two early-hint requests expected // - "cached": same as reload, but resources are cacheable, so only one hinted network request expected
async function test_hint_asset(testName, asset, variant) { // reset the count
let headers = new Headers();
headers.append("X-Early-Hint-Count-Start", "");
await fetch( "http://example.com/browser/netwerk/test/browser/early_hint_pixel_count.sjs",
{ headers }
);
if (asset === "fetch") { // wait until the fetch is complete
await TestUtils.waitForCondition(_ => { return SpecialPowers.spawn(browser, [], _ => { return (
content.document.getElementsByTagName("h2")[0] != undefined &&
content.document.getElementsByTagName("h2")[0].textContent !== "Fetching..."// default text set by early_hint_asset_html.sjs
);
});
});
}
}
);
Services.obs.removeObserver(observer, "earlyhints-connectback");
let gotRequestCount = await fetch( "http://example.com/browser/netwerk/test/browser/early_hint_pixel_count.sjs"
).then(response => response.json()); if (
asset === "script" &&
variant === "cached" &&
numConnectBackRemaining === 1
) { // If the navigation cache is enabled // (dom.script_loader.experimental.navigation_cache), // the script can be cached in the per-process cache storage, and in that // case the channel isn't opened, and the "earlyhints-connectback" // notification isn't observed.
info(
`${testName} (${asset}+${variant}) in-memory-cached script's notification is skipped`
);
} else { Assert.equal(
numConnectBackRemaining, 0,
`${testName} (${asset}+${variant}) no remaining connect back expected`
);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.