Bug 784759 - Delay database initialization until after first page load. r=mfinkle

This commit is contained in:
Wes Johnston 2014-01-28 21:58:12 -08:00
parent a81fc18792
commit b9e1724d63
4 changed files with 26 additions and 6 deletions

View File

@ -90,6 +90,16 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
}
}
protected void blockForGeckoDelayedStartup() {
try {
Actions.EventExpecter geckoReadyExpector = mActions.expectGeckoEvent("Gecko:DelayedStartup");
geckoReadyExpector.blockForEvent();
geckoReadyExpector.unregisterListener();
} catch (Exception e) {
mAsserter.dumpLog("Exception in blockForGeckoDelayedStartup", e);
}
}
static {
try {
mLauncherActivityClass = (Class<Activity>)Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);

View File

@ -29,7 +29,7 @@ public class testFormHistory extends BaseTest {
ContentValues[] cvs = new ContentValues[1];
cvs[0] = new ContentValues();
blockForGeckoReady();
blockForGeckoDelayedStartup();
Uri formHistoryUri;
Uri insertUri;

View File

@ -30,7 +30,7 @@ public class testPasswordProvider extends BaseTest {
ContentValues[] cvs = new ContentValues[1];
cvs[0] = new ContentValues();
blockForGeckoReady();
blockForGeckoDelayedStartup();
cvs[0].put("hostname", "http://www.example.com");
cvs[0].put("httpRealm", "http://www.example.com");

View File

@ -423,6 +423,8 @@ var BrowserApp = {
event.initEvent("UIReady", true, false);
window.dispatchEvent(event);
Services.obs.addObserver(this, "browser-delayed-startup-finished", false);
if (this._startupStatus)
this.onAppUpdated();
@ -694,10 +696,6 @@ var BrowserApp = {
},
onAppUpdated: function() {
// initialize the form history and passwords databases on upgrades
Services.obs.notifyObservers(null, "FormHistory:Init", "");
Services.obs.notifyObservers(null, "Passwords:Init", "");
// Migrate user-set "plugins.click_to_play" pref. See bug 884694.
// Because the default value is true, a user-set pref means that the pref was set to false.
if (Services.prefs.prefHasUserValue("plugins.click_to_play")) {
@ -1614,6 +1612,10 @@ var BrowserApp = {
Services.prefs.setCharPref("general.useragent.locale", aData);
break;
case "browser-delayed-startup-finished":
this._delayedStartup();
break;
default:
dump('BrowserApp.observe: unexpected topic "' + aTopic + '"\n');
break;
@ -1621,6 +1623,14 @@ var BrowserApp = {
}
},
_delayedStartup: function() {
// initialize the form history and passwords databases on upgrades
if (this._startupStatus) {
Services.obs.notifyObservers(null, "FormHistory:Init", "");
Services.obs.notifyObservers(null, "Passwords:Init", "");
}
},
get defaultBrowserWidth() {
delete this.defaultBrowserWidth;
let width = Services.prefs.getIntPref("browser.viewport.desktopWidth");