//////////////////////////////////////////////////////////////////////
// set up and go
SimpleTest.waitForExplicitFinish();
// utilities for check functions
// black means the style wasn't applied, applied styles are green var green = 'rgb(0, 128, 0)'; var black = 'rgb(0, 0, 0)';
function getElementColorById(doc, id) {
return window.getComputedStyle(doc.contentDocument.getElementById(id)).color;
}
// We test both script and style execution by observing changes in computed styles
function checkDefaultSrcOnly() { var testframe = document.getElementById('testframe1');
ok(getElementColorById(testframe, 'unsafe-inline-script') === green, "Inline script should be allowed");
ok(getElementColorById(testframe, 'unsafe-eval-script') === green, "Eval should be allowed");
ok(getElementColorById(testframe, 'unsafe-inline-style') === green, "Inline style should be allowed");
function checkDefaultSrcWithScriptSrc() { var testframe = document.getElementById('testframe2');
ok(getElementColorById(testframe, 'unsafe-inline-script') === black, "Inline script should be blocked");
ok(getElementColorById(testframe, 'unsafe-eval-script') === black, "Eval should be blocked");
ok(getElementColorById(testframe, 'unsafe-inline-style') === green, "Inline style should be allowed");
function checkDefaultSrcWithStyleSrc() { var testframe = document.getElementById('testframe3');
ok(getElementColorById(testframe, 'unsafe-inline-script') === green, "Inline script should be allowed");
ok(getElementColorById(testframe, 'unsafe-eval-script') === green, "Eval should be allowed");
ok(getElementColorById(testframe, 'unsafe-inline-style') === black, "Inline style should be 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.