Commit b94d6da8 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Remove tentative suffix from stale-while-revalidate.

The PR has been merged into the fetch spec.
https://github.com/whatwg/fetch/pull/853

BUG=348877

Change-Id: I5e06ebee3b968e569453df51a441338fb93df72a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1566154Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656466}
parent f4fe59a5
<!DOCTYPE html> <!DOCTYPE html>
<!---
Tentative test against:
https://github.com/whatwg/fetch/pull/853
-->
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
...@@ -39,9 +35,9 @@ https://github.com/whatwg/fetch/pull/853 ...@@ -39,9 +35,9 @@ https://github.com/whatwg/fetch/pull/853
promise_test(async (test) => { promise_test(async (test) => {
var request_token = token(); var request_token = token();
const uri = 'stale-script.py?token=' + request_token; const uri = 'resources/stale-script.py?token=' + request_token;
await setupRegistrationAndWaitToBeControlled(test, 'stale-script.py'); await setupRegistrationAndWaitToBeControlled(test, 'resources/stale-script.py');
var service_worker_count = 0; var service_worker_count = 0;
navigator.serviceWorker.addEventListener('message', function once(event) { navigator.serviceWorker.addEventListener('message', function once(event) {
...@@ -54,7 +50,7 @@ https://github.com/whatwg/fetch/pull/853 ...@@ -54,7 +50,7 @@ https://github.com/whatwg/fetch/pull/853
const response2 = await fetch(uri); const response2 = await fetch(uri);
assert_equals(response.headers.get('Unique-Id'), response2.headers.get('Unique-Id')); assert_equals(response.headers.get('Unique-Id'), response2.headers.get('Unique-Id'));
while(true) { while(true) {
const revalidation_check = await fetch(`stale-script.py?query&token=` + request_token); const revalidation_check = await fetch(`resources/stale-script.py?query&token=` + request_token);
if (revalidation_check.headers.get('Count') == '2') { if (revalidation_check.headers.get('Count') == '2') {
// The service worker should not see the revalidation request. // The service worker should not see the revalidation request.
assert_equals(service_worker_count, 2); assert_equals(service_worker_count, 2);
......
<!DOCTYPE html> <!DOCTYPE html>
<!---
Tentative test against:
https://github.com/whatwg/fetch/pull/853
-->
<meta charset="utf-8"> <meta charset="utf-8">
<title>Tests Stale While Revalidate is not executed for fetch API</title> <title>Tests Stale While Revalidate is not executed for fetch API</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
...@@ -20,13 +16,13 @@ function wait25ms(test) { ...@@ -20,13 +16,13 @@ function wait25ms(test) {
promise_test(async (test) => { promise_test(async (test) => {
var request_token = token(); var request_token = token();
const response = await fetch(`stale-script.py?token=` + request_token); const response = await fetch(`resources/stale-script.py?token=` + request_token);
const response2 = await fetch(`stale-script.py?token=` + request_token); const response2 = await fetch(`resources/stale-script.py?token=` + request_token);
assert_equals(response.headers.get('Unique-Id'), response2.headers.get('Unique-Id')); assert_equals(response.headers.get('Unique-Id'), response2.headers.get('Unique-Id'));
while(true) { while(true) {
const revalidation_check = await fetch(`stale-script.py?query&token=` + request_token); const revalidation_check = await fetch(`resources/stale-script.py?query&token=` + request_token);
if (revalidation_check.headers.get('Count') == '2') { if (revalidation_check.headers.get('Count') == '2') {
break; break;
} }
......
...@@ -25,7 +25,7 @@ def main(request, response): ...@@ -25,7 +25,7 @@ def main(request, response):
if count > 1: if count > 1:
filename = "green-256x256.png" filename = "green-256x256.png"
path = os.path.join(os.path.dirname(__file__), "../../images", filename) path = os.path.join(os.path.dirname(__file__), "../../../images", filename)
body = open(path, "rb").read() body = open(path, "rb").read()
response.add_required_headers = False response.add_required_headers = False
......
<!DOCTYPE html> <!DOCTYPE html>
<!---
Tentative test against:
https://github.com/whatwg/fetch/pull/853
-->
<meta charset="utf-8"> <meta charset="utf-8">
<title>Tests Stale While Revalidate works for css</title> <title>Tests Stale While Revalidate works for css</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
...@@ -21,7 +17,7 @@ async_test(t => { ...@@ -21,7 +17,7 @@ async_test(t => {
assert_equals(window.getComputedStyle(document.body).getPropertyValue('background-color'), "rgb(0, 128, 0)"); assert_equals(window.getComputedStyle(document.body).getPropertyValue('background-color'), "rgb(0, 128, 0)");
var checkResult = () => { var checkResult = () => {
// We poll because we don't know when the revalidation will occur. // We poll because we don't know when the revalidation will occur.
fetch("stale-css.py?query&token=" + request_token).then(t.step_func((response) => { fetch("resources/stale-css.py?query&token=" + request_token).then(t.step_func((response) => {
var count = response.headers.get("Count"); var count = response.headers.get("Count");
if (count == '2') { if (count == '2') {
t.done(); t.done();
...@@ -34,7 +30,7 @@ async_test(t => { ...@@ -34,7 +30,7 @@ async_test(t => {
}); });
link2.rel = "stylesheet"; link2.rel = "stylesheet";
link2.type = "text/css"; link2.type = "text/css";
link2.href = "stale-css.py?token=" + request_token; link2.href = "resources/stale-css.py?token=" + request_token;
document.body.appendChild(link2); document.body.appendChild(link2);
}, 0); }, 0);
}); });
...@@ -43,7 +39,7 @@ async_test(t => { ...@@ -43,7 +39,7 @@ async_test(t => {
var link = document.createElement("link"); var link = document.createElement("link");
link.rel = "stylesheet"; link.rel = "stylesheet";
link.type = "text/css"; link.type = "text/css";
link.href = "stale-css.py?token=" + request_token; link.href = "resources/stale-css.py?token=" + request_token;
document.body.appendChild(link); document.body.appendChild(link);
</script> </script>
</body> </body>
<!DOCTYPE html> <!DOCTYPE html>
<!---
Tentative test against:
https://github.com/whatwg/fetch/pull/853
-->
<meta charset="utf-8"> <meta charset="utf-8">
<title>Tests Stale While Revalidate works for images</title> <title>Tests Stale While Revalidate works for images</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
...@@ -28,7 +24,7 @@ async_test(t => { ...@@ -28,7 +24,7 @@ async_test(t => {
assert_equals(img2.width, 16, "image dimension"); assert_equals(img2.width, 16, "image dimension");
var checkResult = () => { var checkResult = () => {
// We poll because we don't know when the revalidation will occur. // We poll because we don't know when the revalidation will occur.
fetch("stale-image.py?query&token=" + request_token).then(t.step_func((response) => { fetch("resources/stale-image.py?query&token=" + request_token).then(t.step_func((response) => {
var count = response.headers.get("Count"); var count = response.headers.get("Count");
if (count == '2') { if (count == '2') {
t.done(); t.done();
...@@ -39,14 +35,14 @@ async_test(t => { ...@@ -39,14 +35,14 @@ async_test(t => {
}; };
t.step_timeout(checkResult, 25); t.step_timeout(checkResult, 25);
}); });
img2.src = "stale-image.py?token=" + request_token; img2.src = "resources/stale-image.py?token=" + request_token;
childDocument.body.appendChild(img2); childDocument.body.appendChild(img2);
}, 0); }, 0);
}); });
}, 'Cache returns stale resource'); }, 'Cache returns stale resource');
var img = document.createElement("img"); var img = document.createElement("img");
img.src = "stale-image.py?token=" + request_token; img.src = "resources/stale-image.py?token=" + request_token;
img.id = "firstimage"; img.id = "firstimage";
document.body.appendChild(img); document.body.appendChild(img);
</script> </script>
......
<!DOCTYPE html> <!DOCTYPE html>
<!---
Tentative test against:
https://github.com/whatwg/fetch/pull/853
-->
<meta charset="utf-8"> <meta charset="utf-8">
<title>Tests Stale While Revalidate works for scripts</title> <title>Tests Stale While Revalidate works for scripts</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
...@@ -29,13 +25,13 @@ async_test(t => { ...@@ -29,13 +25,13 @@ async_test(t => {
window.onload = t.step_func(() => { window.onload = t.step_func(() => {
step_timeout(() => { step_timeout(() => {
var script = document.createElement("script"); var script = document.createElement("script");
script.src = "stale-script.py?token=" + request_token; script.src = "resources/stale-script.py?token=" + request_token;
document.body.appendChild(script); document.body.appendChild(script);
script.onload = t.step_func(() => { script.onload = t.step_func(() => {
assert_equals(last_modified_count, 2, "last modified"); assert_equals(last_modified_count, 2, "last modified");
var checkResult = () => { var checkResult = () => {
// We poll because we don't know when the revalidation will occur. // We poll because we don't know when the revalidation will occur.
fetch("stale-script.py?query&token=" + request_token).then(t.step_func((response) => { fetch("resources/stale-script.py?query&token=" + request_token).then(t.step_func((response) => {
var count = response.headers.get("Count"); var count = response.headers.get("Count");
if (count == '2') { if (count == '2') {
t.done(); t.done();
...@@ -51,7 +47,7 @@ async_test(t => { ...@@ -51,7 +47,7 @@ async_test(t => {
}, 'Cache returns stale resource'); }, 'Cache returns stale resource');
var script = document.createElement("script"); var script = document.createElement("script");
script.src = "stale-script.py?token=" + request_token; script.src = "resources/stale-script.py?token=" + request_token;
document.body.appendChild(script); document.body.appendChild(script);
</script> </script>
</body> </body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment