зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1549351 - Promise rejection event should not be sent for cross-origin scripts; r=smaug,till
Differential Revision: https://phabricator.services.mozilla.com/D31565 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1c6fe6b8d4
Коммит
e336502f67
|
@ -260,7 +260,7 @@ class MOZ_RAII JS_PUBLIC_API AutoDebuggerJobQueueInterruption {
|
|||
enum class PromiseRejectionHandlingState { Unhandled, Handled };
|
||||
|
||||
typedef void (*PromiseRejectionTrackerCallback)(
|
||||
JSContext* cx, JS::HandleObject promise,
|
||||
JSContext* cx, bool mutedErrors, JS::HandleObject promise,
|
||||
JS::PromiseRejectionHandlingState state, void* data);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1137,7 +1137,7 @@ static bool TrackUnhandledRejections(JSContext* cx, JS::HandleObject promise,
|
|||
}
|
||||
|
||||
static void ForwardingPromiseRejectionTrackerCallback(
|
||||
JSContext* cx, JS::HandleObject promise,
|
||||
JSContext* cx, bool mutedErrors, JS::HandleObject promise,
|
||||
JS::PromiseRejectionHandlingState state, void* data) {
|
||||
AutoReportException are(cx);
|
||||
|
||||
|
|
|
@ -637,9 +637,15 @@ void JSRuntime::addUnhandledRejectedPromise(JSContext* cx,
|
|||
return;
|
||||
}
|
||||
|
||||
bool mutedErrors = false;
|
||||
if (JSScript* script = cx->currentScript()) {
|
||||
mutedErrors = script->mutedErrors();
|
||||
}
|
||||
|
||||
void* data = cx->promiseRejectionTrackerCallbackData;
|
||||
cx->promiseRejectionTrackerCallback(
|
||||
cx, promise, JS::PromiseRejectionHandlingState::Unhandled, data);
|
||||
cx, mutedErrors, promise, JS::PromiseRejectionHandlingState::Unhandled,
|
||||
data);
|
||||
}
|
||||
|
||||
void JSRuntime::removeUnhandledRejectedPromise(JSContext* cx,
|
||||
|
@ -649,9 +655,15 @@ void JSRuntime::removeUnhandledRejectedPromise(JSContext* cx,
|
|||
return;
|
||||
}
|
||||
|
||||
bool mutedErrors = false;
|
||||
if (JSScript* script = cx->currentScript()) {
|
||||
mutedErrors = script->mutedErrors();
|
||||
}
|
||||
|
||||
void* data = cx->promiseRejectionTrackerCallbackData;
|
||||
cx->promiseRejectionTrackerCallback(
|
||||
cx, promise, JS::PromiseRejectionHandlingState::Handled, data);
|
||||
cx, mutedErrors, promise, JS::PromiseRejectionHandlingState::Handled,
|
||||
data);
|
||||
}
|
||||
|
||||
mozilla::non_crypto::XorShift128PlusRNG& JSRuntime::randomKeyGenerator() {
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[disallow-crossorigin.html]
|
||||
expected: ERROR
|
||||
[Promise rejection event should be muted for cross-origin non-CORS script]
|
||||
expected: FAIL
|
||||
|
|
@ -332,7 +332,7 @@ CycleCollectedJSContext::saveJobQueue(JSContext* cx) {
|
|||
|
||||
/* static */
|
||||
void CycleCollectedJSContext::PromiseRejectionTrackerCallback(
|
||||
JSContext* aCx, JS::HandleObject aPromise,
|
||||
JSContext* aCx, bool aMutedErrors, JS::HandleObject aPromise,
|
||||
JS::PromiseRejectionHandlingState state, void* aData) {
|
||||
CycleCollectedJSContext* self = static_cast<CycleCollectedJSContext*>(aData);
|
||||
|
||||
|
@ -348,7 +348,8 @@ void CycleCollectedJSContext::PromiseRejectionTrackerCallback(
|
|||
|
||||
if (state == JS::PromiseRejectionHandlingState::Unhandled) {
|
||||
PromiseDebugging::AddUncaughtRejection(aPromise);
|
||||
if (mozilla::StaticPrefs::dom_promise_rejection_events_enabled()) {
|
||||
if (mozilla::StaticPrefs::dom_promise_rejection_events_enabled() &&
|
||||
!aMutedErrors) {
|
||||
RefPtr<Promise> promise =
|
||||
Promise::CreateFromExisting(xpc::NativeGlobal(aPromise), aPromise);
|
||||
aboutToBeNotified.AppendElement(promise);
|
||||
|
@ -356,7 +357,8 @@ void CycleCollectedJSContext::PromiseRejectionTrackerCallback(
|
|||
}
|
||||
} else {
|
||||
PromiseDebugging::AddConsumedRejection(aPromise);
|
||||
if (mozilla::StaticPrefs::dom_promise_rejection_events_enabled()) {
|
||||
if (mozilla::StaticPrefs::dom_promise_rejection_events_enabled() &&
|
||||
!aMutedErrors) {
|
||||
for (size_t i = 0; i < aboutToBeNotified.Length(); i++) {
|
||||
if (aboutToBeNotified[i] &&
|
||||
aboutToBeNotified[i]->PromiseObj() == aPromise) {
|
||||
|
|
|
@ -118,7 +118,7 @@ class CycleCollectedJSContext
|
|||
JS::HandleObject aIncumbentGlobal,
|
||||
void* aData);
|
||||
static void PromiseRejectionTrackerCallback(
|
||||
JSContext* aCx, JS::HandleObject aPromise,
|
||||
JSContext* aCx, bool aMutedErrors, JS::HandleObject aPromise,
|
||||
JS::PromiseRejectionHandlingState state, void* aData);
|
||||
|
||||
void AfterProcessMicrotasks();
|
||||
|
|
Загрузка…
Ссылка в новой задаче