mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 08:35:26 +00:00
d2d3260579
--HG-- extra : rebase_source : f0419a400dc714bc52481959fc4712fdc50b5e88
84 lines
3.2 KiB
XML
84 lines
3.2 KiB
XML
<?xml version="1.0"?>
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
|
type="text/css"?>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=549682
|
|
-->
|
|
<window title="Mozilla Bug 549682"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
onload="run()">
|
|
<label value="Mozilla Bug 549682"/>
|
|
<!-- test code goes here -->
|
|
<script type="application/javascript"><![CDATA[
|
|
var didRunAsync = false;
|
|
var didRunLocal = false;
|
|
var global = Components.classes["@mozilla.org/globalmessagemanager;1"].getService(Components.interfaces.nsIChromeFrameMessageManager);
|
|
var globalListenerCallCount = 0;
|
|
function globalListener(m) {
|
|
++globalListenerCallCount;
|
|
if (m.name == "sync") {
|
|
global.removeMessageListener("async", globalListener);
|
|
global.removeMessageListener("sync", globalListener);
|
|
global.removeMessageListener("global-sync", globalListener);
|
|
// Note, the result depends on what other windows are open.
|
|
opener.wrappedJSObject.ok(globalListenerCallCount >= 4,
|
|
"Global listener should have been called at least 4 times!");
|
|
opener.wrappedJSObject.ok(didRunLocal, "Local message received.");
|
|
|
|
opener.setTimeout("done()", 0);
|
|
var i = document.getElementById("ifr");
|
|
i.parentNode.removeChild(i); // This is a crash test!
|
|
window.close();
|
|
}
|
|
}
|
|
|
|
function asyncL(m) {
|
|
didRunAsync = true;
|
|
opener.wrappedJSObject.is(m.name, "async", "Wrong message!");
|
|
opener.wrappedJSObject.is(m.json.data, 1234, "Wrong data!");
|
|
}
|
|
|
|
function syncL(m) {
|
|
opener.wrappedJSObject.is(m.name, "sync", "Wrong message!");
|
|
opener.wrappedJSObject.is(m.json.data, 1234, "Wrong data!");
|
|
opener.wrappedJSObject.ok(didRunAsync, "Should have run async!");
|
|
}
|
|
|
|
function localL(m) {
|
|
opener.wrappedJSObject.is(m.name, "lasync", "Wrong message!");
|
|
opener.wrappedJSObject.is(m.json.data, 2345, "Wrong data!");
|
|
didRunLocal = true;
|
|
}
|
|
|
|
function loadScript() {
|
|
// Async should be processed first!
|
|
messageManager.loadFrameScript("data:,sendAsyncMessage('async', { data: 1234 }); sendSyncMessage('sync', { data: 1234 });", false);
|
|
}
|
|
|
|
function run() {
|
|
var localmm = document.getElementById('ifr').messageManager;
|
|
localmm.addMessageListener("lasync", localL);
|
|
localmm.loadFrameScript("data:,sendAsyncMessage('lasync', { data: 2345 })", false);
|
|
|
|
messageManager.addMessageListener("async", asyncL);
|
|
messageManager.addMessageListener("sync", syncL);
|
|
global.addMessageListener("async", globalListener);
|
|
global.addMessageListener("sync", globalListener);
|
|
global.addMessageListener("global-sync", globalListener);
|
|
global.loadFrameScript("data:,sendSyncMessage('global-sync', { data: 1234 });", true);
|
|
|
|
var oldValue = globalListenerCallCount;
|
|
var b = document.createElement("browser");
|
|
b.setAttribute("type", "content");
|
|
document.documentElement.appendChild(b);
|
|
opener.wrappedJSObject.is(globalListenerCallCount, oldValue + 1,
|
|
"Wrong message count");
|
|
|
|
setTimeout(loadScript, 0);
|
|
}
|
|
|
|
]]></script>
|
|
<browser type="content" src="about:blank" id="ifr"/>
|
|
</window>
|