Bug 573635 - e10s: resolve changes to prompt code from m-c merge [r=mfinkle]

This commit is contained in:
Alon Zakai 2010-07-28 17:37:24 -04:00
parent 96fdb5e8f5
commit b6eaf72ddf
2 changed files with 74 additions and 0 deletions

View File

@ -356,3 +356,62 @@ let ContentScroll = {
};
ContentScroll.init();
function PromptRemoter() {
addEventListener("DOMWindowCreated", this, false);
}
PromptRemoter.prototype = {
handleEvent: function handleEvent(aEvent) {
var window = aEvent.originalTarget.defaultView.content;
// Need to make sure we are called on what we care about -
// content windows. DOMWindowCreated is called on *all* HTMLDocuments,
// some of which belong to ChromeWindows or lack defaultView.content
// altogether.
//
// Note about the syntax used here: |"wrappedJSObject" in window|
// will silently fail, without even letting us catch it as an
// exception, and checking in the way that we do check in some
// cases still throws an exception; see bug 582108 about both.
try {
if (!window || !window.wrappedJSObject) {
return;
}
}
catch(e) {
return;
}
function bringTabToFront() {
let event = window.document.createEvent("Events");
event.initEvent("DOMWillOpenModalDialog", true, false);
window.dispatchEvent(event);
}
window.wrappedJSObject.alert = function(aMessage) {
bringTabToFront();
sendAsyncMessage("Prompt:Alert", {
message: aMessage
});
}
window.wrappedJSObject.confirm = function(aMessage) {
bringTabToFront();
return sendSyncMessage("Prompt:Confirm", {
message: aMessage
});
}
window.wrappedJSObject.prompt = function(aText, aValue) {
bringTabToFront();
return sendSyncMessage("Prompt:Prompt", {
text: aText,
value: aValue
});
}
},
};
new PromptRemoter();

View File

@ -134,6 +134,16 @@
break;
}
break;
case "Prompt:Alert":
alert(aMessage.json.message);
break;
case "Prompt:Confirm":
return confirm(aMessage.json.message);
case "Prompt:Prompt":
return prompt(aMessage.json.text, aMessage.json.value);
}
]]></body>
</method>
@ -373,6 +383,11 @@
messageManager.addMessageListener("pagehide", this);
messageManager.addMessageListener("DOMPopupBlocked", this);
// Prompt remoting
["Alert", "Confirm", "Prompt"].forEach(function(name) {
messageManager.addMessageListener("Prompt:" + name, this);
}, this);
this._webProgress._init();
]]>
</constructor>