зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1066340 - Use an AutoEntryScript in nsFrameMessageManager::ReceiveMessage. r=smaug
This commit is contained in:
Родитель
bca5ea6dd2
Коммит
bc6cdbde35
|
@ -925,7 +925,6 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
|||
nsIPrincipal* aPrincipal,
|
||||
InfallibleTArray<nsString>* aJSONRetVal)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners =
|
||||
mListeners.Get(aMessage);
|
||||
if (listeners) {
|
||||
|
@ -956,11 +955,23 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
|||
if (!wrappedJS) {
|
||||
continue;
|
||||
}
|
||||
JS::Rooted<JSObject*> object(cx, wrappedJS->GetJSObject());
|
||||
if (!object) {
|
||||
|
||||
if (!wrappedJS->GetJSObject()) {
|
||||
continue;
|
||||
}
|
||||
JSAutoCompartment ac(cx, object);
|
||||
|
||||
// Note - The ergonomics here will get a lot better with bug 971673:
|
||||
//
|
||||
// AutoEntryScript aes;
|
||||
// if (!aes.Init(wrappedJS->GetJSObject())) {
|
||||
// continue;
|
||||
// }
|
||||
// JSContext* cx = aes.cx();
|
||||
nsIGlobalObject* nativeGlobal =
|
||||
xpc::GetNativeForGlobal(js::GetGlobalForObjectCrossCompartment(wrappedJS->GetJSObject()));
|
||||
AutoEntryScript aes(nativeGlobal);
|
||||
JSContext* cx = aes.cx();
|
||||
JS::Rooted<JSObject*> object(cx, wrappedJS->GetJSObject());
|
||||
|
||||
// The parameter for the listener function.
|
||||
JS::Rooted<JSObject*> param(cx,
|
||||
|
|
|
@ -9,6 +9,7 @@ var is_remote;
|
|||
(function start() {
|
||||
[is_remote] = sendSyncMessage("cpows:is_remote");
|
||||
parent_test();
|
||||
error_reporting_test();
|
||||
dom_test();
|
||||
xray_test();
|
||||
compartment_test();
|
||||
|
@ -89,6 +90,10 @@ function parent_test()
|
|||
sendSyncMessage("cpows:parent_test", {}, {func: f});
|
||||
}
|
||||
|
||||
function error_reporting_test() {
|
||||
sendSyncMessage("cpows:error_reporting_test", {}, {});
|
||||
}
|
||||
|
||||
function dom_test()
|
||||
{
|
||||
let element = content.document.createElement("div");
|
||||
|
|
|
@ -33,7 +33,12 @@
|
|||
}
|
||||
|
||||
// Make sure that an error in this file actually causes the test to fail.
|
||||
var gReceivedErrorProbe = false;
|
||||
window.onerror = function (msg, url, line) {
|
||||
if (/Test Error Probe/.test(msg)) {
|
||||
gReceivedErrorProbe = true;
|
||||
return;
|
||||
}
|
||||
ok(false, "Error while executing: \n" + msg + "\n" + url + ":" + line);
|
||||
};
|
||||
|
||||
|
@ -175,6 +180,11 @@
|
|||
savedMM.sendAsyncMessage("cpows:from_parent", {}, {obj: obj});
|
||||
}
|
||||
|
||||
// Make sure errors in this file actually hit window.onerror.
|
||||
function recvErrorReportingTest(message) {
|
||||
throw "Test Error Probe";
|
||||
}
|
||||
|
||||
let savedElement = null;
|
||||
function recvDomTest(message) {
|
||||
savedElement = message.objects.element;
|
||||
|
@ -271,6 +281,7 @@
|
|||
mm.addMessageListener("cpows:done", recvDoneMessage);
|
||||
mm.addMessageListener("cpows:fail", recvFailMessage);
|
||||
mm.addMessageListener("cpows:parent_test", recvParentTest);
|
||||
mm.addMessageListener("cpows:error_reporting_test", recvErrorReportingTest);
|
||||
mm.addMessageListener("cpows:dom_test", recvDomTest);
|
||||
mm.addMessageListener("cpows:dom_test_after_gc", recvDomTestAfterGC);
|
||||
mm.addMessageListener("cpows:xray_test", recvXrayTest);
|
||||
|
@ -285,6 +296,7 @@
|
|||
}
|
||||
|
||||
function finish() {
|
||||
ok(gReceivedErrorProbe, "Should have reported error probe");
|
||||
opener.setTimeout("done()", 0);
|
||||
window.close();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче