mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1178823. Part 2 - Load sanity test in remote XUL browser. r=mconley
This commit is contained in:
parent
e7fc965d5b
commit
a1081fe520
@ -125,6 +125,11 @@ let listener = {
|
||||
win: null,
|
||||
utils: null,
|
||||
canvas: null,
|
||||
mm: null,
|
||||
|
||||
messages: [
|
||||
"gfxSanity:ContentLoaded",
|
||||
],
|
||||
|
||||
scheduleTest: function(win) {
|
||||
this.win = win;
|
||||
@ -146,6 +151,36 @@ let listener = {
|
||||
this.endTest();
|
||||
},
|
||||
|
||||
receiveMessage(message) {
|
||||
let data = message.data;
|
||||
switch (message.name) {
|
||||
case "gfxSanity:ContentLoaded":
|
||||
this.runSanityTest();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
onWindowLoaded: function() {
|
||||
let browser = this.win.document.createElementNS(XUL_NS, "browser");
|
||||
browser.setAttribute("type", "content");
|
||||
|
||||
let remoteBrowser = Services.appinfo.browserTabsRemoteAutostart;
|
||||
browser.setAttribute("remote", remoteBrowser);
|
||||
|
||||
browser.style.width = PAGE_WIDTH + "px";
|
||||
browser.style.height = PAGE_HEIGHT + "px";
|
||||
|
||||
this.win.document.documentElement.appendChild(browser);
|
||||
// Have to set the mm after we append the child
|
||||
this.mm = browser.messageManager;
|
||||
|
||||
this.messages.forEach((msgName) => {
|
||||
this.mm.addMessageListener(msgName, this);
|
||||
});
|
||||
|
||||
this.mm.loadFrameScript(FRAME_SCRIPT_URL, false);
|
||||
},
|
||||
|
||||
endTest: function() {
|
||||
if (!this.win) {
|
||||
return;
|
||||
@ -156,6 +191,11 @@ let listener = {
|
||||
this.utils = null;
|
||||
this.canvas = null;
|
||||
|
||||
this.messages.forEach((msgName) => {
|
||||
this.mm.removeMessageListener(msgName, this);
|
||||
});
|
||||
|
||||
this.mm = null;
|
||||
}
|
||||
};
|
||||
|
||||
|
60
toolkit/components/gfx/content/gfxFrameScript.js
Normal file
60
toolkit/components/gfx/content/gfxFrameScript.js
Normal file
@ -0,0 +1,60 @@
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
const gfxFrameScript = {
|
||||
domUtils: null,
|
||||
|
||||
init: function() {
|
||||
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: function(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "MozAfterPaint":
|
||||
sendAsyncMessage('gfxSanity:ContentLoaded');
|
||||
removeEventListener("MozAfterPaint", this);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
isSanityTest: function(aUri) {
|
||||
if (!aUri) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return aUri.endsWith("/sanitytest.html");
|
||||
},
|
||||
|
||||
onStateChange: function (webProgress, req, flags, status) {
|
||||
if (webProgress.isTopLevel &&
|
||||
(flags & Ci.nsIWebProgressListener.STATE_STOP) &&
|
||||
this.isSanityTest(req.name)) {
|
||||
|
||||
// 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: XPCOMUtils.generateQI([
|
||||
Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsIObserver,
|
||||
]),
|
||||
};
|
||||
|
||||
gfxFrameScript.init();
|
Loading…
Reference in New Issue
Block a user