gecko/dom/ipc/test.xul

95 lines
3.4 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="800" height="800" orient="vertical">
<script>
function dumpClientRect(r) {
dump(r.left + "," + r.top + "," + r.right + "," +
r.bottom + "," + r.width + "," + r.height + "\n");
}
function handleMozAfterPaint(e) {
return;
dump(e.type + "\n")
var rects = e.clientRects;
var i;
dump("\tclientRects:\n");
for (i = 0; i &lt; rects.length; ++i) {
var r = rects.item(i);
dump("\t\t");
dumpClientRect(rects.item(i));
}
dump("\tboundingClientRect\n\t\t");
dumpClientRect(e.boundingClientRect);
var paintRequests = e.paintRequests;
dump("\tpaintRequests\n");
for (i = 0; i &lt; paintRequests.length; ++i) {
var pr = paintRequests.item(i);
dump("\t\t");
dumpClientRect(pr.clientRect);
if (pr.reason)
dump("\t\t" + pr.reason + "\n");
}
}
function handleMozScrolledAreaChanged(e) {
return;
dump(e.type + "\n");
dump("\t" + e.x + "," + e.y + "," + e.width + "," + e.height + "\n");
}
function restart() {
var y = document.getElementById('page');
var p = y.parentNode;
p.removeChild(y);
p.appendChild(y);
var fl = y.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
fl.activateFrameEvent("MozAfterPaint", true);
fl.activateFrameEvent("MozScrolledAreaChanged", true);
y.addEventListener("MozAfterPaint", handleMozAfterPaint, true);
y.addEventListener("MozScrolledAreaChanged", handleMozScrolledAreaChanged, true);
}
function loadURL(url) {
document.getElementById('page').setAttribute('src', url);
}
function randomClick() {
// First focus the remote frame, then dispatch click. This way remote frame gets focus before
// mouse event.
document.getElementById('page').QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
.frameLoader.activateRemoteFrame();
var frameLoader = document.getElementById('page').QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
var x = parseInt(Math.random() * 100);
var y = parseInt(Math.random() * 100);
frameLoader.sendCrossProcessMouseEvent("mousedown", x, y, 0, 1, 0, false);
frameLoader.sendCrossProcessMouseEvent("mouseup", x, y, 0, 1, 0, false);
}
function openWindow() {
window.open('chrome://global/content/test-ipc.xul', '_blank', 'chrome,resizable,width=800,height=800');
}
function closeWindow() {
window.close();
}
</script>
<toolbar id="controls">
<toolbarbutton label="Back"/>
<toolbarbutton label="Forward"/>
<textbox onchange="loadURL(this.value)" flex="1" id="URL"/>
<toolbarbutton onclick="restart()" label="Recover"/>
<toolbarbutton onclick="randomClick()" label="random click"/>
<toolbarbutton onclick="openWindow()" label="open new window"/>
<toolbarbutton onclick="closeWindow()" label="close this window"/>
</toolbar>
<browser type="content" src="http://www.google.com/" flex="1" id="page" remote="true"
onfocus="this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.activateRemoteFrame();"/>
</window>