Backed out changeset 971167f49931 (bug 1504729) for causing BR build bustages CLOSED TREE

This commit is contained in:
Bogdan Tara 2018-11-06 17:35:19 +02:00
Родитель 83f25ee252
Коммит 8b7521f47e
2 изменённых файлов: 53 добавлений и 53 удалений

Просмотреть файл

@ -30,8 +30,7 @@ class ContentBlockingLog final
// Each element is a tuple of (type, blocked, repeatCount). The type values
// come from the blocking types defined in nsIWebProgressListener.
typedef nsTArray<LogEntry> OriginLog;
typedef Pair<bool, OriginLog> OriginData;
typedef nsClassHashtable<nsStringHashKey, OriginData> OriginDataHashTable;
typedef nsClassHashtable<nsStringHashKey, OriginLog> OriginLogHashTable;
struct StringWriteFunc : public JSONWriteFunc
{
@ -57,14 +56,9 @@ public:
}
auto entry = mLog.LookupForAdd(aOrigin);
if (entry) {
auto& data = entry.Data();
if (aType == nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) {
data->first() = aBlocked;
return;
}
auto& log = data->second();
if (!log.IsEmpty()) {
auto& last = log.LastElement();
auto& log = entry.Data();
if (!log->IsEmpty()) {
auto& last = log->LastElement();
if (last.mType == aType &&
last.mBlocked == aBlocked) {
++last.mRepeatCount;
@ -72,21 +66,17 @@ public:
return;
}
}
if (log.Length() ==
if (log->Length() ==
std::max(1u, StaticPrefs::browser_contentblocking_originlog_length())) {
// Cap the size at the maximum length adjustable by the pref
log.RemoveElementAt(0);
log->RemoveElementAt(0);
}
log.AppendElement(LogEntry{aType, 1u, aBlocked});
log->AppendElement(LogEntry{aType, 1u, aBlocked});
} else {
entry.OrInsert([=] {
nsAutoPtr<OriginData> data(new OriginData(false, OriginLog()));
if (aType == nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) {
data->first() = true;
} else {
data->second().AppendElement(LogEntry{aType, 1u, aBlocked});
}
return data.forget();
auto log(MakeUnique<OriginLog>());
log->AppendElement(LogEntry{aType, 1u, aBlocked});
return log.release();
});
}
}
@ -106,17 +96,7 @@ public:
}
w.StartArrayProperty(NS_ConvertUTF16toUTF8(iter.Key()).get(), w.SingleLineStyle);
auto& data = *iter.UserData();
if (data.first()) {
w.StartArrayElement(w.SingleLineStyle);
{
w.IntElement(nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT);
w.BoolElement(true); // blocked
w.IntElement(1); // repeat count
}
w.EndArray();
}
for (auto& item: data.second()) {
for (auto& item: *iter.UserData()) {
w.StartArrayElement(w.SingleLineStyle);
{
w.IntElement(item.mType);
@ -140,16 +120,10 @@ public:
continue;
}
if (aType == nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) {
if (iter.UserData()->first()) {
for (auto& item: *iter.UserData()) {
if ((item.mType & aType) != 0) {
return true;
}
} else {
for (auto& item: iter.UserData()->second()) {
if ((item.mType & aType) != 0) {
return true;
}
}
}
}
return false;
@ -162,17 +136,17 @@ public:
// Now add the sizes of each origin log queue.
// The const_cast is needed because the nsTHashtable::Iterator interface is
// not const-safe. :-(
for (auto iter = const_cast<OriginDataHashTable&>(mLog).Iter();
for (auto iter = const_cast<OriginLogHashTable&>(mLog).Iter();
!iter.Done(); iter.Next()) {
if (iter.UserData()) {
aSizes.mDOMOtherSize +=
iter.UserData()->second().ShallowSizeOfIncludingThis(aSizes.mState.mMallocSizeOf);
iter.UserData()->ShallowSizeOfIncludingThis(aSizes.mState.mMallocSizeOf);
}
}
}
private:
OriginDataHashTable mLog;
OriginLogHashTable mLog;
};
} // namespace dom

Просмотреть файл

@ -156,29 +156,55 @@ add_task(async function() {
is(text, 1, "One cookie received received for scripts.");
});
let expectTrackerFound = item => {
is(item[0], Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT,
"Correct blocking type reported");
is(item[1], true,
"Correct blocking status reported");
ok(item[2] >= 1,
"Correct repeat count reported");
};
let log = JSON.parse(await browser.getContentBlockingLog());
for (let trackerOrigin in log) {
is(trackerOrigin, TEST_3RD_PARTY_DOMAIN, "Correct tracker origin must be reported");
let originLog = log[trackerOrigin];
is(originLog.length, 3, "We should have 3 entries in the compressed log");
is(originLog[0][0], Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT,
"Correct blocking type reported");
is(originLog[0][1], true,
"Correct blocking status reported");
ok(originLog[0][2] >= 1,
"Correct repeat count reported");
is(originLog.length, 10, "We should have 10 entries in the compressed log");
expectTrackerFound(originLog[0]);
is(originLog[1][0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER,
"Correct blocking type reported");
is(originLog[1][1], true,
"Correct blocking status reported");
is(originLog[1][2], 6,
is(originLog[1][2], 1,
"Correct repeat count reported");
is(originLog[2][0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER,
expectTrackerFound(originLog[2]);
is(originLog[3][0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER,
"Correct blocking type reported");
is(originLog[2][1], false,
is(originLog[3][1], true,
"Correct blocking status reported");
ok(originLog[2][2] >= 1,
is(originLog[3][2], 1,
"Correct repeat count reported");
expectTrackerFound(originLog[4]);
is(originLog[5][0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER,
"Correct blocking type reported");
is(originLog[5][1], true,
"Correct blocking status reported");
is(originLog[5][2], 1,
"Correct repeat count reported");
expectTrackerFound(originLog[6]);
is(originLog[7][0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER,
"Correct blocking type reported");
is(originLog[7][1], true,
"Correct blocking status reported");
is(originLog[7][2], 3,
"Correct repeat count reported");
is(originLog[8][0], Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER,
"Correct blocking type reported");
is(originLog[8][1], false,
"Correct blocking status reported");
is(originLog[8][2], 1,
"Correct repeat count reported");
expectTrackerFound(originLog[9]);
}
info("Removing the tab");