Bug 571598: Allow XUL documents loaded in about urls to persist attributes. r=bz

This commit is contained in:
Dave Townsend 2010-07-29 22:08:50 -07:00
Родитель 383dac2f4e
Коммит 792bccf3f4
3 изменённых файлов: 69 добавлений и 0 удалений

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

@ -90,6 +90,7 @@
#include "nsILocale.h"
#include "nsILocaleService.h"
#include "nsIConsoleService.h"
#include "nsEscape.h"
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -335,6 +336,20 @@ nsXULContentUtils::MakeElementURI(nsIDocument* aDocument,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURL> mutableURL(do_QueryInterface(docURIClone));
if (!mutableURL) {
nsCString uri;
rv = docURL->GetSpec(aURI);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString ref;
NS_EscapeURL(NS_ConvertUTF16toUTF8(aElementID), esc_FilePath | esc_AlwaysCopy, ref);
aURI.Append('#');
aURI.Append(ref);
return NS_OK;
}
NS_ENSURE_TRUE(mutableURL, NS_ERROR_NOT_AVAILABLE);
rv = mutableURL->SetRef(NS_ConvertUTF16toUTF8(aElementID));
@ -381,6 +396,19 @@ nsXULContentUtils::MakeElementID(nsIDocument* aDocument,
url->GetRef(ref);
CopyUTF8toUTF16(ref, aElementID);
} else {
const char* start = aURI.BeginReading();
const char* end = aURI.EndReading();
const char* chr = end;
while (--chr >= start) {
if (*chr == '#') {
nsDependentCSubstring ref = Substring(chr + 1, end);
nsCAutoString unescaped;
CopyUTF8toUTF16(NS_UnescapeURL(ref, esc_FilePath, unescaped), aElementID);
return NS_OK;
}
}
aElementID.Truncate();
}

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

@ -50,6 +50,7 @@ _TEST_FILES = \
browser_bug562890.js \
browser_bug562899.js \
browser_bug562992.js \
browser_bug567137.js \
browser_bug572561.js \
browser_dragdrop.js \
browser_searching.js \

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

@ -0,0 +1,40 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test that the selected category is persisted across loads of the manager
function test() {
waitForExplicitFinish();
open_manager(null, function(aWindow) {
let utils = new CategoryUtilities(aWindow);
// Open the plugins category
utils.openType("plugin", function() {
// Re-open the manager
close_manager(aWindow, function() {
open_manager(null, function(aWindow) {
utils = new CategoryUtilities(aWindow);
is(utils.selectedCategory, "plugin", "Should have shown the plugins category");
// Open the extensions category
utils.openType("extension", function() {
// Re-open the manager
close_manager(aWindow, function() {
open_manager(null, function(aWindow) {
utils = new CategoryUtilities(aWindow);
is(utils.selectedCategory, "extension", "Should have shown the extensions category");
close_manager(aWindow, finish);
});
});
});
});
});
});
});
}