Bug 1244259 - wait for SafeBrowsing to have added MozEntries in initial runs of talos perf testing, r?jmaher,gcp
MozReview-Commit-ID: Dvs5RQyhfpy
--- a/testing/talos/talos/getInfo.html
+++ b/testing/talos/talos/getInfo.html
@@ -11,13 +11,12 @@
</head>
<body onload="
dumpLog('__metrics\tScreen width/height:' + screen.width + '/' + screen.height + '\n\tcolorDepth:' + screen.colorDepth + '\n');
dumpLog('\tBrowser inner width/height: ' + window.innerWidth + '/' + window.innerHeight + '\n');
//JMAHER: this is temporarily commented out because this hangs the fennec browser
// dumpLog('\tBrowser outer width/height: ' + window.outerWidth + '/' + window.outerHeight);
dumpLog('__metrics\n');
- goQuitApplication();
- window.close();
+ goQuitApplication(true);
">
</body>
</html>
--- a/testing/talos/talos/talos-powers/chrome/talos-powers-content.js
+++ b/testing/talos/talos/talos-powers/chrome/talos-powers-content.js
@@ -4,21 +4,21 @@
var { interfaces: Ci } = Components;
/**
* Content that wants to quit the whole session should
* fire the TalosQuitApplication custom event. This will
* attempt to force-quit the browser.
*/
-addEventListener("TalosQuitApplication", () => {
+addEventListener("TalosQuitApplication", event => {
// If we're loaded in a low-priority background process, like
// the background page thumbnailer, then we shouldn't be allowed
// to quit the whole application. This is a workaround until
// bug 1164459 is fixed.
let priority = docShell.QueryInterface(Ci.nsIDocumentLoader)
.loadGroup
.QueryInterface(Ci.nsISupportsPriority)
.priority;
if (priority != Ci.nsISupportsPriority.PRIORITY_LOWEST) {
- sendAsyncMessage("Talos:ForceQuit");
+ sendAsyncMessage("Talos:ForceQuit", event.detail);
}
});
--- a/testing/talos/talos/talos-powers/components/TalosPowersService.js
+++ b/testing/talos/talos/talos-powers/components/TalosPowersService.js
@@ -48,21 +48,33 @@ TalosPowersService.prototype = {
inject() {
Services.mm.loadFrameScript(FRAME_SCRIPT, true);
Services.mm.addMessageListener("Talos:ForceQuit", this);
},
receiveMessage(message) {
if (message.name == "Talos:ForceQuit") {
- this.forceQuit();
+ this.forceQuit(message.data);
}
},
- forceQuit() {
+ forceQuit(messageData) {
+ if (messageData && messageData.waitForSafeBrowsing) {
+ let SafeBrowsing = Cu.import("resource://gre/modules/SafeBrowsing.jsm", {}).SafeBrowsing;
+
+ let whenDone = () => {
+ this.forceQuit();
+ };
+ SafeBrowsing.addMozEntriesFinishedPromise.then(whenDone, whenDone);
+ // Speed things up in case nobody else called this:
+ SafeBrowsing.init();
+ return;
+ }
+
let enumerator = Services.wm.getEnumerator(null);
while (enumerator.hasMoreElements()) {
let domWindow = enumerator.getNext();
domWindow.close();
}
try {
Services.startup.quit(Services.startup.eForceQuit);
--- a/testing/talos/talos/tests/quit.js
+++ b/testing/talos/talos/tests/quit.js
@@ -63,52 +63,73 @@ function canQuitApplication()
}
catch (ex)
{
}
os.notifyObservers(null, "quit-application-granted", null);
return true;
}
-function goQuitApplication()
+function goQuitApplication(waitForSafeBrowsing)
{
const privs = 'UniversalPreferencesRead UniversalPreferencesWrite ' +
'UniversalXPConnect';
try
{
netscape.security.PrivilegeManager.enablePrivilege(privs);
}
catch(ex)
{
throw('goQuitApplication: privilege failure ' + ex);
}
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
+ if (xulRuntime.processType == xulRuntime.PROCESS_TYPE_CONTENT) {
+ // If we're running in a remote browser, emit an event for a
+ // frame script to pick up to quit the whole browser.
+ var event = new CustomEvent("TalosQuitApplication", {bubbles:true, detail: {waitForSafeBrowsing}});
+ document.dispatchEvent(event);
+ return;
+ }
+
+ if (waitForSafeBrowsing) {
+ var SafeBrowsing = Components.utils.
+ import("resource://gre/modules/SafeBrowsing.jsm", {}).SafeBrowsing;
+
+ var whenDone = () => {
+ goQuitApplication(false);
+ };
+
+ SafeBrowsing.addMozEntriesFinishedPromise.then(whenDone, whenDone);
+ // Speed things up in case nobody else called this:
+ SafeBrowsing.init();
+ return false;
+ }
+
if (!canQuitApplication())
{
return false;
}
const kAppStartup = '@mozilla.org/toolkit/app-startup;1';
const kAppShell = '@mozilla.org/appshell/appShellService;1';
var appService;
- var forceQuit;
if (kAppStartup in Components.classes)
{
appService = Components.classes[kAppStartup].
getService(Components.interfaces.nsIAppStartup);
- forceQuit = Components.interfaces.nsIAppStartup.eForceQuit;
}
else if (kAppShell in Components.classes)
{
appService = Components.classes[kAppShell].
getService(Components.interfaces.nsIAppShellService);
- forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
}
else
{
throw 'goQuitApplication: no AppStartup/appShell';
}
var windowManager = Components.
classes['@mozilla.org/appshell/window-mediator;1'].getService();
@@ -125,21 +146,17 @@ function goQuitApplication()
{
return false;
}
domWindow.close();
}
try
{
- appService.quit(forceQuit);
- // If we're running in a remote browser, emit an event for a
- // frame script to pick up to quit the whole browser.
- var event = new CustomEvent("TalosQuitApplication", {bubbles:true});
- document.dispatchEvent(event);
+ appService.quit(appService.eForceQuit);
}
catch(ex)
{
throw('goQuitApplication: ' + ex);
}
return true;
}
--- a/toolkit/components/url-classifier/SafeBrowsing.jsm
+++ b/toolkit/components/url-classifier/SafeBrowsing.jsm
@@ -327,25 +327,43 @@ this.SafeBrowsing = {
let db = Cc["@mozilla.org/url-classifier/dbservice;1"].
getService(Ci.nsIUrlClassifierDBService);
// nsIUrlClassifierUpdateObserver
let dummyListener = {
updateUrlRequested: function() { },
streamFinished: function() { },
- updateError: function() { },
- updateSuccess: function() { }
+ // We notify observers when we're done in order to be able to make perf
+ // test results more consistent
+ updateError: function() {
+ Services.obs.notifyObservers(db, "mozentries-update-finished", "error");
+ },
+ updateSuccess: function() {
+ Services.obs.notifyObservers(db, "mozentries-update-finished", "success");
+ }
};
try {
let tables = "test-malware-simple,test-phish-simple,test-unwanted-simple,test-track-simple,test-trackwhite-simple,test-forbid-simple";
db.beginUpdate(dummyListener, tables, "");
db.beginStream("", "");
db.updateStream(update);
db.finishStream();
db.finishUpdate();
} catch(ex) {
// beginUpdate will throw harmlessly if there's an existing update in progress, ignore failures.
log("addMozEntries failed!", ex);
+ Services.obs.notifyObservers(db, "mozentries-update-finished", "exception");
}
},
+
+ addMozEntriesFinishedPromise: new Promise(resolve => {
+ let finished = (subject, topic, data) => {
+ Services.obs.removeObserver(finished, "mozentries-update-finished");
+ if (data == "error") {
+ Cu.reportError("addMozEntries failed to update the db!");
+ }
+ resolve();
+ };
+ Services.obs.addObserver(finished, "mozentries-update-finished", false);
+ }),
};