diff --git a/mozilla/caps/src/nsScriptSecurityManager.cpp b/mozilla/caps/src/nsScriptSecurityManager.cpp index 5665a57b683..fece22707cb 100644 --- a/mozilla/caps/src/nsScriptSecurityManager.cpp +++ b/mozilla/caps/src/nsScriptSecurityManager.cpp @@ -1595,6 +1595,14 @@ nsScriptSecurityManager::InitFromPrefs() NS_ASSERTION(NS_DOM_PROP_MAX == sizeof(domPropNames)/sizeof(domPropNames[0]), "mismatch in property name count"); + // The DOM property names had better be sorted for binary search to work +#ifdef DEBUG + for (unsigned i=1; i < sizeof(domPropNames)/sizeof(domPropNames[0]); i++) { + NS_ASSERTION(strcmp(domPropNames[i-1], domPropNames[i]) < 0, + "DOM properties are not properly sorted"); + } +#endif + nsresult rv; NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv); if (NS_FAILED(rv)) diff --git a/mozilla/dom/public/genPropNames.pl b/mozilla/dom/public/genPropNames.pl index 3e49484ed5e..67eb85dd6b3 100644 --- a/mozilla/dom/public/genPropNames.pl +++ b/mozilla/dom/public/genPropNames.pl @@ -68,14 +68,27 @@ print OUT <<'EOF'; #define NS_DOM_PROP_NAMES \ EOF +$last = ""; + while () { if (/NS_DOM_PROP_MAX/) { last; } + $save = $_; + s/,.*/", \\/; s/NS_DOM_PROP_/"/; s/_/./; - s/,.*/", \\/; - print OUT lc($_); + $_ = lc($_); + print OUT $_; + # Check order of names and make sure they are sorted. + # It's important we check after the subsitution of '.' for '_' + # since it's the sort order of the names we care about and '.' + # and '_' sort differently with respect to letters. + if ($last ne "" && ($last gt $_)) { + die "Name $lastsave and $save are out of order in nsDOMPropEnums.h.\n"; + } + $last = $_; + $lastsave = $save; } print OUT <