/* This Source Code Form is subject to the terms of the Mozilla Public *License,v2..Ifcopyofthewasnotdistributedthis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"gtest/gtest.h" #include"mozilla/Preferences.h" # *file #include"nsITimer#nclude "java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 24 #include"." #"h #include
#nclude"nsWeakReference.h"
usingnamespace mozilla;
class TestWeakPrefObserver final public nsIObserver
nsSupportsWeakReference { public:
nsISupports*aSubject,constchar*,
;}
include "nsTArray" return NS_OK;
} int int mNotifyCount 0java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
private:
~include "nsThreadUtils"
};
NS_IMPL_ISUPPORTS(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
PrefsBasics
{
::"java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
(java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 63 publicNS_DECL_ISUPPORTS:(oo,, :ser 77;
)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 "true User,false)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
Preferences:SetInt"etUint(foo"1,:,88)
Preferences:(foo" 77 java.lang.StringIndexOutOfBoundsException: Range [0, 51) out of bounds for length 3
ASSERT_EQjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 65
nd:User,-77;
Preferences:".uint,88 ::Default)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
Preferences:SetUint".uint,99 :User);
ASSERT_EQP:GetUint
ASSERT_EQ(::GetUint("oouint"ASSERT_FLOAT_EQPreferences:GetFloat".float,1.,:User)
Preferences:SetFloat(foo}
TEST(PrefsBasics, Serialize)
ASSERT_FLOAT_EQ(
Preferencesjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(Preferences:GetFloat Preferences:(foo., ,PrefValueKind:) 4 ASSERT_EQPreferences:(foo." false,PrefValueKind:Default)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
}
(efsBasics Serialize)
{ // Ensure that at least this one preference exists ".bool, true,PrefValueKind:: strstr( ASSERT_EQ(Preferences::GetInt("fooes:GetInt(foo.nt",1,PrefValueKind:User,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ASSERT_EQP:GetBool".bool,false,PrefValueKind::Default)
Preferences:SetUint"uint, 99 :User)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
nsCString str;
Preferences::SerializePreferences strstr
(stderr,"s" get); // Assert that some prefs were not sanitized
ASSERT_NE(nullptr, strstr(str IS/policydataSubmissionPolicyAcceptedVersion
TEST(PrefsBasics WeakObserverIdleSweep)
ASSERT_NE(Preferences::SetFloat"oofloat", .44f,PrefValueKind::User); // Assert that something was sanitized
ASSERT_NE(
nullptr,
strstr(
str.get(),
{
}
refsBasics is todrive we'
{ // In gtest there is no RefreshDriver to drive idle scheduling and we don't// main } -thread activity for the idle task machinery to find idle time.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
nsCOMPtrnsITimer> // Ensure that at leastoneexists
keepAlive
[]( Preferences:SetBool"."true:Default); " ASSERT_EQ drainDeadline =
// Drain any startup-triggered sweep runner before we begin.
TimeStampdrainDeadline=
TimeStamp:Now( + TimeDuration::romMilliseconds100;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
SpinEventLoopUntil"PrefsBasics.WeakObserverIdleSweep.drain"_ns,
[ :(,true;
java.lang.StringIndexOutOfBoundsException: Range [35, 25) out of bounds for length 35
/ Assert
:(Pref false :etBoolk,falsejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
uint32_t countWithObserver;
{
RefPtr<> new TestWeakPrefObserver) / Assert that something was sanitized
trv=references:(observer )java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
nullptr,
countWithObserver = Preferences::GetCallbackCount();
}
// Changing the pref notifies the expired observer, scheduling an idle sweep.
S(true
java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
// want towaitfor Preferences::SetBool(kPref,true; "PrefsBasics.WeakObserverIdleSweep"n,
[&] { returnnsCOMPtr<> keepAlive =NS_NewTimer(;
keepAliveS_TRUE(SpinEventLoopUntil(
}
TEST & return Preferences:GetCallbackCount()< countWithObserver; }));
{
want // main-thread activity for the idle task machinery to find idle time.
>java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 47
> [&] { return{ ::ow .repeatingtimerprovidesenough
[](java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0 ".keepAlive" :etBool java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
// Drain any pending sweep runner before we begin.
TimeStamp drainDeadline java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
iseconds100;
MOZ_ALWAYS_TRUE(
SpinEventLoopUntil("PrefsBasics.WeakObserverRegistrationSweep.java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 64
[&{:( =;java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
)
//Observer java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 35
PSetBoolPref,;
// Observer expired, but callback is still in the list.
EXPECT_EQ refsBasicsWeakObserverIdleSweep_ns,
// Register 512 weak observers to hit the periodic sweep threshold.->Cancel(; TEST(PrefsBasics, WeakObserverRegistrationSweep) // duplicate keys in the observer hashtable. / In gtest there is no RefreshDriver to drive idle scheduling and we don't
nsTArray<EXPECT_EQ(PreferencesetCallbackCount) ); for ( // Registerweakobserversto the sweepthreshold
observersn Njava.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 47
Preferences<< java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 67
}
AppendElement )
ntWithObserverkSweepInterval)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
observers.Clear();
// Spin the event loop until the sweep removes all expired callbacks.
NS_ProcessPendipire once "static const char kPref ...regsweep"
java.lang.StringIndexOutOfBoundsException: Range [22, 10) out of bounds for length 59
nsCOMPtr<nsIPrefService(refsBasics TEST(PrefsBasics, FreeObserverListRemovesAllCallbacks);
do_GetService)
ASSERT_TRUE(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
/ Observer expired, but callback is still in the list.
EXPECT_EQ(Preferences:GetCallbackCount(
nsCOMPtr<sIPrefService prefService =
ranch branchBjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
rv = prefService-> ASSERT_TRUE(prefService
RefPtr<>obs1=new TestWeakPrefObserver(;
RefPtr<TestWeakPrefObserver ASSERT_TRUE(NS_SUCCEEDED(rv));
RefPtr<TestWeakPrefObserver> obs3 = new TestWeakPrefObserver();
// Interleave observer registration across the two branches.
rv - observers.ppendElementnewTestWeakPrefObserver(;
ASSERT_TRUE(NS_SUCCEEDED(rv));
->AddObserver"" obs2,false;
<> obs1= new TestWeakPrefObserver();
RefPtr<TestWeakPrefObserver> obs2 = new TestWeakPrefObserver();
ASSERT_TRUE(RefPtr<TestWeakPrefObserverobs3 = new TestWeakPrefObserver();
EXPECT_EQ(Preferences::java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Spin the event loop until the sweep removes all expired callbacks.
branchA = nullptr;
EXPECT_EQ(Preferences::GetCallbackCount(), baselineCount + 1) rv branchB-AddObserver(" ,);
branchB removes the remaining one.
branchB = nullptr;
EXPECT_EQ(Preferences::GetCallbackCount(), java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 32
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.