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) { if (newLoad) {
browser.addEventListener("load", function onload() { Services.obs.addObserver(function advancedPaneLoadedObs(prefWin, topic, data) {
browser.removeEventListener("load", onload, true); if (prefWin != browser.contentWindow) {
return;
}
Services.obs.removeObserver(advancedPaneLoadedObs, "advanced-pane-loaded");
switchToPane(); switchToPane();
}, true); }, "advanced-pane-loaded", false);
} else { } else {
switchToPane(); switchToPane();
} }

View File

@ -71,6 +71,9 @@ var gAdvancedPane = {
#endif #endif
this.updateActualCacheSize(); this.updateActualCacheSize();
this.updateActualAppCacheSize(); 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 categories = document.getElementById("categories");
let item = categories.querySelector(".category[value=" + name + "]"); let item = categories.querySelector(".category[value=" + name + "]");
categories.selectedItem = item; categories.selectedItem = item;
gotoPref(name);
} }
function gotoPref(page) { function gotoPref(page) {

View File

@ -185,17 +185,17 @@ add_task(function* testOpenPreferences() {
let deferred = Promise.defer(); let deferred = Promise.defer();
Services.obs.addObserver(function observer(prefWin, topic, data) { Services.obs.addObserver(function observer(prefWin, topic, data) {
Services.obs.removeObserver(observer, "advanced-pane-loaded"); Services.obs.removeObserver(observer, "advanced-pane-loaded");
info("Advanced preference pane opened."); 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. prefWin.close();
let el = prefWin.document.getElementById("dataChoicesPanel"); info("Closed preferences pane.");
is_element_visible(el);
prefWin.close(); deferred.resolve();
info("Closed preferences pane."); });
deferred.resolve();
}, "advanced-pane-loaded", false); }, "advanced-pane-loaded", false);
info("Loading preferences pane."); info("Loading preferences pane.");

View File

@ -432,12 +432,12 @@ function is_hidden(aElement) {
function is_element_visible(aElement, aMsg) { function is_element_visible(aElement, aMsg) {
isnot(aElement, null, "Element should not be null, when checking visibility"); 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) { function is_element_hidden(aElement, aMsg) {
isnot(aElement, null, "Element should not be null, when checking visibility"); 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"));
} }
/** /**