fune/toolkit/components/gfx/content/gfxFrameScript.js
Kris Maglione a259026c9d Bug 1456035: Part 4 - Convert callers of XPCOMUtils.generateQI to ChromeUtils.generateQI. r=mccr8
This also removes any redundant Ci.nsISupports elements in the interface
lists.

This was done using the following script:

acecb401b7/processors/chromeutils-generateQI.jsm

MozReview-Commit-ID: AIx10P8GpZY

--HG--
extra : rebase_source : a29c07530586dc18ba040f19215475ac20fcfb3b
2018-04-22 20:55:06 -07:00

64 lines
1.7 KiB
JavaScript

/* eslint-env mozilla/frame-script */
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const gfxFrameScript = {
domUtils: null,
init() {
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
this.domUtils = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
webNav.loadURI("chrome://gfxsanity/content/sanitytest.html",
Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
null, null, null);
},
handleEvent(aEvent) {
switch (aEvent.type) {
case "MozAfterPaint":
sendAsyncMessage("gfxSanity:ContentLoaded");
removeEventListener("MozAfterPaint", this);
break;
}
},
isSanityTest(aUri) {
if (!aUri) {
return false;
}
return aUri.endsWith("/sanitytest.html");
},
onStateChange(webProgress, req, flags, status) {
if (webProgress.isTopLevel &&
(flags & Ci.nsIWebProgressListener.STATE_STOP) &&
this.isSanityTest(req.name)) {
webProgress.removeProgressListener(this);
// If no paint is pending, then the test already painted
if (this.domUtils.isMozAfterPaintPending) {
addEventListener("MozAfterPaint", this);
} else {
sendAsyncMessage("gfxSanity:ContentLoaded");
}
}
},
// Needed to support web progress listener
QueryInterface: ChromeUtils.generateQI([
Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference,
Ci.nsIObserver,
]),
};
gfxFrameScript.init();