// test file's CSP meta tags shouldn't overwrite same-origin iframe's CSP meta tags
async function testBlocked() {
info("testBlocked");
let sameOriginMetaFrame = document.getElementById("sameOriginMetaFrame");
let onFrameLoad = new Promise(resolve => {
sameOriginMetaFrame.addEventListener('load', resolve, {once: true});
});
sameOriginMetaFrame.src = 'file_bug1764343.html';
await onFrameLoad;
let doc = sameOriginMetaFrame.contentDocument;
doc.open();
doc.write(NEW_HTML);
let bgcolor = window.getComputedStyle(doc.body).getPropertyValue("background-color");
is(bgcolor, "rgba(0, 0, 0, 0)", "inital background value in FF should be 'transparent'");
let img = doc.getElementById("testInlineImage");
let onImgError = new Promise(resolve => { img.addEventListener('error', resolve, {once: true});
}); img.src = "//mochi.test:8888/tests/image/test/mochitest/blue.png";
await onImgError;
is(img.complete, false, "image should not be loaded");
// Make sure that CSP policy can further restrict (no 'nonce-b'), but not weak (adding 'nonce-c' or 'nonce-d')
is(doc.a, true, "doc.a should be true (script 'nonce-a' allowed)");
is(doc.b, undefined, "doc.b should be undefined (script 'nonce-b' blocked)");
is(doc.c, undefined, "doc.c should be undefined (script 'nonce-c' blocked)");
is(doc.d, undefined, "doc.d should be undefined (script 'nonce-d' blocked)");
}
// test file's CSP meta tags should apply to about blank iframe's CSP meta tags
async function testNotBlocked() {
info("testNotBlocked");
let aboutBlankMetaFrame = document.getElementById("aboutBlankMetaFrame");
let onFrameLoad = new Promise(resolve => {
aboutBlankMetaFrame.addEventListener('load', resolve, {once: true});
});
aboutBlankMetaFrame.src = 'about:blank';
await onFrameLoad;
let doc = aboutBlankMetaFrame.contentDocument;
doc.open();
doc.write(NEW_HTML);
let bgcolor = window.getComputedStyle(doc.body).getPropertyValue("background-color");
is(bgcolor, "rgb(255, 0, 0)", "background value should be updated to red");
let img = doc.getElementById("testInlineImage");
let onImgLoad = new Promise(resolve => { img.addEventListener('load', resolve, {once: true});
}); img.src = "//mochi.test:8888/tests/image/test/mochitest/blue.png";
await onImgLoad;
is(img.complete, true, "image should be loaded");
// New HTML contains 'nonce-a/c/d' and no CSP in about:blank.
// (Can not weaken parent with 'nonce-d')
is(doc.a, true, "doc.a should be true (script 'nonce-a' allowed)");
is(doc.b, undefined, "doc.b should be undefined (script 'nonce-b' blocked)");
is(doc.c, true, "doc.c should be true (script 'nonce-c' allowed)");
is(doc.d, undefined, "doc.d should be true (script 'nonce-d' blocked)");
}
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.