Bug 477564 - Session restore hangs/not responding with high CPU on large form with many checkboxes r=dietrich

Cap the maximum number of XPATHs generated
This commit is contained in:
Simon Bünzli 2009-07-24 11:39:22 -04:00
Родитель b5922d32c2
Коммит 8a61a3333a
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -1477,8 +1477,15 @@ SessionStoreService.prototype = {
if (!node)
return null;
const MAX_GENERATED_XPATHS = 100;
let generatedCount = 0;
let data = {};
do {
// Only generate a limited number of XPath expressions for perf reasons (cf. bug 477564)
if (!node.id && ++generatedCount > MAX_GENERATED_XPATHS)
continue;
let id = node.id ? "#" + node.id : XPathHelper.generate(node);
if (node instanceof Ci.nsIDOMHTMLInputElement) {
if (node.type != "file")