Bug 741047 - Implement opening in-content preferences to a given view. r=Gijs

--HG--
extra : rebase_source : cf486a6e5c8673d66a57e3b726b58073c694a338
This commit is contained in:
Jared Wein 2014-05-11 15:52:33 -04:00
parent d81e59e107
commit b297792021
5 changed files with 20 additions and 13 deletions

View File

@ -505,10 +505,13 @@ function openPreferences(paneID, extraArgs)
}
if (newLoad) {
browser.addEventListener("load", function onload() {
browser.removeEventListener("load", onload, true);
Services.obs.addObserver(function advancedPaneLoadedObs(prefWin, topic, data) {
if (prefWin != browser.contentWindow) {
return;
}
Services.obs.removeObserver(advancedPaneLoadedObs, "advanced-pane-loaded");
switchToPane();
}, true);
}, "advanced-pane-loaded", false);
} else {
switchToPane();
}

View File

@ -71,6 +71,9 @@ var gAdvancedPane = {
#endif
this.updateActualCacheSize();
this.updateActualAppCacheSize();
// Notify observers that the UI is now ready
Services.obs.notifyObservers(window, "advanced-pane-loaded", null);
},
/**

View File

@ -44,6 +44,7 @@ function selectCategory(name) {
let categories = document.getElementById("categories");
let item = categories.querySelector(".category[value=" + name + "]");
categories.selectedItem = item;
gotoPref(name);
}
function gotoPref(page) {

View File

@ -185,17 +185,17 @@ add_task(function* testOpenPreferences() {
let deferred = Promise.defer();
Services.obs.addObserver(function observer(prefWin, topic, data) {
Services.obs.removeObserver(observer, "advanced-pane-loaded");
info("Advanced preference pane opened.");
executeSoon(function() {
// We want this test to fail if the preferences pane changes.
let el = prefWin.document.getElementById("dataChoicesPanel");
is_element_visible(el);
// We want this test to fail if the preferences pane changes.
let el = prefWin.document.getElementById("dataChoicesPanel");
is_element_visible(el);
prefWin.close();
info("Closed preferences pane.");
prefWin.close();
info("Closed preferences pane.");
deferred.resolve();
deferred.resolve();
});
}, "advanced-pane-loaded", false);
info("Loading preferences pane.");

View File

@ -432,12 +432,12 @@ function is_hidden(aElement) {
function is_element_visible(aElement, aMsg) {
isnot(aElement, null, "Element should not be null, when checking visibility");
ok(!is_hidden(aElement), aMsg);
ok(!is_hidden(aElement), aMsg || (aElement + " should be visible"));
}
function is_element_hidden(aElement, aMsg) {
isnot(aElement, null, "Element should not be null, when checking visibility");
ok(is_hidden(aElement), aMsg);
ok(is_hidden(aElement), aMsg || (aElement + " should be hidden"));
}
/**