Auto merge of #19849 - gterzian:update_wpt, r=jdm

WPT tests: Remove custom cache script, use trickle option instead

<!-- Please describe your changes on the following line: -->

Follow up on https://github.com/servo/servo/pull/19350 @jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19849)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-01-25 14:38:11 -06:00 committed by GitHub
commit a2fca92881
5 changed files with 6 additions and 80 deletions

View file

@ -12495,11 +12495,6 @@
{}
]
],
"mozilla/resources/http-cache-trickle.py": [
[
{}
]
],
"mozilla/resources/http-cache.js": [
[
{}
@ -66395,11 +66390,11 @@
"testharness"
],
"mozilla/http-cache-xhr.html": [
"d4747fdc9ec6acc50718c13a668451987a44d219",
"56c44d5100ec2b5a585192e4ec319bb133123c93",
"testharness"
],
"mozilla/http-cache.html": [
"33827dc9bdb0efcbcae4f730086693be315cfc14",
"929fdc40e9a193d0ead4c95e2d21d030d27d4bf0",
"testharness"
],
"mozilla/iframe-unblock-onload.html": [
@ -72074,12 +72069,8 @@
"78686147f85e4146e7fc58c1f67a613f65b099a2",
"support"
],
"mozilla/resources/http-cache-trickle.py": [
"48f4e32ec2e1c1b6d47e89254045b398c1d84d40",
"support"
],
"mozilla/resources/http-cache.js": [
"4bf71e1f328e778990eb756741a3be58f4f57ef6",
"c6b1ee9def26d4e12a1b93e551c225f82b4717c2",
"support"
],
"mozilla/resources/iframe_contentDocument_inner.html": [

View file

@ -28,7 +28,7 @@
];
var uuid = token();
var url = make_url(uuid, requests, 0);
url += '&trickle=true';
url += '&pipe=trickle(1:d1:r2)';
client.onprogress = test.step_func(function() {
var client2 = new XMLHttpRequest();
client2.onloadend = test.step_func(function(event) {

View file

@ -4,7 +4,6 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="resources/http-cache.js"></script>
<script src="/fetch/http-cache/resources/http-cache.py"></script>
<script>
var tests = [];
function check_status(status) {

View file

@ -1,64 +0,0 @@
# 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/.
import time
from json import JSONEncoder, JSONDecoder
from base64 import b64decode
def main(request, response):
uuid = request.GET.first("token", None)
if "querystate" in request.GET:
response.headers.set("Content-Type", "text/plain")
return JSONEncoder().encode(request.server.stash.take(uuid))
server_state = request.server.stash.take(uuid)
if not server_state:
server_state = []
requests = JSONDecoder().decode(b64decode(request.GET.first("info", "")))
config = requests[len(server_state)]
state = dict()
state["request_method"] = request.method
state["request_headers"] = dict([[h.lower(), request.headers[h]] for h in request.headers])
server_state.append(state)
request.server.stash.put(uuid, server_state)
note_headers = ['content-type', 'access-control-allow-origin', 'last-modified', 'etag']
noted_headers = {}
for header in config.get('response_headers', []):
if header[0].lower() in ["location", "content-location"]: # magic!
header[1] = "%s&target=%s" % (request.url, header[1])
response.headers.set(header[0], header[1])
if header[0].lower() in note_headers:
noted_headers[header[0].lower()] = header[1]
if "access-control-allow-origin" not in noted_headers:
response.headers.set("Access-Control-Allow-Origin", "*")
if "content-type" not in noted_headers:
response.headers.set("Content-Type", "text/plain")
response.headers.set("Server-Request-Count", len(server_state))
code, phrase = config.get("response_status", [200, "OK"])
if request.headers.get("If-Modified-Since", False) == noted_headers.get('last-modified', True):
code, phrase = [304, "Not Modified"]
if request.headers.get("If-None-Match", False) == noted_headers.get('etag', True):
code, phrase = [304, "Not Modified"]
response.status = (code, phrase)
if request.GET.first("trickle", None):
response.write_status_headers()
for byte in config.get("response_body", uuid):
response.writer.write_content(byte)
time.sleep(1)
content = config.get("response_body", uuid)
if code in [204, 304]:
return ""
else:
return content

View file

@ -40,11 +40,11 @@ function make_url(uuid, requests, idx) {
if ("query_arg" in requests[idx]) {
arg = "&target=" + requests[idx].query_arg;
}
return "resources/http-cache-trickle.py?token=" + uuid + "&info=" + btoa(JSON.stringify(requests)) + arg;
return "/fetch/http-cache/resources/http-cache.py?token=" + uuid + "&info=" + btoa(JSON.stringify(requests)) + arg;
}
function server_state(uuid) {
return fetch("resources/http-cache-trickle.py?querystate&token=" + uuid)
return fetch("/fetch/http-cache/resources/http-cache.py?querystate&token=" + uuid)
.then(function(response) {
return response.text();
}).then(function(text) {