mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1472491: Part 1 - Add [ChromeOnly] wantUntrusted event listener option. r=bz
This is the same as the non-standard 4th addEventListener argument, but in a more standard place. Aside from being easier for readers to understand, this makes it much easier to define a set of DOM events an IPC actor needs to handle, without adding extra hacks to handle untrusted listeners. MozReview-Commit-ID: H6KxjSHtQrY --HG-- extra : rebase_source : 2d07a77f0cc22df59e19740d8ef538da06e763d3
This commit is contained in:
parent
f1e256e606
commit
57d6fb6016
@ -29,8 +29,16 @@ EventTarget::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
|
||||
bool
|
||||
EventTarget::ComputeWantsUntrusted(const Nullable<bool>& aWantsUntrusted,
|
||||
const AddEventListenerOptionsOrBoolean* aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (aOptions && aOptions->IsAddEventListenerOptions()) {
|
||||
const auto& options = aOptions->GetAsAddEventListenerOptions();
|
||||
if (options.mWantUntrusted.WasPassed()) {
|
||||
return options.mWantUntrusted.Value();
|
||||
}
|
||||
}
|
||||
|
||||
if (!aWantsUntrusted.IsNull()) {
|
||||
return aWantsUntrusted.Value();
|
||||
}
|
||||
@ -50,7 +58,7 @@ EventTarget::AddEventListener(const nsAString& aType,
|
||||
const Nullable<bool>& aWantsUntrusted,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, aRv);
|
||||
bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, &aOptions, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
@ -71,7 +79,7 @@ EventTarget::AddEventListener(const nsAString& aType,
|
||||
const Nullable<bool>& aWantsUntrusted)
|
||||
{
|
||||
ErrorResult rv;
|
||||
bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, rv);
|
||||
bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, nullptr, rv);
|
||||
if (rv.Failed()) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
@ -112,7 +120,7 @@ EventTarget::AddSystemEventListener(const nsAString& aType,
|
||||
const Nullable<bool>& aWantsUntrusted)
|
||||
{
|
||||
ErrorResult rv;
|
||||
bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, rv);
|
||||
bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, nullptr, rv);
|
||||
if (rv.Failed()) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
@ -289,8 +289,12 @@ protected:
|
||||
/**
|
||||
* A method to compute the right wantsUntrusted value for AddEventListener.
|
||||
* This will call the above hook as needed.
|
||||
*
|
||||
* If aOptions is non-null, and it contains a value for mWantUntrusted, that
|
||||
* value takes precedence over aWantsUntrusted.
|
||||
*/
|
||||
bool ComputeWantsUntrusted(const Nullable<bool>& aWantsUntrusted,
|
||||
const AddEventListenerOptionsOrBoolean* aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,8 @@ dictionary EventListenerOptions {
|
||||
dictionary AddEventListenerOptions : EventListenerOptions {
|
||||
boolean passive;
|
||||
boolean once = false;
|
||||
[ChromeOnly]
|
||||
boolean wantUntrusted;
|
||||
};
|
||||
|
||||
[Constructor,
|
||||
|
Loading…
Reference in New Issue
Block a user