<!DOCTYPE html>
<script src="../resources/runner.js"></script>
<script src="./resources/utils.js"></script>
<script>
const DECLARATIONS = 400;
const TRAILING_TOKENS_PER_DECLARATION = 1000;
// Makes many (invalid) width-declarations where {} appears at the start of
// the the value, with lots of trailing tokens after.
function makeStyle() {
let rules = [];
for (let i = 0; i < DECLARATIONS; i++) {
rules.push(`width: {}
${[...Array(TRAILING_TOKENS_PER_DECLARATION).keys()]
.map(x => `foo${x}`).join(' ')}
;`);
}
return `
div {
${rules.join('\n')}
}
`
}
let globalCounter = 0;
const stylesheetText = makeStyle();
let stylesheet = new CSSStyleSheet();
PerfTestRunner.measureTime({
description: 'Many invalid width declarations with braces at the start',
run: () => {
// This is a parsing test: we don't care about style recalc.
// We append a rule based on globalCounter to prevent caching
// on the stylesheet string.
stylesheet.replaceSync(stylesheetText + `\n .b${globalCounter++} {}`);
}
});
</script>