mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Merge mozilla-central to autoland a=merge on a CLOSED TREE
This commit is contained in:
commit
71432717b8
@ -1494,29 +1494,32 @@ pref("browser.ping-centre.production.endpoint", "https://tiles.services.mozilla.
|
||||
// Enable GMP support in the addon manager.
|
||||
pref("media.gmp-provider.enabled", true);
|
||||
|
||||
pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended", true);
|
||||
pref("browser.contentblocking.fastblock.control-center.ui.enabled", true);
|
||||
pref("browser.contentblocking.trackingprotection.control-center.ui.enabled", true);
|
||||
pref("browser.contentblocking.rejecttrackers.ui.recommended", true);
|
||||
pref("browser.contentblocking.fastblock.ui.enabled", true);
|
||||
pref("browser.contentblocking.trackingprotection.ui.enabled", true);
|
||||
// Enable the new Content Blocking UI only on Nightly.
|
||||
#ifdef NIGHTLY_BUILD
|
||||
pref("browser.contentblocking.ui.enabled", true);
|
||||
pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", true);
|
||||
pref("browser.contentblocking.rejecttrackers.control-center.ui.enabled", true);
|
||||
pref("browser.contentblocking.rejecttrackers.ui.enabled", true);
|
||||
#else
|
||||
pref("browser.contentblocking.ui.enabled", false);
|
||||
pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", false);
|
||||
pref("browser.contentblocking.rejecttrackers.control-center.ui.enabled", false);
|
||||
pref("browser.contentblocking.rejecttrackers.ui.enabled", false);
|
||||
#endif
|
||||
#ifdef NIGHTLY_BUILD
|
||||
|
||||
// Define a set of default features for the Content Blocking UI
|
||||
pref("browser.contentblocking.fastblock.ui.enabled", true);
|
||||
pref("browser.contentblocking.fastblock.control-center.ui.enabled", true);
|
||||
pref("browser.contentblocking.trackingprotection.ui.enabled", true);
|
||||
pref("browser.contentblocking.trackingprotection.control-center.ui.enabled", true);
|
||||
pref("browser.contentblocking.rejecttrackers.ui.enabled", true);
|
||||
pref("browser.contentblocking.rejecttrackers.ui.recommended", true);
|
||||
pref("browser.contentblocking.rejecttrackers.control-center.ui.enabled", true);
|
||||
pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended", true);
|
||||
pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", true);
|
||||
|
||||
// Enable the Report Breakage UI on Nightly and Beta but not on Release yet.
|
||||
#ifdef EARLY_BETA_OR_EARLIER
|
||||
pref("browser.contentblocking.reportBreakage.enabled", true);
|
||||
#else
|
||||
pref("browser.contentblocking.reportBreakage.enabled", false);
|
||||
#endif
|
||||
pref("browser.contentblocking.reportBreakage.url", "https://tracking-protection-issues.herokuapp.com/new");
|
||||
|
||||
// Content Blocking has a separate pref for the intro count, since the former TP intro
|
||||
// was updated when we introduced content blocking and we want people to see it again.
|
||||
pref("browser.contentblocking.introCount", 0);
|
||||
|
@ -1,18 +1,11 @@
|
||||
MOZ_AUTOMATION_L10N_CHECK=0
|
||||
|
||||
. "$topsrcdir/build/mozconfig.common"
|
||||
. "$topsrcdir/build/unix/mozconfig.linux"
|
||||
|
||||
# Use Clang as specified in manifest
|
||||
export CC="$topsrcdir/clang/bin/clang -fgnu89-inline"
|
||||
export CXX="$topsrcdir/clang/bin/clang++"
|
||||
# Enabling the clang plugin triggers leaks. bug 1487622
|
||||
unset ENABLE_CLANG_PLUGIN
|
||||
export LLVM_SYMBOLIZER="$topsrcdir/clang/bin/llvm-symbolizer"
|
||||
|
||||
# Use a newer binutils, if it's there
|
||||
if [ -e "$topsrcdir/binutils/bin/ld" ]; then
|
||||
export CC="$CC -B $topsrcdir/binutils/bin"
|
||||
export CXX="$CXX -B $topsrcdir/binutils/bin"
|
||||
fi
|
||||
|
||||
#
|
||||
# Enable ASan specific code and build workarounds
|
||||
ac_add_options --enable-address-sanitizer
|
||||
|
||||
@ -23,5 +16,3 @@ ac_add_options --disable-install-strip
|
||||
ac_add_options --disable-jemalloc
|
||||
ac_add_options --disable-crashreporter
|
||||
ac_add_options --disable-profiling
|
||||
|
||||
. "$topsrcdir/build/unix/mozconfig.stdcxx"
|
||||
|
@ -1,24 +1,13 @@
|
||||
MOZ_AUTOMATION_L10N_CHECK=0
|
||||
|
||||
. "$topsrcdir/build/mozconfig.common"
|
||||
. "$topsrcdir/build/unix/mozconfig.linux"
|
||||
|
||||
# Use Clang as specified in manifest
|
||||
export AR="$topsrcdir/clang/bin/llvm-ar"
|
||||
export NM="$topsrcdir/clang/bin/llvm-nm"
|
||||
export RANLIB="$topsrcdir/clang/bin/llvm-ranlib"
|
||||
|
||||
export CC="$topsrcdir/clang/bin/clang"
|
||||
export CXX="$topsrcdir/clang/bin/clang++"
|
||||
|
||||
# Use a newer binutils, if it's there
|
||||
if [ -e "$topsrcdir/binutils/bin/ld" ]; then
|
||||
export CC="$CC -B $topsrcdir/binutils/bin"
|
||||
export CXX="$CXX -B $topsrcdir/binutils/bin"
|
||||
fi
|
||||
|
||||
ac_add_options --enable-lto
|
||||
# Until it's either made the default or we figure a way to remove the
|
||||
# copy locations that LTO induces in non-PIE executables.
|
||||
ac_add_options --enable-pie
|
||||
|
||||
. "$topsrcdir/build/unix/mozconfig.stdcxx"
|
||||
|
@ -1,18 +1,9 @@
|
||||
MOZ_AUTOMATION_L10N_CHECK=0
|
||||
|
||||
. "$topsrcdir/build/mozconfig.common"
|
||||
. "$topsrcdir/build/unix/mozconfig.linux"
|
||||
|
||||
# Use Clang as specified in manifest
|
||||
export CC="$topsrcdir/clang/bin/clang"
|
||||
export CXX="$topsrcdir/clang/bin/clang++"
|
||||
export LLVM_SYMBOLIZER="$topsrcdir/clang/bin/llvm-symbolizer"
|
||||
|
||||
# Use a newer binutils, if it's there
|
||||
if [ -e "$topsrcdir/binutils/bin/ld" ]; then
|
||||
export CC="$CC -B $topsrcdir/binutils/bin"
|
||||
export CXX="$CXX -B $topsrcdir/binutils/bin"
|
||||
fi
|
||||
|
||||
# Enable TSan specific code and build workarounds
|
||||
ac_add_options --enable-thread-sanitizer
|
||||
|
||||
@ -30,5 +21,3 @@ ac_add_options --enable-pie
|
||||
ac_add_options --disable-install-strip
|
||||
# -gline-tables-only results in significantly smaller binaries.
|
||||
ac_add_options --enable-debug-symbols="-gline-tables-only"
|
||||
|
||||
. "$topsrcdir/build/unix/mozconfig.stdcxx"
|
||||
|
@ -14,7 +14,7 @@
|
||||
"use strict";
|
||||
|
||||
const ctx = new AudioContext();
|
||||
const osc = ctx.createOscillator();
|
||||
const osc = ctx.createStereoPanner();
|
||||
|
||||
function throwError() {
|
||||
try {
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
function throwDOMException() {
|
||||
try {
|
||||
osc.frequency.setValueAtTime(0, -1);
|
||||
osc.channelCount = 3;
|
||||
} catch (e) {
|
||||
return {
|
||||
lineNumber: e.lineNumber,
|
||||
|
@ -542,12 +542,16 @@ Navigator::CookieEnabled()
|
||||
return cookieEnabled;
|
||||
}
|
||||
|
||||
uint32_t rejectedReason = 0;
|
||||
if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(mWindow,
|
||||
codebaseURI)) {
|
||||
codebaseURI,
|
||||
&rejectedReason)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
AntiTrackingCommon::NotifyRejection(mWindow);
|
||||
if (rejectedReason) {
|
||||
AntiTrackingCommon::NotifyRejection(mWindow, rejectedReason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -8876,7 +8876,8 @@ static bool
|
||||
StorageDisabledByAntiTrackingInternal(nsPIDOMWindowInner* aWindow,
|
||||
nsIChannel* aChannel,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsIURI* aURI)
|
||||
nsIURI* aURI,
|
||||
uint32_t* aRejectedReason)
|
||||
{
|
||||
MOZ_ASSERT(aWindow || aChannel || aPrincipal);
|
||||
|
||||
@ -8884,7 +8885,8 @@ StorageDisabledByAntiTrackingInternal(nsPIDOMWindowInner* aWindow,
|
||||
nsIURI* documentURI = aURI ? aURI : aWindow->GetDocumentURI();
|
||||
return !documentURI ||
|
||||
!AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(aWindow,
|
||||
documentURI);
|
||||
documentURI,
|
||||
aRejectedReason);
|
||||
}
|
||||
|
||||
if (aChannel) {
|
||||
@ -8900,7 +8902,8 @@ StorageDisabledByAntiTrackingInternal(nsPIDOMWindowInner* aWindow,
|
||||
}
|
||||
|
||||
return !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel,
|
||||
uri);
|
||||
uri,
|
||||
aRejectedReason);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
@ -8914,13 +8917,15 @@ nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsIURI* aURI)
|
||||
{
|
||||
uint32_t rejectedReason = 0;
|
||||
bool disabled =
|
||||
StorageDisabledByAntiTrackingInternal(aWindow, aChannel, aPrincipal, aURI);
|
||||
if (disabled && sAntiTrackingControlCenterUIEnabled) {
|
||||
StorageDisabledByAntiTrackingInternal(aWindow, aChannel, aPrincipal, aURI,
|
||||
&rejectedReason);
|
||||
if (disabled && sAntiTrackingControlCenterUIEnabled && rejectedReason) {
|
||||
if (aWindow) {
|
||||
AntiTrackingCommon::NotifyRejection(aWindow);
|
||||
AntiTrackingCommon::NotifyRejection(aWindow, rejectedReason);
|
||||
} else if (aChannel) {
|
||||
AntiTrackingCommon::NotifyRejection(aChannel);
|
||||
AntiTrackingCommon::NotifyRejection(aChannel, rejectedReason);
|
||||
}
|
||||
}
|
||||
return disabled;
|
||||
|
@ -5291,7 +5291,7 @@ nsGlobalWindowOuter::NotifyContentBlockingState(unsigned aState,
|
||||
securityUI->GetState(&state);
|
||||
if (aState == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
doc->SetHasTrackingContentBlocked(true);
|
||||
} else if (aState == nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES) {
|
||||
} else if (aState == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER) {
|
||||
doc->SetHasTrackingCookiesBlocked(true);
|
||||
} else {
|
||||
// Ignore nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
|
||||
|
@ -106,3 +106,8 @@ MSG_DEF(MSG_CACHE_OPEN_FAILED, 0, JSEXN_TYPEERR, "CacheStorage.open() failed to
|
||||
MSG_DEF(MSG_MATRIX_INIT_LENGTH_WRONG, 1, JSEXN_TYPEERR, "Matrix init sequence must have a length of 6 or 16 (actual value: {0})")
|
||||
MSG_DEF(MSG_INVALID_MEDIA_VIDEO_CONFIGURATION, 0, JSEXN_TYPEERR, "Invalid VideoConfiguration.")
|
||||
MSG_DEF(MSG_INVALID_MEDIA_AUDIO_CONFIGURATION, 0, JSEXN_TYPEERR, "Invalid AudioConfiguration.")
|
||||
MSG_DEF(MSG_INVALID_CURVE_DURATION_ERROR, 0, JSEXN_RANGEERR, "The curve duration for SetValueCurve must be strictly positive.")
|
||||
MSG_DEF(MSG_INVALID_AUDIOPARAM_METHOD_START_TIME_ERROR, 0, JSEXN_RANGEERR, "The start time for an AudioParam method must be positive.")
|
||||
MSG_DEF(MSG_INVALID_AUDIOPARAM_METHOD_END_TIME_ERROR, 0, JSEXN_RANGEERR, "The end time for an AudioParam method must be positive.")
|
||||
MSG_DEF(MSG_INVALID_AUDIOPARAM_EXPONENTIAL_VALUE_ERROR, 0, JSEXN_RANGEERR, "The value passed to exponentialCurveToValueAtTime must be positive.")
|
||||
MSG_DEF(MSG_INVALID_AUDIOPARAM_EXPONENTIAL_CONSTANT_ERROR, 0, JSEXN_RANGEERR, "The exponential constant passed to setTargetAtTime must be positive.")
|
||||
|
@ -221,22 +221,37 @@ AudioEventTimeline::GetValuesAtTimeHelperInternal(TimeType aTime,
|
||||
return mValue;
|
||||
}
|
||||
|
||||
// If this event is a curve event, this returns the end time of the curve.
|
||||
// Otherwise, this returns the time of the event.
|
||||
auto TimeOf = [](const AudioTimelineEvent* aEvent) -> TimeType {
|
||||
if (aEvent->mType == AudioTimelineEvent::SetValueCurve) {
|
||||
return aEvent->template Time<TimeType>() + aEvent->mDuration;
|
||||
}
|
||||
return aEvent->template Time<TimeType>();
|
||||
};
|
||||
|
||||
// Value for an event. For a ValueCurve event, this is the value of the last
|
||||
// element of the curve.
|
||||
auto ValueOf = [](const AudioTimelineEvent* aEvent) -> float {
|
||||
if (aEvent->mType == AudioTimelineEvent::SetValueCurve) {
|
||||
return aEvent->mCurve[aEvent->mCurveLength - 1];
|
||||
}
|
||||
return aEvent->mValue;
|
||||
};
|
||||
|
||||
// SetTarget nodes can be handled no matter what their next node is (if
|
||||
// they have one)
|
||||
if (aPrevious->mType == AudioTimelineEvent::SetTarget) {
|
||||
return ExponentialApproach(TimeOf(aPrevious),
|
||||
mLastComputedValue, aPrevious->mValue,
|
||||
mLastComputedValue, ValueOf(aPrevious),
|
||||
aPrevious->mTimeConstant, aTime);
|
||||
}
|
||||
|
||||
// SetValueCurve events can be handled no matter what their next node is
|
||||
// (if they have one)
|
||||
if (aPrevious->mType == AudioTimelineEvent::SetValueCurve) {
|
||||
return ExtractValueFromCurve(TimeOf(aPrevious),
|
||||
// (if they have one), when aTime is in the curve region.
|
||||
if (aPrevious->mType == AudioTimelineEvent::SetValueCurve &&
|
||||
aTime <= aPrevious->template Time<TimeType>() + aPrevious->mDuration) {
|
||||
return ExtractValueFromCurve(aPrevious->template Time<TimeType>(),
|
||||
aPrevious->mCurve, aPrevious->mCurveLength,
|
||||
aPrevious->mDuration, aTime);
|
||||
}
|
||||
@ -250,7 +265,7 @@ AudioEventTimeline::GetValuesAtTimeHelperInternal(TimeType aTime,
|
||||
// The value will be constant after the last event
|
||||
return aPrevious->mValue;
|
||||
case AudioTimelineEvent::SetValueCurve:
|
||||
return ExtractValueFromCurve(TimeOf(aPrevious),
|
||||
return ExtractValueFromCurve(aPrevious->template Time<TimeType>(),
|
||||
aPrevious->mCurve, aPrevious->mCurveLength,
|
||||
aPrevious->mDuration, aTime);
|
||||
case AudioTimelineEvent::SetTarget:
|
||||
@ -269,15 +284,15 @@ AudioEventTimeline::GetValuesAtTimeHelperInternal(TimeType aTime,
|
||||
switch (aNext->mType) {
|
||||
case AudioTimelineEvent::LinearRamp:
|
||||
return LinearInterpolate(TimeOf(aPrevious),
|
||||
aPrevious->mValue,
|
||||
ValueOf(aPrevious),
|
||||
TimeOf(aNext),
|
||||
aNext->mValue, aTime);
|
||||
ValueOf(aNext), aTime);
|
||||
|
||||
case AudioTimelineEvent::ExponentialRamp:
|
||||
return ExponentialInterpolate(TimeOf(aPrevious),
|
||||
aPrevious->mValue,
|
||||
ValueOf(aPrevious),
|
||||
TimeOf(aNext),
|
||||
aNext->mValue, aTime);
|
||||
ValueOf(aNext), aTime);
|
||||
|
||||
case AudioTimelineEvent::SetValueAtTime:
|
||||
case AudioTimelineEvent::SetTarget:
|
||||
@ -298,7 +313,7 @@ AudioEventTimeline::GetValuesAtTimeHelperInternal(TimeType aTime,
|
||||
// value is constant.
|
||||
return aPrevious->mValue;
|
||||
case AudioTimelineEvent::SetValueCurve:
|
||||
return ExtractValueFromCurve(TimeOf(aPrevious),
|
||||
return ExtractValueFromCurve(aPrevious->template Time<TimeType>(),
|
||||
aPrevious->mCurve, aPrevious->mCurveLength,
|
||||
aPrevious->mDuration, aTime);
|
||||
case AudioTimelineEvent::SetTarget:
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
#include "MainThreadUtils.h"
|
||||
#include "nsTArray.h"
|
||||
@ -116,13 +117,6 @@ inline int64_t AudioTimelineEvent::Time<int64_t>() const
|
||||
return mTimeInTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some methods in this class will be instantiated with different ErrorResult
|
||||
* template arguments for testing and production code.
|
||||
*
|
||||
* ErrorResult is a type which satisfies the following:
|
||||
* - Implements a Throw() method taking an nsresult argument, representing an error code.
|
||||
*/
|
||||
class AudioEventTimeline
|
||||
{
|
||||
public:
|
||||
@ -132,7 +126,6 @@ public:
|
||||
mLastComputedValue(aDefaultValue)
|
||||
{ }
|
||||
|
||||
template <class ErrorResult>
|
||||
bool ValidateEvent(AudioTimelineEvent& aEvent, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -142,51 +135,52 @@ public:
|
||||
};
|
||||
|
||||
// Validate the event itself
|
||||
if (!WebAudioUtils::IsTimeValid(TimeOf(aEvent)) ||
|
||||
!WebAudioUtils::IsTimeValid(aEvent.mTimeConstant)) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
if (!WebAudioUtils::IsTimeValid(TimeOf(aEvent))) {
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_METHOD_START_TIME_ERROR>();
|
||||
return false;
|
||||
}
|
||||
if (!WebAudioUtils::IsTimeValid(aEvent.mTimeConstant)) {
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_EXPONENTIAL_CONSTANT_ERROR>();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aEvent.mType == AudioTimelineEvent::SetValueCurve) {
|
||||
if (!aEvent.mCurve || !aEvent.mCurveLength) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return false;
|
||||
}
|
||||
if (aEvent.mCurveLength < 2) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return false;
|
||||
}
|
||||
if (aEvent.mDuration <= 0) {
|
||||
aRv.template ThrowRangeError<MSG_INVALID_CURVE_DURATION_ERROR>();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool timeAndValueValid = IsValid(aEvent.mValue) &&
|
||||
IsValid(aEvent.mDuration);
|
||||
if (!timeAndValueValid) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(IsValid(aEvent.mValue) && IsValid(aEvent.mDuration));
|
||||
|
||||
// Make sure that non-curve events don't fall within the duration of a
|
||||
// Make sure that new events don't fall within the duration of a
|
||||
// curve event.
|
||||
for (unsigned i = 0; i < mEvents.Length(); ++i) {
|
||||
if (mEvents[i].mType == AudioTimelineEvent::SetValueCurve &&
|
||||
!(aEvent.mType == AudioTimelineEvent::SetValueCurve &&
|
||||
TimeOf(aEvent) == TimeOf(mEvents[i])) &&
|
||||
TimeOf(mEvents[i]) <= TimeOf(aEvent) &&
|
||||
TimeOf(mEvents[i]) + mEvents[i].mDuration >= TimeOf(aEvent)) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
TimeOf(mEvents[i]) + mEvents[i].mDuration > TimeOf(aEvent)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that curve events don't fall in a range which includes other
|
||||
// Make sure that new curve events don't fall in a range which includes other
|
||||
// events.
|
||||
if (aEvent.mType == AudioTimelineEvent::SetValueCurve) {
|
||||
for (unsigned i = 0; i < mEvents.Length(); ++i) {
|
||||
// In case we have two curve at the same time
|
||||
if (mEvents[i].mType == AudioTimelineEvent::SetValueCurve &&
|
||||
TimeOf(mEvents[i]) == TimeOf(aEvent)) {
|
||||
continue;
|
||||
}
|
||||
if (TimeOf(mEvents[i]) > TimeOf(aEvent) &&
|
||||
TimeOf(mEvents[i]) < TimeOf(aEvent) + aEvent.mDuration) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
if (TimeOf(aEvent) < TimeOf(mEvents[i]) &&
|
||||
TimeOf(aEvent) + aEvent.mDuration >= TimeOf(mEvents[i])) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -195,7 +189,8 @@ public:
|
||||
// Make sure that invalid values are not used for exponential curves
|
||||
if (aEvent.mType == AudioTimelineEvent::ExponentialRamp) {
|
||||
if (aEvent.mValue <= 0.f) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_EXPONENTIAL_VALUE_ERROR>();
|
||||
return false;
|
||||
}
|
||||
const AudioTimelineEvent* previousEvent = GetPreviousEvent(TimeOf(aEvent));
|
||||
@ -219,19 +214,14 @@ public:
|
||||
{
|
||||
for (unsigned i = 0; i < mEvents.Length(); ++i) {
|
||||
if (aEvent.template Time<TimeType>() == mEvents[i].template Time<TimeType>()) {
|
||||
if (aEvent.mType == mEvents[i].mType) {
|
||||
// If times and types are equal, replace the event
|
||||
mEvents.ReplaceElementAt(i, aEvent);
|
||||
} else {
|
||||
// Otherwise, place the element after the last event of another type
|
||||
// If two events happen at the same time, have them in chronological
|
||||
// order of insertion.
|
||||
do {
|
||||
++i;
|
||||
} while (i < mEvents.Length() &&
|
||||
aEvent.mType != mEvents[i].mType &&
|
||||
aEvent.template Time<TimeType>() == mEvents[i].template Time<TimeType>());
|
||||
mEvents.InsertElementAt(i, aEvent);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Otherwise, place the event right after the latest existing event
|
||||
if (aEvent.template Time<TimeType>() < mEvents[i].template Time<TimeType>()) {
|
||||
@ -270,7 +260,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class ErrorResult>
|
||||
void SetValueAtTime(float aValue, double aStartTime, ErrorResult& aRv)
|
||||
{
|
||||
AudioTimelineEvent event(AudioTimelineEvent::SetValueAtTime, aStartTime, aValue);
|
||||
@ -280,7 +269,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class ErrorResult>
|
||||
void LinearRampToValueAtTime(float aValue, double aEndTime, ErrorResult& aRv)
|
||||
{
|
||||
AudioTimelineEvent event(AudioTimelineEvent::LinearRamp, aEndTime, aValue);
|
||||
@ -290,7 +278,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class ErrorResult>
|
||||
void ExponentialRampToValueAtTime(float aValue, double aEndTime, ErrorResult& aRv)
|
||||
{
|
||||
AudioTimelineEvent event(AudioTimelineEvent::ExponentialRamp, aEndTime, aValue);
|
||||
@ -300,7 +287,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class ErrorResult>
|
||||
void SetTargetAtTime(float aTarget, double aStartTime, double aTimeConstant, ErrorResult& aRv)
|
||||
{
|
||||
AudioTimelineEvent event(AudioTimelineEvent::SetTarget, aStartTime, aTarget, aTimeConstant);
|
||||
@ -310,7 +296,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class ErrorResult>
|
||||
void SetValueCurveAtTime(const float* aValues, uint32_t aValuesLength, double aStartTime, double aDuration, ErrorResult& aRv)
|
||||
{
|
||||
AudioTimelineEvent event(AudioTimelineEvent::SetValueCurve, aStartTime, 0.0f, 0.0f, aDuration, aValues, aValuesLength);
|
||||
|
@ -51,13 +51,16 @@ public:
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aStartTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_METHOD_START_TIME_ERROR>();
|
||||
return this;
|
||||
}
|
||||
aStartTime = std::max(aStartTime, GetParentObject()->CurrentTime());
|
||||
EventInsertionHelper(aRv, AudioTimelineEvent::SetValueCurve,
|
||||
aStartTime, 0.0f, 0.0f, aDuration, aValues.Elements(),
|
||||
aStartTime, 0.0f,
|
||||
0.0f, aDuration, aValues.Elements(),
|
||||
aValues.Length());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -80,7 +83,8 @@ public:
|
||||
AudioParam* SetValueAtTime(float aValue, double aStartTime, ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aStartTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_METHOD_START_TIME_ERROR>();
|
||||
return this;
|
||||
}
|
||||
aStartTime = std::max(aStartTime, GetParentObject()->CurrentTime());
|
||||
@ -94,7 +98,8 @@ public:
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aEndTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_METHOD_END_TIME_ERROR>();
|
||||
return this;
|
||||
}
|
||||
aEndTime = std::max(aEndTime, GetParentObject()->CurrentTime());
|
||||
@ -106,7 +111,8 @@ public:
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aEndTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_METHOD_END_TIME_ERROR>();
|
||||
return this;
|
||||
}
|
||||
aEndTime = std::max(aEndTime, GetParentObject()->CurrentTime());
|
||||
@ -120,7 +126,8 @@ public:
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aStartTime) ||
|
||||
!WebAudioUtils::IsTimeValid(aTimeConstant)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_METHOD_START_TIME_ERROR>();
|
||||
return this;
|
||||
}
|
||||
aStartTime = std::max(aStartTime, GetParentObject()->CurrentTime());
|
||||
@ -134,7 +141,8 @@ public:
|
||||
AudioParam* CancelScheduledValues(double aStartTime, ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aStartTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
aRv.template ThrowRangeError<
|
||||
MSG_INVALID_AUDIOPARAM_METHOD_START_TIME_ERROR>();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -219,7 +227,7 @@ private:
|
||||
AudioTimelineEvent::Type aType,
|
||||
double aTime, float aValue,
|
||||
double aTimeConstant = 0.0,
|
||||
float aDuration = 0.0,
|
||||
double aDuration = 0.0,
|
||||
const float* aCurve = nullptr,
|
||||
uint32_t aCurveLength = 0)
|
||||
{
|
||||
|
@ -1,441 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AudioEventTimeline.h"
|
||||
#include <sstream>
|
||||
#include <limits>
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// Mock the MediaStream class
|
||||
namespace mozilla {
|
||||
class MediaStream
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaStream)
|
||||
private:
|
||||
~MediaStream() {
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using std::numeric_limits;
|
||||
|
||||
// Some simple testing primitives
|
||||
void ok(bool val, const char* msg)
|
||||
{
|
||||
if (!val) {
|
||||
fprintf(stderr, "failure: %s", msg);
|
||||
}
|
||||
ASSERT_TRUE(val);
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
template <class T>
|
||||
basic_ostream<T, char_traits<T> >&
|
||||
operator<<(basic_ostream<T, char_traits<T> >& os, nsresult rv)
|
||||
{
|
||||
os << static_cast<uint32_t>(rv);
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
template <class T, class U>
|
||||
void is(const T& a, const U& b, const char* msg)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << msg << ", Got: " << a << ", expected: " << b << std::endl;
|
||||
ok(a == b, ss.str().c_str());
|
||||
}
|
||||
|
||||
template <>
|
||||
void is(const float& a, const float& b, const char* msg)
|
||||
{
|
||||
// stupidly high, since we mostly care about the correctness of the algorithm
|
||||
const float kEpsilon = 0.00001f;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << msg << ", Got: " << a << ", expected: " << b << std::endl;
|
||||
ok(fabsf(a - b) < kEpsilon, ss.str().c_str());
|
||||
}
|
||||
|
||||
class ErrorResultMock
|
||||
{
|
||||
public:
|
||||
ErrorResultMock()
|
||||
: mRv(NS_OK)
|
||||
{
|
||||
}
|
||||
void Throw(nsresult aRv)
|
||||
{
|
||||
mRv = aRv;
|
||||
}
|
||||
|
||||
operator nsresult() const
|
||||
{
|
||||
return mRv;
|
||||
}
|
||||
|
||||
ErrorResultMock& operator=(nsresult aRv)
|
||||
{
|
||||
mRv = aRv;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
nsresult mRv;
|
||||
};
|
||||
|
||||
typedef AudioEventTimeline Timeline;
|
||||
|
||||
TEST(AudioEventTimeline, SpecExample)
|
||||
{
|
||||
// First, run the basic tests
|
||||
Timeline timeline(10.0f);
|
||||
is(timeline.Value(), 10.0f, "Correct default value returned");
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
uint32_t curveLength = 44100;
|
||||
float* curve = new float[curveLength];
|
||||
for (uint32_t i = 0; i < curveLength; ++i) {
|
||||
curve[i] = sin(M_PI * i / float(curveLength));
|
||||
}
|
||||
|
||||
// This test is copied from the example in the Web Audio spec
|
||||
const double t0 = 0.0,
|
||||
t1 = 0.1,
|
||||
t2 = 0.2,
|
||||
t3 = 0.3,
|
||||
t4 = 0.4,
|
||||
t5 = 0.6,
|
||||
t6 = 0.7,
|
||||
t7 = 1.0;
|
||||
timeline.SetValueAtTime(0.2f, t0, rv);
|
||||
is(rv, NS_OK, "SetValueAtTime succeeded");
|
||||
timeline.SetValueAtTime(0.3f, t1, rv);
|
||||
is(rv, NS_OK, "SetValueAtTime succeeded");
|
||||
timeline.SetValueAtTime(0.4f, t2, rv);
|
||||
is(rv, NS_OK, "SetValueAtTime succeeded");
|
||||
timeline.LinearRampToValueAtTime(1.0f, t3, rv);
|
||||
is(rv, NS_OK, "LinearRampToValueAtTime succeeded");
|
||||
timeline.LinearRampToValueAtTime(0.15f, t4, rv);
|
||||
is(rv, NS_OK, "LinearRampToValueAtTime succeeded");
|
||||
timeline.ExponentialRampToValueAtTime(0.75f, t5, rv);
|
||||
is(rv, NS_OK, "ExponentialRampToValueAtTime succeeded");
|
||||
timeline.ExponentialRampToValueAtTime(0.05f, t6, rv);
|
||||
is(rv, NS_OK, "ExponentialRampToValueAtTime succeeded");
|
||||
timeline.SetValueCurveAtTime(curve, curveLength, t6, t7 - t6, rv);
|
||||
is(rv, NS_OK, "SetValueCurveAtTime succeeded");
|
||||
|
||||
is(timeline.GetValueAtTime(0.0), 0.2f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.05), 0.2f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.1), 0.3f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.15), 0.3f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.2), 0.4f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.25), (0.4f + 1.0f) / 2, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.3), 1.0f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.35), (1.0f + 0.15f) / 2, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.4), 0.15f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.45), (0.15f * powf(0.75f / 0.15f, 0.05f / 0.2f)), "Correct value");
|
||||
is(timeline.GetValueAtTime(0.5), (0.15f * powf(0.75f / 0.15f, 0.5f)), "Correct value");
|
||||
is(timeline.GetValueAtTime(0.55), (0.15f * powf(0.75f / 0.15f, 0.15f / 0.2f)), "Correct value");
|
||||
is(timeline.GetValueAtTime(0.6), 0.75f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.65), (0.75f * powf(0.05f / 0.75f, 0.5f)), "Correct value");
|
||||
is(timeline.GetValueAtTime(0.7), 0.0f, "Correct value");
|
||||
is(timeline.GetValueAtTime(0.85), 1.0f, "Correct value");
|
||||
is(timeline.GetValueAtTime(1.0), curve[curveLength - 1], "Correct value");
|
||||
|
||||
delete[] curve;
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, InvalidEvents)
|
||||
{
|
||||
static_assert(numeric_limits<float>::has_quiet_NaN, "Platform must have a quiet NaN");
|
||||
const float NaN = numeric_limits<float>::quiet_NaN();
|
||||
const float Infinity = numeric_limits<float>::infinity();
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
float curve[] = { -1.0f, 0.0f, 1.0f };
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetValueAtTime(NaN, 0.1, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueAtTime(Infinity, 0.1, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueAtTime(-Infinity, 0.1, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.LinearRampToValueAtTime(NaN, 0.2, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.LinearRampToValueAtTime(Infinity, 0.2, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.LinearRampToValueAtTime(-Infinity, 0.2, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.ExponentialRampToValueAtTime(NaN, 0.3, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.ExponentialRampToValueAtTime(Infinity, 0.3, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.ExponentialRampToValueAtTime(-Infinity, 0.4, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.ExponentialRampToValueAtTime(0, 0.5, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetTargetAtTime(NaN, 0.4, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetTargetAtTime(Infinity, 0.4, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetTargetAtTime(-Infinity, 0.4, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetTargetAtTime(0.4f, NaN, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetTargetAtTime(0.4f, Infinity, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetTargetAtTime(0.4f, -Infinity, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueCurveAtTime(nullptr, 0, 1.0, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueCurveAtTime(curve, ArrayLength(curve), NaN, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueCurveAtTime(curve, ArrayLength(curve), Infinity, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueCurveAtTime(curve, ArrayLength(curve), -Infinity, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueCurveAtTime(curve, ArrayLength(curve), 1.0, NaN, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueCurveAtTime(curve, ArrayLength(curve), 1.0, Infinity, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValueCurveAtTime(curve, ArrayLength(curve), 1.0, -Infinity, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, EventReplacement)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
is(timeline.GetEventCount(), 0u, "No events yet");
|
||||
timeline.SetValueAtTime(10.0f, 0.1, rv);
|
||||
is(timeline.GetEventCount(), 1u, "One event scheduled now");
|
||||
timeline.SetValueAtTime(20.0f, 0.1, rv);
|
||||
is(rv, NS_OK, "Event scheduling should be successful");
|
||||
is(timeline.GetEventCount(), 1u, "Event should be replaced");
|
||||
is(timeline.GetValueAtTime(0.1), 20.0f, "The first event should be overwritten");
|
||||
timeline.LinearRampToValueAtTime(30.0f, 0.1, rv);
|
||||
is(rv, NS_OK, "Event scheduling should be successful");
|
||||
is(timeline.GetEventCount(), 2u, "Different event type should be appended");
|
||||
is(timeline.GetValueAtTime(0.1), 30.0f, "The first event should be overwritten");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, EventRemoval)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetValueAtTime(10.0f, 0.1, rv);
|
||||
timeline.SetValueAtTime(15.0f, 0.15, rv);
|
||||
timeline.SetValueAtTime(20.0f, 0.2, rv);
|
||||
timeline.LinearRampToValueAtTime(30.0f, 0.3, rv);
|
||||
is(timeline.GetEventCount(), 4u, "Should have three events initially");
|
||||
timeline.CancelScheduledValues(0.4);
|
||||
is(timeline.GetEventCount(), 4u, "Trying to delete past the end of the array should have no effect");
|
||||
timeline.CancelScheduledValues(0.3);
|
||||
is(timeline.GetEventCount(), 3u, "Should successfully delete one event");
|
||||
timeline.CancelScheduledValues(0.12);
|
||||
is(timeline.GetEventCount(), 1u, "Should successfully delete two events");
|
||||
timeline.CancelAllEvents();
|
||||
ok(timeline.HasSimpleValue(), "No event should remain scheduled");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, BeforeFirstEventSetValue)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetValueAtTime(20.0f, 1.0, rv);
|
||||
is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, BeforeFirstEventSetTarget)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetTargetAtTime(20.0f, 1.0, 5.0, rv);
|
||||
is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, BeforeFirstEventLinearRamp)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.LinearRampToValueAtTime(20.0f, 1.0, rv);
|
||||
is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, BeforeFirstEventExponentialRamp)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.ExponentialRampToValueAtTime(20.0f, 1.0, rv);
|
||||
is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, AfterLastValueEvent)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetValueAtTime(20.0f, 1.0, rv);
|
||||
is(timeline.GetValueAtTime(1.5), 20.0f, "Return the last value after the last SetValue event");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, AfterLastTargetValueEvent)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetTargetAtTime(20.0f, 1.0, 5.0, rv);
|
||||
is(timeline.GetValueAtTime(10.), (20.f + (10.f - 20.f) * expf(-9.0f / 5.0f)), "Return the value after the last SetTarget event based on the curve");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, AfterLastTargetValueEventWithValueSet)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetValue(50.f);
|
||||
timeline.SetTargetAtTime(20.0f, 1.0, 5.0, rv);
|
||||
|
||||
// When using SetTargetValueAtTime, Timeline become stateful: the value for
|
||||
// time t may depend on the time t-1, so we can't just query the value at a
|
||||
// time and get the right value. We have to call GetValueAtTime for the
|
||||
// previous times.
|
||||
for (double i = 0.0; i < 9.99; i+=0.01) {
|
||||
timeline.GetValueAtTime(i);
|
||||
}
|
||||
|
||||
is(timeline.GetValueAtTime(10.), (20.f + (50.f - 20.f) * expf(-9.0f / 5.0f)), "Return the value after SetValue and the last SetTarget event based on the curve");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, Value)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
is(timeline.Value(), 10.0f, "value should initially match the default value");
|
||||
timeline.SetValue(20.0f);
|
||||
is(timeline.Value(), 20.0f, "Should be able to set the value");
|
||||
timeline.SetValueAtTime(20.0f, 1.0, rv);
|
||||
// TODO: The following check needs to change when we compute the value based on the current time of the context
|
||||
is(timeline.Value(), 20.0f, "TODO...");
|
||||
timeline.SetValue(30.0f);
|
||||
is(timeline.Value(), 20.0f, "Should not be able to set the value");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, LinearRampAtZero)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.LinearRampToValueAtTime(20.0f, 0.0, rv);
|
||||
is(timeline.GetValueAtTime(0.0), 20.0f, "Should get the correct value when t0 == t1 == 0");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, ExponentialRampAtZero)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.ExponentialRampToValueAtTime(20.0f, 0.0, rv);
|
||||
is(timeline.GetValueAtTime(0.0), 20.0f, "Should get the correct value when t0 == t1 == 0");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, LinearRampAtSameTime)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetValueAtTime(5.0f, 1.0, rv);
|
||||
timeline.LinearRampToValueAtTime(20.0f, 1.0, rv);
|
||||
is(timeline.GetValueAtTime(1.0), 20.0f, "Should get the correct value when t0 == t1");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, ExponentialRampAtSameTime)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetValueAtTime(5.0f, 1.0, rv);
|
||||
timeline.ExponentialRampToValueAtTime(20.0f, 1.0, rv);
|
||||
is(timeline.GetValueAtTime(1.0), 20.0f, "Should get the correct value when t0 == t1");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, SetTargetZeroTimeConstant)
|
||||
{
|
||||
Timeline timeline(10.0f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetTargetAtTime(20.0f, 1.0, 0.0, rv);
|
||||
is(timeline.GetValueAtTime(1.0), 20.0f, "Should get the correct value when t0 == t1");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, ExponentialInvalidPreviousZeroValue)
|
||||
{
|
||||
Timeline timeline(0.f);
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.ExponentialRampToValueAtTime(1.f, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.SetValue(1.f);
|
||||
rv = NS_OK;
|
||||
timeline.ExponentialRampToValueAtTime(1.f, 1.0, rv);
|
||||
is(rv, NS_OK, "Should succeed this time");
|
||||
timeline.CancelScheduledValues(0.0);
|
||||
is(timeline.GetEventCount(), 0u, "Should have no events scheduled");
|
||||
rv = NS_OK;
|
||||
timeline.SetValueAtTime(0.f, 0.5, rv);
|
||||
is(rv, NS_OK, "Should succeed");
|
||||
timeline.ExponentialRampToValueAtTime(1.f, 1.0, rv);
|
||||
is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
|
||||
timeline.CancelScheduledValues(0.0);
|
||||
is(timeline.GetEventCount(), 0u, "Should have no events scheduled");
|
||||
rv = NS_OK;
|
||||
timeline.ExponentialRampToValueAtTime(1.f, 1.0, rv);
|
||||
is(rv, NS_OK, "Should succeed this time");
|
||||
}
|
||||
|
||||
TEST(AudioEventTimeline, SettingValueCurveTwice)
|
||||
{
|
||||
Timeline timeline(0.f);
|
||||
float curve[] = { -1.0f, 0.0f, 1.0f };
|
||||
|
||||
ErrorResultMock rv;
|
||||
|
||||
timeline.SetValueCurveAtTime(curve, ArrayLength(curve), 0.0f, 0.3f, rv);
|
||||
timeline.SetValueCurveAtTime(curve, ArrayLength(curve), 0.0f, 0.3f, rv);
|
||||
is(rv, NS_OK, "SetValueCurveAtTime succeeded");
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'TestAudioEventTimeline.cpp',
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'..',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul-gtest'
|
@ -9,8 +9,6 @@ with Files('*'):
|
||||
|
||||
DIRS += ['blink']
|
||||
|
||||
TEST_DIRS += ['gtest']
|
||||
|
||||
MOCHITEST_MANIFESTS += [
|
||||
'test/blink/mochitest.ini',
|
||||
'test/mochitest.ini',
|
||||
|
@ -73,8 +73,6 @@ tags=capturestream
|
||||
[test_audioParamGain.html]
|
||||
[test_audioParamLinearRamp.html]
|
||||
[test_audioParamSetCurveAtTime.html]
|
||||
[test_audioParamSetCurveAtTimeTwice.html]
|
||||
[test_audioParamSetCurveAtTimeZeroDuration.html]
|
||||
[test_audioParamSetTargetAtTime.html]
|
||||
[test_audioParamSetTargetAtTimeZeroTimeConstant.html]
|
||||
[test_audioParamSetValueAtTime.html]
|
||||
|
@ -1,68 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test AudioParam.setValueCurveAtTime twice</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
|
||||
function linearInterpolate(t0, v0, t1, v1, t)
|
||||
{
|
||||
return v0 + (v1 - v0) * ((t - t0) / (t1 - t0));
|
||||
}
|
||||
|
||||
var T0 = 0;
|
||||
|
||||
var gTest = {
|
||||
length: 2048,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var curve2 = new Float32Array(100);
|
||||
for (var i = 0; i < 100; ++i) {
|
||||
curve2[i] = Math.sin(220 * 6 * Math.PI * i / context.sampleRate);
|
||||
}
|
||||
|
||||
var source = context.createConstantSource();
|
||||
|
||||
var gain = context.createGain();
|
||||
gain.gain.setValueCurveAtTime(curve2, T0, this.duration/2);
|
||||
//Set a different curve from the first one
|
||||
gain.gain.setValueCurveAtTime(this.curve, T0, this.duration);
|
||||
|
||||
source.connect(gain);
|
||||
|
||||
source.start(0);
|
||||
return gain;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
this.duration = 1024 / context.sampleRate;
|
||||
this.curve = new Float32Array(100);
|
||||
for (var i = 0; i < 100; ++i) {
|
||||
this.curve[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
|
||||
}
|
||||
var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate);
|
||||
for (var i = 0; i < 2048; ++i) {
|
||||
step = 1024.0/99.0;
|
||||
var current = Math.floor(i / step);
|
||||
var next = current + 1;
|
||||
if (next < this.curve.length) {
|
||||
expectedBuffer.getChannelData(0)[i] = linearInterpolate(current*step, this.curve[current], next*step, this.curve[next], i);
|
||||
} else {
|
||||
expectedBuffer.getChannelData(0)[i] = this.curve[99];
|
||||
}
|
||||
}
|
||||
return expectedBuffer;
|
||||
},
|
||||
};
|
||||
|
||||
runTest();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,57 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test AudioParam.linearRampToValue</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var T0 = 0;
|
||||
|
||||
var gTest = {
|
||||
length: 2048,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(1, 2048, context.sampleRate);
|
||||
for (var i = 0; i < 2048; ++i) {
|
||||
sourceBuffer.getChannelData(0)[i] = 1;
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var gain = context.createGain();
|
||||
gain.gain.setValueCurveAtTime(this.curve, this.T0, 0);
|
||||
|
||||
source.connect(gain);
|
||||
|
||||
source.start(0);
|
||||
return gain;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
this.T0 = 1024 / context.sampleRate;
|
||||
this.curve = new Float32Array(100);
|
||||
for (var i = 0; i < 100; ++i) {
|
||||
this.curve[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
|
||||
}
|
||||
var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate);
|
||||
for (var i = 0; i < 1024; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 1;
|
||||
}
|
||||
for (var i = 1024; i < 2048; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = this.curve[99];
|
||||
}
|
||||
return expectedBuffer;
|
||||
},
|
||||
};
|
||||
|
||||
runTest();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -29,9 +29,9 @@ add_task(async () => {
|
||||
payments.add(payment);
|
||||
}
|
||||
is(payments.size, TABS_TO_OPEN, `Should be ${TABS_TO_OPEN} unique objects.`);
|
||||
tabs.forEach(async tab => {
|
||||
for (const tab of tabs) {
|
||||
await TestUtils.waitForTick();
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
}
|
||||
Services.prefs.setBoolPref("dom.payments.request.enabled", false);
|
||||
});
|
||||
|
@ -1999,13 +1999,9 @@ HTMLEditRules::InsertBRElement(const EditorDOMPoint& aPointToBreak)
|
||||
}
|
||||
// If the container of the break is a link, we need to split it and
|
||||
// insert new <br> between the split links.
|
||||
nsCOMPtr<nsINode> linkDOMNode;
|
||||
if (HTMLEditorRef().IsInLink(pointToBreak.GetContainer(),
|
||||
address_of(linkDOMNode))) {
|
||||
nsCOMPtr<Element> linkNode = do_QueryInterface(linkDOMNode);
|
||||
if (NS_WARN_IF(!linkNode)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RefPtr<Element> linkNode =
|
||||
HTMLEditor::GetLinkElement(pointToBreak.GetContainer());
|
||||
if (linkNode) {
|
||||
SplitNodeResult splitLinkNodeResult =
|
||||
HTMLEditorRef().SplitNodeDeepWithTransaction(
|
||||
*linkNode, pointToBreak,
|
||||
|
@ -737,7 +737,7 @@ protected: // May be called by friends.
|
||||
const nsAString* aValue,
|
||||
nsAString* outValue = nullptr);
|
||||
|
||||
bool IsInLink(nsINode* aNode, nsCOMPtr<nsINode>* outLink = nullptr);
|
||||
static dom::Element* GetLinkElement(nsINode* aNode);
|
||||
|
||||
/**
|
||||
* Small utility routine to test if a break node is visible to user.
|
||||
|
@ -360,7 +360,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
}
|
||||
|
||||
// Remember if we are in a link.
|
||||
bool bStartedInLink = IsInLink(pointToInsert.GetContainer());
|
||||
bool bStartedInLink = !!GetLinkElement(pointToInsert.GetContainer());
|
||||
|
||||
// Are we in a text node? If so, split it.
|
||||
if (pointToInsert.IsInTextNode()) {
|
||||
@ -659,15 +659,13 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
selection->Collapse(selNode, selOffset);
|
||||
|
||||
// if we just pasted a link, discontinue link style
|
||||
nsCOMPtr<nsINode> link;
|
||||
nsCOMPtr<nsIContent> linkContent;
|
||||
if (!bStartedInLink &&
|
||||
IsInLink(selNode, address_of(link))) {
|
||||
(linkContent = GetLinkElement(selNode))) {
|
||||
// so, if we just pasted a link, I split it. Why do that instead of just
|
||||
// nudging selection point beyond it? Because it might have ended in a BR
|
||||
// that is not visible. If so, the code above just placed selection
|
||||
// inside that. So I split it instead.
|
||||
nsCOMPtr<nsIContent> linkContent = do_QueryInterface(link);
|
||||
NS_ENSURE_STATE(linkContent || !link);
|
||||
SplitNodeResult splitLinkResult =
|
||||
SplitNodeDeepWithTransaction(
|
||||
*linkContent, EditorRawDOMPoint(selNode, selOffset),
|
||||
@ -687,25 +685,21 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
return rules->DidDoAction(selection, subActionInfo, rv);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditor::IsInLink(nsINode* aNode,
|
||||
nsCOMPtr<nsINode>* outLink)
|
||||
// static
|
||||
Element*
|
||||
HTMLEditor::GetLinkElement(nsINode* aNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, false);
|
||||
if (outLink) {
|
||||
*outLink = nullptr;
|
||||
if (NS_WARN_IF(!aNode)) {
|
||||
return nullptr;
|
||||
}
|
||||
nsINode* node = aNode;
|
||||
while (node) {
|
||||
if (HTMLEditUtils::IsLink(node)) {
|
||||
if (outLink) {
|
||||
*outLink = node;
|
||||
}
|
||||
return true;
|
||||
return node->AsElement();
|
||||
}
|
||||
node = node->GetParentNode();
|
||||
}
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1282,7 +1282,10 @@ PREF("preferences.allow.omt-write", bool, true)
|
||||
// Privacy prefs
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Whether Content Blocking has been enabled
|
||||
// Whether Content Blocking has been enabled.
|
||||
// Please note that privacy protections provided by Gecko may depend on this preference.
|
||||
// Turning this off may disable some protections. Please do not turn this pref off without
|
||||
// realizing the implications of what you're doing.
|
||||
VARCACHE_PREF(
|
||||
"browser.contentblocking.enabled",
|
||||
browser_contentblocking_enabled,
|
||||
|
@ -39,7 +39,7 @@ SimpleChannelParent::NotifyTrackingProtectionDisabled()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SimpleChannelParent::NotifyTrackingCookieBlocked()
|
||||
SimpleChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason)
|
||||
{
|
||||
// Nothing to do.
|
||||
return NS_OK;
|
||||
|
@ -38,7 +38,7 @@ interface nsIParentChannel : nsIStreamListener
|
||||
* Called to notify the HttpChannelChild that cookie has been blocked for
|
||||
* this load.
|
||||
*/
|
||||
[noscript] void notifyTrackingCookieBlocked();
|
||||
[noscript] void notifyTrackingCookieBlocked(in uint32_t aRejectedReason);
|
||||
|
||||
/**
|
||||
* Called to set matched information when URL matches SafeBrowsing list.
|
||||
|
@ -188,7 +188,8 @@ CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel)
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign &&
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel,
|
||||
uri)) {
|
||||
uri,
|
||||
nullptr)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
@ -382,7 +383,7 @@ CookieServiceChild::GetCookieStringFromCookieHashTable(nsIURI *a
|
||||
aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted, nullptr,
|
||||
CountCookiesFromHashTable(baseDomain, aOriginAttrs),
|
||||
aOriginAttrs);
|
||||
aOriginAttrs, nullptr);
|
||||
|
||||
if (cookieStatus != STATUS_ACCEPTED && cookieStatus != STATUS_ACCEPT_SESSION) {
|
||||
return;
|
||||
@ -589,7 +590,8 @@ CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign &&
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel,
|
||||
aHostURI)) {
|
||||
aHostURI,
|
||||
nullptr)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
@ -649,7 +651,8 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign &&
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel,
|
||||
aHostURI)) {
|
||||
aHostURI,
|
||||
nullptr)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
@ -701,7 +704,7 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
isForeign, isTrackingResource,
|
||||
firstPartyStorageAccessGranted, aCookieString,
|
||||
CountCookiesFromHashTable(baseDomain, attrs),
|
||||
attrs);
|
||||
attrs, nullptr);
|
||||
|
||||
if (cookieStatus != STATUS_ACCEPTED && cookieStatus != STATUS_ACCEPT_SESSION) {
|
||||
return NS_OK;
|
||||
|
@ -166,7 +166,8 @@ CookieServiceParent::TrackCookieLoad(nsIChannel *aChannel)
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign &&
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel,
|
||||
uri)) {
|
||||
uri,
|
||||
nullptr)) {
|
||||
storageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
@ -2050,7 +2051,8 @@ nsCookieService::GetCookieStringCommon(nsIURI *aHostURI,
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign &&
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel,
|
||||
aHostURI)) {
|
||||
aHostURI,
|
||||
nullptr)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
@ -2160,7 +2162,8 @@ nsCookieService::SetCookieStringCommon(nsIURI *aHostURI,
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign &&
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel,
|
||||
aHostURI)) {
|
||||
aHostURI,
|
||||
nullptr)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
@ -2219,6 +2222,7 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
|
||||
// check default prefs
|
||||
uint32_t priorCookieCount = 0;
|
||||
uint32_t rejectedReason = 0;
|
||||
nsAutoCString hostFromURI;
|
||||
aHostURI->GetHost(hostFromURI);
|
||||
CountCookiesFromHost(hostFromURI, &priorCookieCount);
|
||||
@ -2228,13 +2232,15 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted,
|
||||
aCookieHeader.get(), priorCookieCount,
|
||||
aOriginAttrs);
|
||||
aOriginAttrs, &rejectedReason);
|
||||
|
||||
MOZ_ASSERT_IF(rejectedReason, cookieStatus == STATUS_REJECTED);
|
||||
|
||||
// fire a notification if third party or if cookie was rejected
|
||||
// (but not if there was an error)
|
||||
switch (cookieStatus) {
|
||||
case STATUS_REJECTED:
|
||||
NotifyRejected(aHostURI, aChannel);
|
||||
NotifyRejected(aHostURI, aChannel, rejectedReason);
|
||||
if (aIsForeign) {
|
||||
NotifyThirdParty(aHostURI, false, aChannel);
|
||||
}
|
||||
@ -2264,14 +2270,15 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
|
||||
// notify observers that a cookie was rejected due to the users' prefs.
|
||||
void
|
||||
nsCookieService::NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel)
|
||||
nsCookieService::NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel,
|
||||
uint32_t aRejectedReason)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(aHostURI, "cookie-rejected", nullptr);
|
||||
}
|
||||
|
||||
AntiTrackingCommon::NotifyRejection(aChannel);
|
||||
AntiTrackingCommon::NotifyRejection(aChannel, aRejectedReason);
|
||||
}
|
||||
|
||||
// notify observers that a third-party cookie was accepted/rejected
|
||||
@ -3203,7 +3210,7 @@ nsCookieService::GetCookiesForURI(nsIURI *aHostURI,
|
||||
aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted,
|
||||
nullptr, priorCookieCount,
|
||||
aOriginAttrs);
|
||||
aOriginAttrs, nullptr);
|
||||
|
||||
// for GetCookie(), we don't fire rejection notifications.
|
||||
switch (cookieStatus) {
|
||||
@ -3610,7 +3617,8 @@ nsCookieService::SetCookieInternal(nsIURI *aHostURI,
|
||||
&permission);
|
||||
if (!permission) {
|
||||
COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader, "cookie rejected by permission manager");
|
||||
NotifyRejected(aHostURI, aChannel);
|
||||
NotifyRejected(aHostURI, aChannel,
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION);
|
||||
return newCookie;
|
||||
}
|
||||
|
||||
@ -4188,10 +4196,20 @@ nsCookieService::CheckPrefs(nsICookiePermission *aPermissionService,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
const char *aCookieHeader,
|
||||
const int aNumOfCookies,
|
||||
const OriginAttributes &aOriginAttrs)
|
||||
const OriginAttributes &aOriginAttrs,
|
||||
uint32_t *aRejectedReason)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Let's use a internal value in order to avoid a null check on
|
||||
// aRejectedReason everywhere.
|
||||
uint32_t rejectedReason = 0;
|
||||
if (!aRejectedReason) {
|
||||
aRejectedReason = &rejectedReason;
|
||||
}
|
||||
|
||||
*aRejectedReason = 0;
|
||||
|
||||
// don't let ftp sites get/set cookies (could be a security issue)
|
||||
bool ftp;
|
||||
if (NS_SUCCEEDED(aHostURI->SchemeIs("ftp", &ftp)) && ftp) {
|
||||
@ -4221,6 +4239,7 @@ nsCookieService::CheckPrefs(nsICookiePermission *aPermissionService,
|
||||
case nsICookiePermission::ACCESS_DENY:
|
||||
COOKIE_LOGFAILURE(aCookieHeader ? SET_COOKIE : GET_COOKIE, aHostURI,
|
||||
aCookieHeader, "cookies are blocked for this site");
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION;
|
||||
return STATUS_REJECTED;
|
||||
|
||||
case nsICookiePermission::ACCESS_ALLOW:
|
||||
@ -4231,6 +4250,7 @@ nsCookieService::CheckPrefs(nsICookiePermission *aPermissionService,
|
||||
COOKIE_LOGFAILURE(aCookieHeader ? SET_COOKIE : GET_COOKIE, aHostURI,
|
||||
aCookieHeader, "third party cookies are blocked "
|
||||
"for this site");
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION;
|
||||
return STATUS_REJECTED;
|
||||
|
||||
}
|
||||
@ -4243,6 +4263,7 @@ nsCookieService::CheckPrefs(nsICookiePermission *aPermissionService,
|
||||
COOKIE_LOGFAILURE(aCookieHeader ? SET_COOKIE : GET_COOKIE, aHostURI,
|
||||
aCookieHeader, "third party cookies are blocked "
|
||||
"for this site");
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION;
|
||||
return STATUS_REJECTED;
|
||||
}
|
||||
return STATUS_ACCEPTED;
|
||||
@ -4256,12 +4277,14 @@ nsCookieService::CheckPrefs(nsICookiePermission *aPermissionService,
|
||||
if (aIsForeign && aIsTrackingResource && !aFirstPartyStorageAccessGranted &&
|
||||
aCookieBehavior == nsICookieService::BEHAVIOR_REJECT_TRACKER) {
|
||||
COOKIE_LOGFAILURE(aCookieHeader ? SET_COOKIE : GET_COOKIE, aHostURI, aCookieHeader, "cookies are disabled in trackers");
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER;
|
||||
return STATUS_REJECTED;
|
||||
}
|
||||
|
||||
// check default prefs
|
||||
if (aCookieBehavior == nsICookieService::BEHAVIOR_REJECT) {
|
||||
COOKIE_LOGFAILURE(aCookieHeader ? SET_COOKIE : GET_COOKIE, aHostURI, aCookieHeader, "cookies are disabled");
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL;
|
||||
return STATUS_REJECTED;
|
||||
}
|
||||
|
||||
@ -4272,12 +4295,14 @@ nsCookieService::CheckPrefs(nsICookiePermission *aPermissionService,
|
||||
if (aCookieBehavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN &&
|
||||
!aFirstPartyStorageAccessGranted) {
|
||||
COOKIE_LOGFAILURE(aCookieHeader ? SET_COOKIE : GET_COOKIE, aHostURI, aCookieHeader, "context is third party");
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
|
||||
return STATUS_REJECTED;
|
||||
}
|
||||
|
||||
if (aCookieBehavior == nsICookieService::BEHAVIOR_LIMIT_FOREIGN) {
|
||||
if (aNumOfCookies == 0) {
|
||||
COOKIE_LOGFAILURE(aCookieHeader ? SET_COOKIE : GET_COOKIE, aHostURI, aCookieHeader, "context is third party");
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
|
||||
return STATUS_REJECTED;
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ class nsCookieService final : public nsICookieService
|
||||
static bool IsSameSiteEnabled();
|
||||
static bool PathMatches(nsCookie* aCookie, const nsACString& aPath);
|
||||
static bool CanSetCookie(nsIURI *aHostURI, const nsCookieKey& aKey, nsCookieAttributes &aCookieAttributes, bool aRequireHostMatch, CookieStatus aStatus, nsDependentCString &aCookieHeader, int64_t aServerTime, bool aFromHttp, nsIChannel* aChannel, bool aLeaveSercureAlone, bool &aSetCookie, mozIThirdPartyUtil* aThirdPartyUtil);
|
||||
static CookieStatus CheckPrefs(nsICookiePermission *aPermissionServices, uint8_t aCookieBehavior, bool aThirdPartySession, bool aThirdPartyNonsecureSession, nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aIsFirstPartyStorageAccessGranted, const char *aCookieHeader, const int aNumOfCookies, const OriginAttributes& aOriginAttrs);
|
||||
static CookieStatus CheckPrefs(nsICookiePermission *aPermissionServices, uint8_t aCookieBehavior, bool aThirdPartySession, bool aThirdPartyNonsecureSession, nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aIsFirstPartyStorageAccessGranted, const char *aCookieHeader, const int aNumOfCookies, const OriginAttributes& aOriginAttrs, uint32_t* aRejectedReason);
|
||||
static int64_t ParseServerTime(const nsCString &aServerTime);
|
||||
void GetCookiesForURI(nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aFirstPartyStorageAccessGranted, bool aIsSafeTopLevelNav, bool aIsTopLevelForeign, bool aHttpBound, const OriginAttributes& aOriginAttrs, nsTArray<nsCookie*>& aCookieList);
|
||||
|
||||
@ -319,7 +319,7 @@ class nsCookieService final : public nsICookieService
|
||||
bool FindSecureCookie(const nsCookieKey& aKey, nsCookie* aCookie);
|
||||
int64_t FindStaleCookie(nsCookieEntry *aEntry, int64_t aCurrentTime, nsIURI* aSource, const mozilla::Maybe<bool> &aIsSecure, nsListIter &aIter);
|
||||
void TelemetryForEvictingStaleCookie(nsCookie* aEvicted, int64_t oldestCookieTime);
|
||||
void NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel);
|
||||
void NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel, uint32_t aRejectedReason);
|
||||
void NotifyThirdParty(nsIURI *aHostURI, bool aAccepted, nsIChannel *aChannel);
|
||||
void NotifyChanged(nsISupports *aSubject, const char16_t *aData, bool aOldCookieIsSession = false, bool aFromHttp = false);
|
||||
void NotifyPurged(nsICookie2* aCookie);
|
||||
|
@ -39,7 +39,7 @@ DataChannelParent::NotifyTrackingProtectionDisabled()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataChannelParent::NotifyTrackingCookieBlocked()
|
||||
DataChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason)
|
||||
{
|
||||
// Nothing to do.
|
||||
return NS_OK;
|
||||
|
@ -39,7 +39,7 @@ FileChannelParent::NotifyTrackingProtectionDisabled()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileChannelParent::NotifyTrackingCookieBlocked()
|
||||
FileChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason)
|
||||
{
|
||||
// Nothing to do.
|
||||
return NS_OK;
|
||||
|
@ -577,7 +577,7 @@ FTPChannelParent::NotifyTrackingProtectionDisabled()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FTPChannelParent::NotifyTrackingCookieBlocked()
|
||||
FTPChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason)
|
||||
{
|
||||
// One day, this should probably be filled in.
|
||||
return NS_OK;
|
||||
|
@ -348,7 +348,7 @@ HttpBackgroundChannelChild::RecvNotifyTrackingProtectionDisabled()
|
||||
}
|
||||
|
||||
IPCResult
|
||||
HttpBackgroundChannelChild::RecvNotifyTrackingCookieBlocked()
|
||||
HttpBackgroundChannelChild::RecvNotifyTrackingCookieBlocked(const uint32_t& aRejectedReason)
|
||||
{
|
||||
LOG(("HttpBackgroundChannelChild::RecvNotifyTrackingCookieBlocked [this=%p]\n", this));
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
@ -357,7 +357,7 @@ HttpBackgroundChannelChild::RecvNotifyTrackingCookieBlocked()
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mChannelChild->ProcessNotifyTrackingCookieBlocked();
|
||||
mChannelChild->ProcessNotifyTrackingCookieBlocked(aRejectedReason);
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ protected:
|
||||
|
||||
IPCResult RecvNotifyTrackingProtectionDisabled() override;
|
||||
|
||||
IPCResult RecvNotifyTrackingCookieBlocked() override;
|
||||
IPCResult RecvNotifyTrackingCookieBlocked(const uint32_t& aRejectedReason) override;
|
||||
|
||||
IPCResult RecvNotifyTrackingResource(const bool& aIsThirdParty) override;
|
||||
|
||||
|
@ -380,7 +380,7 @@ HttpBackgroundChannelParent::OnNotifyTrackingProtectionDisabled()
|
||||
}
|
||||
|
||||
bool
|
||||
HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked()
|
||||
HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked(uint32_t aRejectedReason)
|
||||
{
|
||||
LOG(("HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked [this=%p]\n", this));
|
||||
AssertIsInMainProcess();
|
||||
@ -391,11 +391,13 @@ HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked()
|
||||
|
||||
if (!IsOnBackgroundThread()) {
|
||||
MutexAutoLock lock(mBgThreadMutex);
|
||||
RefPtr<HttpBackgroundChannelParent> self = this;
|
||||
nsresult rv = mBackgroundThread->Dispatch(
|
||||
NewRunnableMethod(
|
||||
NS_NewRunnableFunction(
|
||||
"net::HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked",
|
||||
this,
|
||||
&HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked),
|
||||
[self, aRejectedReason]() {
|
||||
self->OnNotifyTrackingCookieBlocked(aRejectedReason);
|
||||
}),
|
||||
NS_DISPATCH_NORMAL);
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
|
||||
@ -403,7 +405,7 @@ HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked()
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
return SendNotifyTrackingCookieBlocked();
|
||||
return SendNotifyTrackingCookieBlocked(aRejectedReason);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
bool OnNotifyTrackingProtectionDisabled();
|
||||
|
||||
// To send NotifyTrackingCookieBlocked message over background channel.
|
||||
bool OnNotifyTrackingCookieBlocked();
|
||||
bool OnNotifyTrackingCookieBlocked(uint32_t aRejectedReason);
|
||||
|
||||
// To send NotifyTrackingResource message over background channel.
|
||||
bool OnNotifyTrackingResource(bool aIsThirdParty);
|
||||
|
@ -2043,7 +2043,7 @@ HttpChannelChild::ProcessNotifyTrackingProtectionDisabled()
|
||||
}
|
||||
|
||||
void
|
||||
HttpChannelChild::ProcessNotifyTrackingCookieBlocked()
|
||||
HttpChannelChild::ProcessNotifyTrackingCookieBlocked(uint32_t aRejectedReason)
|
||||
{
|
||||
LOG(("HttpChannelChild::ProcessNotifyTrackingCookieBlocked [this=%p]\n", this));
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
@ -2053,8 +2053,8 @@ HttpChannelChild::ProcessNotifyTrackingCookieBlocked()
|
||||
neckoTarget->Dispatch(
|
||||
NS_NewRunnableFunction(
|
||||
"nsChannelClassifier::NotifyTrackingCookieBlocked",
|
||||
[self]() {
|
||||
AntiTrackingCommon::NotifyRejection(self);
|
||||
[self, aRejectedReason]() {
|
||||
AntiTrackingCommon::NotifyRejection(self, aRejectedReason);
|
||||
}),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ private:
|
||||
void ProcessFlushedForDiversion();
|
||||
void ProcessDivertMessages();
|
||||
void ProcessNotifyTrackingProtectionDisabled();
|
||||
void ProcessNotifyTrackingCookieBlocked();
|
||||
void ProcessNotifyTrackingCookieBlocked(uint32_t aRejectedReason);
|
||||
void ProcessNotifyTrackingResource(bool aIsThirdParty);
|
||||
void ProcessSetClassifierMatchedInfo(const nsCString& aList,
|
||||
const nsCString& aProvider,
|
||||
|
@ -1811,12 +1811,12 @@ HttpChannelParent::NotifyTrackingProtectionDisabled()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelParent::NotifyTrackingCookieBlocked()
|
||||
HttpChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason)
|
||||
{
|
||||
LOG(("HttpChannelParent::NotifyTrackingCookieBlocked [this=%p]\n", this));
|
||||
if (!mIPCClosed) {
|
||||
MOZ_ASSERT(mBgParent);
|
||||
Unused << NS_WARN_IF(!mBgParent->OnNotifyTrackingCookieBlocked());
|
||||
Unused << NS_WARN_IF(!mBgParent->OnNotifyTrackingCookieBlocked(aRejectedReason));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ child:
|
||||
async NotifyTrackingProtectionDisabled();
|
||||
|
||||
// Tell the child that tracking cookies are blocked for this load.
|
||||
async NotifyTrackingCookieBlocked();
|
||||
async NotifyTrackingCookieBlocked(uint32_t aRejectedReason);
|
||||
|
||||
// Tell the child that the resource being loaded is on the tracking
|
||||
// protection list.
|
||||
|
@ -745,6 +745,8 @@ nsHttpChannel::ConnectOnTailUnblock()
|
||||
|
||||
bool isTrackingResource = mIsThirdPartyTrackingResource; // is atomic
|
||||
if (isTrackingResource && CheckFastBlocked()) {
|
||||
AntiTrackingCommon::NotifyRejection(this,
|
||||
nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT);
|
||||
Unused << AsyncAbort(NS_ERROR_ABORT);
|
||||
CloseCacheEntry(false);
|
||||
return NS_OK;
|
||||
@ -3902,7 +3904,7 @@ nsHttpChannel::OpenCacheEntryInternal(bool isHttps,
|
||||
extension.Append("TRR");
|
||||
}
|
||||
|
||||
if (!AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(this, mURI)) {
|
||||
if (!AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(this, mURI, nullptr)) {
|
||||
nsCOMPtr<nsIURI> topWindowURI;
|
||||
rv = GetTopWindowURI(getter_AddRefs(topWindowURI));
|
||||
bool isDocument = false;
|
||||
|
@ -37,7 +37,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
/// The type used for storing pseudo-class string arguments.
|
||||
pub type PseudoClassStringArg = ThinBoxedSlice<u16>;
|
||||
pub type PseudoClassStringArg = Atom;
|
||||
|
||||
macro_rules! pseudo_class_name {
|
||||
(bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*],
|
||||
@ -72,24 +72,13 @@ impl ToCss for NonTSPseudoClass {
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
use cssparser::CssStringWriter;
|
||||
use std::fmt::Write;
|
||||
macro_rules! pseudo_class_serialize {
|
||||
(bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*],
|
||||
string: [$(($s_css:expr, $s_name:ident, $s_gecko_type:tt, $s_state:tt, $s_flags:tt),)*]) => {
|
||||
match *self {
|
||||
$(NonTSPseudoClass::$name => concat!(":", $css),)*
|
||||
$(NonTSPseudoClass::$s_name(ref s) => {
|
||||
dest.write_str(concat!(":", $s_css, "("))?;
|
||||
{
|
||||
// FIXME(emilio): Avoid the extra allocation!
|
||||
let mut css = CssStringWriter::new(dest);
|
||||
|
||||
// Discount the null char in the end from the
|
||||
// string.
|
||||
css.write_str(&String::from_utf16(&s[..s.len() - 1]).unwrap())?;
|
||||
}
|
||||
return dest.write_str(")")
|
||||
return write!(dest, concat!(":", $s_css, "({})"), s)
|
||||
}, )*
|
||||
NonTSPseudoClass::MozLocaleDir(ref dir) => {
|
||||
dest.write_str(":-moz-locale-dir(")?;
|
||||
@ -405,10 +394,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
||||
match_ignore_ascii_case! { &name,
|
||||
$($s_css => {
|
||||
let name = parser.expect_ident_or_string()?;
|
||||
// convert to null terminated utf16 string
|
||||
// since that's what Gecko deals with
|
||||
let utf16: Vec<u16> = name.encode_utf16().chain(Some(0u16)).collect();
|
||||
NonTSPseudoClass::$s_name(utf16.into_boxed_slice().into())
|
||||
NonTSPseudoClass::$s_name(Atom::from(name.as_ref()))
|
||||
}, )*
|
||||
"-moz-locale-dir" => {
|
||||
NonTSPseudoClass::MozLocaleDir(Direction::parse(parser)?)
|
||||
|
@ -1721,10 +1721,6 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||
// Gecko supports :lang() from CSS Selectors 3, which only accepts a
|
||||
// single language tag, and which performs simple dash-prefix matching
|
||||
// on it.
|
||||
debug_assert!(
|
||||
value.len() > 0 && value[value.len() - 1] == 0,
|
||||
"expected value to be null terminated"
|
||||
);
|
||||
let override_lang_ptr = match &override_lang {
|
||||
&Some(Some(ref atom)) => atom.as_ptr(),
|
||||
_ => ptr::null_mut(),
|
||||
@ -1734,7 +1730,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||
self.0,
|
||||
override_lang_ptr,
|
||||
override_lang.is_some(),
|
||||
value.as_ptr(),
|
||||
value.as_slice().as_ptr(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,70 +0,0 @@
|
||||
[audioparam-exceptional-values.html]
|
||||
[X gain.gain.setValueAtTime(1,-1) threw "NotSupportedError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.linearRampToValueAtTime(1,-1) threw "NotSupportedError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.exponentialRampToValueAtTime(1,-1) threw "NotSupportedError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setTargetAtTime(1,-1,1) threw "NotSupportedError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setTargetAtTime(1,1,-1) threw "NotSupportedError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setValueCurveAtTime([0,0,0\],-1,1) threw "NotSupportedError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setValueCurveAtTime([0,0,0\],1,-1) did not throw an exception.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setValueCurveAtTime(curve, 1, 0) did not throw an exception.]
|
||||
expected: FAIL
|
||||
|
||||
[< [special cases 1\] 8 out of 8 assertions were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.exponentialRampToValueAtTime(0,1) threw "SyntaxError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.exponentialRampToValueAtTime(-1e-100,1) threw "SyntaxError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.exponentialRampToValueAtTime(1e-100,1) threw "SyntaxError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[< [special cases 2\] 3 out of 3 assertions were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[# AUDIT TASK RUNNER FINISHED: 2 out of 6 tasks were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setTargetAtTime(1,-1,1) threw "NotSupportedError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.exponentialRampToValueAtTime(-1e-100,1) threw "SyntaxError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.linearRampToValueAtTime(1,-1) threw "NotSupportedError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.exponentialRampToValueAtTime(0,1) threw "SyntaxError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setValueCurveAtTime([0,0,0\],-1,1) threw "NotSupportedError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setValueAtTime(1,-1) threw "NotSupportedError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.exponentialRampToValueAtTime(1e-100,1) threw "SyntaxError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.exponentialRampToValueAtTime(1,-1) threw "NotSupportedError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X gain.gain.setTargetAtTime(1,1,-1) threw "NotSupportedError" instead of EcmaScript error RangeError.]
|
||||
expected: FAIL
|
||||
|
@ -1,14 +1,8 @@
|
||||
[audioparam-method-chaining.html]
|
||||
[X Calling setValueAtTime() with a negative end time threw "NotSupportedError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X Calling exponentialRampToValueAtTime() with a zero target value threw "SyntaxError" instead of RangeError.]
|
||||
expected: FAIL
|
||||
|
||||
[X The gain value of the second gain node is not equal to 0.5. Got 1.]
|
||||
expected: FAIL
|
||||
|
||||
[< [invalid-operation\] 3 out of 4 assertions were failed.]
|
||||
[< [invalid-operation\] 1 out of 4 assertions were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[# AUDIT TASK RUNNER FINISHED: 1 out of 3 tasks were failed.]
|
||||
|
@ -1,46 +0,0 @@
|
||||
[audioparam-setValueCurve-exceptions.html]
|
||||
[X setValueAtTime(1, 0.018750000000000003) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[X linearRampToValueAtTime(1, 0.018750000000000003) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[X exponentialRampToValueAtTime(1, 0.018750000000000003) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[X setTargetAtTime(1, 0.018750000000000003, 1) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[< [setValueCurve\] 4 out of 6 assertions were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[X setValueCurveAtTime(curve, 0.00625, 0.01) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[X setValueCurveAtTime(curve, 0.018750000000000003, 0.01) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[X setValueCurveAtTime(curve, 0.03125, 0.01) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[X setValueCurveAtTime(curve, 0.043750000000000004, 0.01) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[X setValueCurveAtTime(curve, 0.031415926535897934, 0.01) threw "SyntaxError" instead of NotSupportedError.]
|
||||
expected: FAIL
|
||||
|
||||
[< [automations\] 5 out of 13 assertions were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[X setValueCurveAtTime([\], 0, 0.01) threw "SyntaxError" instead of InvalidStateError.]
|
||||
expected: FAIL
|
||||
|
||||
[X setValueCurveAtTime([1\], 0, 0.01) did not throw an exception.]
|
||||
expected: FAIL
|
||||
|
||||
[< [curve lengths\] 2 out of 3 assertions were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[# AUDIT TASK RUNNER FINISHED: 3 out of 5 tasks were failed.]
|
||||
expected: FAIL
|
||||
|
@ -1,25 +1,10 @@
|
||||
[event-insertion.html]
|
||||
[X setValueCurveAtTime([98,99\], 0.0234375, 0.0078125) incorrectly threw TypeError: "Argument 1 of AudioParam.setValueCurveAtTime does not implement interface Float32Array.".]
|
||||
expected: FAIL
|
||||
|
||||
[X setValueCurveAtTime([3,4\], 0.0234375, 0.0078125) incorrectly threw TypeError: "Argument 1 of AudioParam.setValueCurveAtTime does not implement interface Float32Array.".]
|
||||
expected: FAIL
|
||||
|
||||
[X Output at frame 512 (time 0.03125) is not equal to 4. Got 3.]
|
||||
expected: FAIL
|
||||
|
||||
[< [Insert same event at same time\] 3 out of 12 assertions were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[# AUDIT TASK RUNNER FINISHED: 1 out of 4 tasks were failed.]
|
||||
[< [Insert same event at same time\] 1 out of 12 assertions were failed.]
|
||||
expected: FAIL
|
||||
|
||||
[X Output at frame 384 (time 0.0234375) is not equal to 3. Got 98.]
|
||||
expected: FAIL
|
||||
|
||||
[X Output at frame 512 (time 0.03125) is not equal to 4. Got 99.]
|
||||
expected: FAIL
|
||||
|
||||
[< [Insert same event at same time\] 2 out of 12 assertions were failed.]
|
||||
[# AUDIT TASK RUNNER FINISHED: 1 out of 4 tasks were failed.]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -174,11 +174,16 @@
|
||||
},
|
||||
]);
|
||||
|
||||
// One final test for setValueCurve: duration can't be 0.
|
||||
// Two final tests for setValueCurve: duration must be strictly
|
||||
// positive.
|
||||
should(
|
||||
() => gain.gain.setValueCurveAtTime(curve, 1, 0),
|
||||
'gain.gain.setValueCurveAtTime(curve, 1, 0)')
|
||||
.throw(RangeError);
|
||||
should(
|
||||
() => gain.gain.setValueCurveAtTime(curve, 1, -1),
|
||||
'gain.gain.setValueCurveAtTime(curve, 1, -1)')
|
||||
.throw(RangeError);
|
||||
|
||||
task.done();
|
||||
});
|
||||
|
@ -30,7 +30,7 @@
|
||||
let curveStartTime = 0.1 * testDurationSec;
|
||||
let duration = 0.1 * testDurationSec;
|
||||
|
||||
// Some time that is known to during the setValueCurveTime interval.
|
||||
// Some time that is known to be during the setValueCurveTime interval.
|
||||
let automationTime = curveStartTime + duration / 2;
|
||||
|
||||
should(
|
||||
@ -286,6 +286,61 @@
|
||||
task.done();
|
||||
});
|
||||
|
||||
audit.define('curve overlap', (task, should) => {
|
||||
let context =
|
||||
new OfflineAudioContext(1, testDurationFrames, sampleRate);
|
||||
let g = context.createGain();
|
||||
let startTime = 5;
|
||||
let startTimeLater = 10;
|
||||
let startTimeEarlier = 2.5;
|
||||
let curveDuration = 10;
|
||||
let curveDurationShorter = 5;
|
||||
let curve = [1, 2, 3];
|
||||
|
||||
// An initial curve event
|
||||
should(
|
||||
() => {
|
||||
g.gain.setValueCurveAtTime(curve, startTime, curveDuration);
|
||||
},
|
||||
`g.gain.setValueCurveAtTime([${curve}], ${startTime}, ${curveDuration})`)
|
||||
.notThrow();
|
||||
|
||||
// Check that an exception is thrown when trying to overlap two curves,
|
||||
// in various ways
|
||||
|
||||
// Same start time and end time (curve exactly overlapping)
|
||||
should(
|
||||
() => {
|
||||
g.gain.setValueCurveAtTime(curve, startTime, curveDuration);
|
||||
},
|
||||
`second g.gain.setValueCurveAtTime([${curve}], ${startTime}, ${curveDuration})`)
|
||||
.throw('NotSupportedError');
|
||||
// Same start time, shorter end time
|
||||
should(
|
||||
() => {
|
||||
g.gain.setValueCurveAtTime(curve, startTime, curveDurationShorter);
|
||||
},
|
||||
`g.gain.setValueCurveAtTime([${curve}], ${startTime}, ${curveDurationShorter})`)
|
||||
.throw('NotSupportedError');
|
||||
// Earlier start time, end time after the start time an another curve
|
||||
should(
|
||||
() => {
|
||||
g.gain.setValueCurveAtTime(curve, startTimeEarlier, curveDuration);
|
||||
},
|
||||
`g.gain.setValueCurveAtTime([${curve}], ${startTimeEarlier}, ${curveDuration})`)
|
||||
.throw('NotSupportedError');
|
||||
// Start time after the start time of the other curve, but earlier that
|
||||
// its end.
|
||||
should(
|
||||
() => {
|
||||
g.gain.setValueCurveAtTime(curve, startTimeLater, curveDuration);
|
||||
},
|
||||
`g.gain.setValueCurveAtTime([${curve}], ${startTimeLater}, ${curveDuration})`)
|
||||
.throw('NotSupportedError');
|
||||
|
||||
task.done();
|
||||
});
|
||||
|
||||
audit.define('curve lengths', (task, should) => {
|
||||
let context =
|
||||
new OfflineAudioContext(1, testDurationFrames, sampleRate);
|
||||
|
@ -30,8 +30,8 @@
|
||||
|
||||
// An array of tests to be done. Each entry specifies the event
|
||||
// type and the event time. The events are inserted in the order
|
||||
// given (in |values|), and the second event should replace the
|
||||
// first, as required by the spec.
|
||||
// given (in |values|), and the second event should be inserted
|
||||
// after the first one, as required by the spec.
|
||||
let testCases = [
|
||||
{
|
||||
event: 'setValueAtTime',
|
||||
@ -57,7 +57,7 @@
|
||||
{
|
||||
event: 'setValueCurveAtTime',
|
||||
frame: 3 * RENDER_QUANTUM_FRAMES,
|
||||
values: [[98, 99], [3, 4]],
|
||||
values: [[3, 4]],
|
||||
extraArgs: RENDER_QUANTUM_FRAMES / context.sampleRate,
|
||||
outputTestFrame: 4 * RENDER_QUANTUM_FRAMES,
|
||||
expectedOutputValue: 4
|
||||
|
@ -330,11 +330,18 @@ AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(n
|
||||
|
||||
bool
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWindow,
|
||||
nsIURI* aURI)
|
||||
nsIURI* aURI,
|
||||
uint32_t* aRejectedReason)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
// Let's avoid a null check on aRejectedReason everywhere else.
|
||||
uint32_t rejectedReason = 0;
|
||||
if (!aRejectedReason) {
|
||||
aRejectedReason = &rejectedReason;
|
||||
}
|
||||
|
||||
LOG_SPEC(("Computing whether window %p has access to URI %s", aWindow, _spec), aURI);
|
||||
|
||||
nsGlobalWindowInner* innerWindow = nsGlobalWindowInner::Cast(aWindow);
|
||||
@ -356,7 +363,12 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWin
|
||||
LOG(("CheckCookiePermissionForPrincipal() returned a non-default access code (%d), returning %s",
|
||||
int(access), access != nsICookiePermission::ACCESS_DENY ?
|
||||
"success" : "failure"));
|
||||
return access != nsICookiePermission::ACCESS_DENY;
|
||||
if (access != nsICookiePermission::ACCESS_DENY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION;
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t behavior = CookiesBehavior(toplevelPrincipal);
|
||||
@ -367,6 +379,7 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWin
|
||||
|
||||
if (behavior == nsICookieService::BEHAVIOR_REJECT) {
|
||||
LOG(("The cookie behavior pref mandates rejecting all cookies!"));
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -397,6 +410,7 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWin
|
||||
// change the meaning of BEHAVIOR_LIMIT_FOREIGN to be one which makes sense
|
||||
// for non-cookie storage types, this may change.
|
||||
LOG(("Nothing more to do due to the behavior code %d", int(behavior)));
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -457,16 +471,28 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWin
|
||||
result == nsIPermissionManager::ALLOW_ACTION ?
|
||||
"success" : "failure"), parentPrincipalURI);
|
||||
|
||||
return result == nsIPermissionManager::ALLOW_ACTION;
|
||||
if (result != nsIPermissionManager::ALLOW_ACTION) {
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel,
|
||||
nsIURI* aURI)
|
||||
nsIURI* aURI,
|
||||
uint32_t* aRejectedReason)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
MOZ_ASSERT(aChannel);
|
||||
|
||||
// Let's avoid a null check on aRejectedReason everywhere else.
|
||||
uint32_t rejectedReason = 0;
|
||||
if (!aRejectedReason) {
|
||||
aRejectedReason = &rejectedReason;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> channelURI;
|
||||
Unused << aChannel->GetURI(getter_AddRefs(channelURI));
|
||||
LOG_SPEC(("Computing whether channel %p has access to URI %s", aChannel, _spec),
|
||||
@ -526,7 +552,12 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel
|
||||
LOG(("CheckCookiePermissionForPrincipal() returned a non-default access code (%d), returning %s",
|
||||
int(access), access != nsICookiePermission::ACCESS_DENY ?
|
||||
"success" : "failure"));
|
||||
return access != nsICookiePermission::ACCESS_DENY;
|
||||
if (access != nsICookiePermission::ACCESS_DENY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv) || !channelPrincipal)) {
|
||||
@ -542,6 +573,7 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel
|
||||
|
||||
if (behavior == nsICookieService::BEHAVIOR_REJECT) {
|
||||
LOG(("The cookie behavior pref mandates rejecting all cookies!"));
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -585,6 +617,7 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel
|
||||
// change the meaning of BEHAVIOR_LIMIT_FOREIGN to be one which makes sense
|
||||
// for non-cookie storage types, this may change.
|
||||
LOG(("Nothing more to do due to the behavior code %d", int(behavior)));
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -673,7 +706,12 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel
|
||||
result == nsIPermissionManager::ALLOW_ACTION ?
|
||||
"success" : "failure"), parentPrincipalURI);
|
||||
|
||||
return result == nsIPermissionManager::ALLOW_ACTION;
|
||||
if (result != nsIPermissionManager::ALLOW_ACTION) {
|
||||
*aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -838,8 +876,15 @@ AntiTrackingCommon::IsOnContentBlockingAllowList(nsIURI* aTopWinURI,
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
AntiTrackingCommon::NotifyRejection(nsIChannel* aChannel)
|
||||
AntiTrackingCommon::NotifyRejection(nsIChannel* aChannel,
|
||||
uint32_t aRejectedReason)
|
||||
{
|
||||
MOZ_ASSERT(aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT);
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (!httpChannel) {
|
||||
return;
|
||||
@ -851,7 +896,7 @@ AntiTrackingCommon::NotifyRejection(nsIChannel* aChannel)
|
||||
if (parentChannel) {
|
||||
// This channel is a parent-process proxy for a child process request.
|
||||
// Tell the child process channel to do this instead.
|
||||
parentChannel->NotifyTrackingCookieBlocked();
|
||||
parentChannel->NotifyTrackingCookieBlocked(aRejectedReason);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -870,14 +915,19 @@ AntiTrackingCommon::NotifyRejection(nsIChannel* aChannel)
|
||||
return;
|
||||
}
|
||||
|
||||
pwin->NotifyContentBlockingState(
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, httpChannel);
|
||||
pwin->NotifyContentBlockingState(aRejectedReason, aChannel);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
AntiTrackingCommon::NotifyRejection(nsPIDOMWindowInner* aWindow)
|
||||
AntiTrackingCommon::NotifyRejection(nsPIDOMWindowInner* aWindow,
|
||||
uint32_t aRejectedReason)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT);
|
||||
|
||||
nsIDocument* document = aWindow->GetExtantDoc();
|
||||
if (!document) {
|
||||
@ -897,7 +947,6 @@ AntiTrackingCommon::NotifyRejection(nsPIDOMWindowInner* aWindow)
|
||||
}
|
||||
|
||||
if (pwin) {
|
||||
pwin->NotifyContentBlockingState(
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, httpChannel);
|
||||
pwin->NotifyContentBlockingState(aRejectedReason, httpChannel);
|
||||
}
|
||||
}
|
||||
|
@ -33,9 +33,17 @@ public:
|
||||
// loaded inside the passed 3rd party context tracking resource window.
|
||||
// If the window is first party context, please use
|
||||
// MaybeIsFirstPartyStorageAccessGrantedFor();
|
||||
//
|
||||
// aRejectedReason could be set to one of these values if passed and if the
|
||||
// storage permission is not granted:
|
||||
// * nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION
|
||||
// * nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
|
||||
// * nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL
|
||||
// * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
|
||||
static bool
|
||||
IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* a3rdPartyTrackingWindow,
|
||||
nsIURI* aURI);
|
||||
nsIURI* aURI,
|
||||
uint32_t* aRejectedReason);
|
||||
|
||||
// Note: you should use IsFirstPartyStorageAccessGrantedFor() passing the
|
||||
// nsIHttpChannel! Use this method _only_ if the channel is not available.
|
||||
@ -49,8 +57,11 @@ public:
|
||||
|
||||
// It returns true if the URI has access to the first party storage.
|
||||
// aChannel can be a 3rd party channel, or not.
|
||||
// See IsFirstPartyStorageAccessGrantedFor(window) to see the possible values
|
||||
// of aRejectedReason.
|
||||
static bool
|
||||
IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel, nsIURI* aURI);
|
||||
IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel, nsIURI* aURI,
|
||||
uint32_t* aRejectedReason);
|
||||
|
||||
// This method checks if the principal has the permission to access to the
|
||||
// first party storage.
|
||||
@ -92,11 +103,18 @@ public:
|
||||
// This method can be called on the parent process or on the content process.
|
||||
// The notification is propagated to the child channel if aChannel is a parent
|
||||
// channel proxy.
|
||||
//
|
||||
// aRejectedReason must be one of these values:
|
||||
// * nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION
|
||||
// * nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
|
||||
// * nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL
|
||||
// * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
|
||||
// * nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT
|
||||
static void
|
||||
NotifyRejection(nsIChannel* aChannel);
|
||||
NotifyRejection(nsIChannel* aChannel, uint32_t aRejectedReason);
|
||||
|
||||
static void
|
||||
NotifyRejection(nsPIDOMWindowInner* aWindow);
|
||||
NotifyRejection(nsPIDOMWindowInner* aWindow, uint32_t aRejectedReason);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -217,7 +217,7 @@ this.AntiTracking = {
|
||||
let cookieBlocked = 0;
|
||||
let listener = {
|
||||
onSecurityChange(webProgress, request, stateFlags, status) {
|
||||
if (stateFlags & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_COOKIES) {
|
||||
if (stateFlags & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER) {
|
||||
++cookieBlocked;
|
||||
}
|
||||
},
|
||||
|
@ -218,14 +218,10 @@ interface nsIWebProgressListener : nsISupports
|
||||
*
|
||||
* STATE_BLOCKED_UNSAFE_CONTENT
|
||||
* Content which againts SafeBrowsing list has been blocked from loading.
|
||||
*
|
||||
* STATE_BLOCKED_TRACKING_COOKIES
|
||||
* Tracking cookies has been blocked from loading.
|
||||
*/
|
||||
const unsigned long STATE_BLOCKED_TRACKING_CONTENT = 0x00001000;
|
||||
const unsigned long STATE_LOADED_TRACKING_CONTENT = 0x00002000;
|
||||
const unsigned long STATE_BLOCKED_UNSAFE_CONTENT = 0x00004000;
|
||||
const unsigned long STATE_BLOCKED_TRACKING_COOKIES = 0x00008000;
|
||||
|
||||
/**
|
||||
* Diagnostic flags
|
||||
@ -295,6 +291,33 @@ interface nsIWebProgressListener : nsISupports
|
||||
const unsigned long STATE_USES_WEAK_CRYPTO = 0x02000000;
|
||||
const unsigned long STATE_CERT_USER_OVERRIDDEN = 0x04000000;
|
||||
|
||||
/**
|
||||
* Cookie Jar blocking
|
||||
*
|
||||
* These flags describe the reason of cookie jar rejection.
|
||||
*
|
||||
* STATE_COOKIES_BLOCKED_BY_PERMISSION
|
||||
* Rejected for custom site permission.
|
||||
*
|
||||
* STATE_COOKIES_BLOCKED_TRACKER
|
||||
* Rejected because the resource is a tracker and cookie policy doesn't
|
||||
* allow its loading.
|
||||
*
|
||||
* STATE_COOKIES_BLOCKED_ALL
|
||||
* Rejected because cookie policy blocks all cookies.
|
||||
*
|
||||
* STATE_COOKIES_BLOCKED_FOREIGN
|
||||
* Rejected because cookie policy blocks 3rd party cookies.
|
||||
*
|
||||
* STATE_BLOCKED_SLOW_TRACKING_CONTENT
|
||||
* Rejected because of the FastBlock feature.
|
||||
*/
|
||||
const unsigned long STATE_COOKIES_BLOCKED_BY_PERMISSION = 0x10000000;
|
||||
const unsigned long STATE_COOKIES_BLOCKED_TRACKER = 0x20000000;
|
||||
const unsigned long STATE_COOKIES_BLOCKED_ALL = 0x40000000;
|
||||
const unsigned long STATE_COOKIES_BLOCKED_FOREIGN = 0x80000000;
|
||||
const unsigned long STATE_BLOCKED_SLOW_TRACKING_CONTENT = 0x00000040;
|
||||
|
||||
/**
|
||||
* Notification indicating the state has changed for one of the requests
|
||||
* associated with aWebProgress.
|
||||
|
@ -422,7 +422,7 @@ NS_IMETHODIMP nsExtProtocolChannel::NotifyTrackingProtectionDisabled()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::NotifyTrackingCookieBlocked()
|
||||
NS_IMETHODIMP nsExtProtocolChannel::NotifyTrackingCookieBlocked(uint32_t aRejectedReason)
|
||||
{
|
||||
// nothing to do
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user