blob: e87a37cfb95bca94bb8e775cfab22881b008ccf5 [file] [log] [blame]
<!DOCTYPE html>
<meta name="assert" content="This test checks that a layout() function correctly fails to parse on an insecure context." />
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/get-host-info.js"></script>
<style>
#test {
display: flex;
}
</style>
<div id="test"></div>
<script>
if (window.location.origin != get_host_info().UNAUTHENTICATED_ORIGIN) {
window.location = get_host_info().UNAUTHENTICATED_ORIGIN + window.location.pathname;
} else {
test(function() {
const element = document.getElementById('test');
assert_false(window.isSecureContext);
element.setAttribute('style', 'display: layout(fail)');
assert_equals(getComputedStyle(element).display, 'flex');
element.setAttribute('style', '');
element.style.display = 'layout(fail)';
assert_equals(getComputedStyle(element).display, 'flex');
element.style.display = '';
const styleSheet = document.styleSheets[0];
let idx = styleSheet.insertRule(
'#test { display: layout(fail); }',
styleSheet.cssRules.length);
assert_equals(getComputedStyle(element).display, 'flex');
styleSheet.deleteRule(idx);
idx = styleSheet.insertRule(
'#test { --display: layout(fail); display: var(--display); }',
styleSheet.cssRules.length);
assert_equals(getComputedStyle(element).display, 'inline');
styleSheet.deleteRule(idx);
});
}
</script>