code review: fixed sorting of 1st-party hostnames

This commit is contained in:
gorhill 2015-10-25 08:18:10 -04:00
parent e2bc299dc9
commit da6c7b8b5e
2 changed files with 12 additions and 7 deletions

View File

@ -78,8 +78,10 @@ window.addEventListener('unload', function() {
vAPI.app.onShutdown();
}
for ( var cleanup of cleanupTasks ) {
cleanup();
// IMPORTANT: cleanup tasks must be executed using LIFO order.
var i = cleanupTasks.length;
while ( i-- ) {
cleanupTasks[i]();
}
if ( cleanupTasks.length < expectedNumberOfCleanups ) {
@ -2865,17 +2867,18 @@ vAPI.toolbarButton = {
};
var shutdown = function() {
CustomizableUI.removeListener(CUIEvents);
CustomizableUI.destroyWidget(tbb.id);
for ( var win of winWatcher.getWindows() ) {
var panel = win.document.getElementById(tbb.viewId);
if ( panel !== null && panel.parentNode !== null ) {
panel.parentNode.removeChild(panel);
}
win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.removeSheet(styleURI, 1);
}
CustomizableUI.removeListener(CUIEvents);
CustomizableUI.destroyWidget(tbb.id);
vAPI.messaging.globalMessageManager.removeMessageListener(
location.host + ':closePopup',

View File

@ -126,10 +126,12 @@ var cachePopupData = function(data) {
continue;
}
domain = hostnameDict[hostname].domain;
prefix = hostname.slice(0, 0 - domain.length);
// Prefix with space char for 1st-party hostnames: this ensure these
// will come first in list.
if ( domain === popupData.pageDomain ) {
domain = '\u0020';
}
prefix = hostname.slice(0, 0 - domain.length);
hostnameToSortableTokenMap[hostname] = domain + prefix.split('.').reverse().join('.');
}
return popupData;