Update web-platform-tests to revision 181f8381fe9373e027f4b5ba5d1439843ad2c2e6

This commit is contained in:
WPT Sync Bot 2019-02-21 21:02:15 -05:00
parent 0dda115609
commit 0355b8e70d
105 changed files with 2775 additions and 764 deletions

View file

@ -207,3 +207,28 @@ async function reportExists(expected) {
}
return false;
}
/*
* Verifies that reports were uploaded that contains all of the fields in
* expected.
*/
async function reportsExist(expected_reports) {
const timeout = 10;
let reportLocation =
"/network-error-logging/support/report.py?op=retrieve_report&timeout=" +
timeout + "&reportID=" + reportID;
// There must be the report of pass.png, so adding 1.
const min_count = expected_reports.length + 1;
reportLocation += "&min_count=" + min_count;
const response = await fetch(reportLocation);
const json = await response.json();
for (const expected of expected_reports) {
const found = json.some((report) => {
return _isSubsetOf(expected, report);
});
if (!found)
return false;
}
return true;
}

View file

@ -2,12 +2,12 @@ import time
import json
import re
def retrieve_from_stash(request, key, timeout, default_value):
def retrieve_from_stash(request, key, timeout, min_count, default_value):
t0 = time.time()
while time.time() - t0 < timeout:
time.sleep(0.5)
value = request.server.stash.take(key=key)
if value is not None:
if value is not None and len(value) >= min_count:
request.server.stash.put(key=key, value=value)
return json.dumps(value)
@ -34,7 +34,11 @@ def main(request, response):
timeout = float(request.GET.first("timeout"))
except:
timeout = 0.5
return [("Content-Type", "application/json")], retrieve_from_stash(request, key, timeout, '[]')
try:
min_count = int(request.GET.first("min_count"))
except:
min_count = 1
return [("Content-Type", "application/json")], retrieve_from_stash(request, key, timeout, min_count, '[]')
# append new reports
new_reports = json.loads(request.body)