Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
function evaluateIfCondition(name, condition) {
const target = document.createElement("div");
target.style.cssText = `
--flag: 2px;
--result: if(${condition}: 1px; else: 2px);
width: var(--result);
`;
document.body.appendChild(target);
println(`${name} result: ${getComputedStyle(target).width}`);
target.remove();
}
function evaluateSharedMediaEnvironment(condition) {
const targets = [];
for (let i = 0; i < 2; ++i) {
const target = document.createElement("div");
target.style.cssText = `
--result: ${condition};
width: var(--result);
`;
targets.push(target);
document.body.appendChild(target);
}
internals.updateStyle();
println(`shared results: ${targets.map(target => getComputedStyle(target).width).join(", ")}`);
targets.forEach(target => target.remove());
}
test(() => {
evaluateIfCondition("media", "media((width >= 0px))");
evaluateIfCondition("supports", "supports((display: grid))");
evaluateIfCondition("style", "style(--flag > 1px)");
evaluateSharedMediaEnvironment("1px");
evaluateSharedMediaEnvironment("if(media((width >= 0px)): 1px; else: 2px)");
});
</script>