Bug 1646960 - imported patch ignore-blocked-preloads.diff r=bomsy

Differential Revision: https://phabricator.services.mozilla.com/D80856
This commit is contained in:
Jan Odvarko 2020-06-25 10:54:15 +00:00
Родитель e3dbdcd341
Коммит 6799964058
2 изменённых файлов: 18 добавлений и 5 удалений

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

@ -8,7 +8,7 @@
*/
add_task(async function() {
const { tab, monitor } = await initNetMonitor(CSP_URL, { requestCount: 3 });
const { tab, monitor } = await initNetMonitor(CSP_URL, { requestCount: 2 });
const { document, store, windowRequire } = monitor.panelWin;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
@ -18,11 +18,10 @@ add_task(async function() {
store.dispatch(Actions.batchEnable(false));
const wait = waitForNetworkEvents(monitor, 3);
const wait = waitForNetworkEvents(monitor, 2);
tab.linkedBrowser.reload();
await wait;
info("Waiting until the requests appear in netmonitor");
await wait;
// Ensure the attempt to load a JS file shows a blocked CSP error
verifyRequestItemTarget(
@ -32,7 +31,7 @@ add_task(async function() {
"GET",
EXAMPLE_URL + "js_websocket-worker-test.js",
{
transferred: "CSP Preload",
transferred: "CSP",
cause: { type: "script" },
type: "",
}

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

@ -326,6 +326,20 @@ NetworkObserver.prototype = {
return;
}
// Ignore preload requests to avoid duplicity request entries in
// the Network panel. If a preload fails (for whatever reason)
// then the platform kicks off another 'real' request.
const type = channel.loadInfo.internalContentPolicyType;
if (
type == Ci.nsIContentPolicy.TYPE_INTERNAL_SCRIPT_PRELOAD ||
type == Ci.nsIContentPolicy.TYPE_INTERNAL_MODULE_PRELOAD ||
type == Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_PRELOAD ||
type == Ci.nsIContentPolicy.TYPE_INTERNAL_STYLESHEET_PRELOAD ||
type == Ci.nsIContentPolicy.TYPE_INTERNAL_FONT_PRELOAD
) {
return;
}
const blockedCode = channel.loadInfo.requestBlockingReason;
this._httpResponseExaminer(subject, topic, blockedCode);
},