Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Save Data Client Hint] (3) Add/Update WPTs
These WPTs have to be internal as there is no external way to enable data saver mode. For launch, this is sufficient as it verifies the behavior of the ch-save-data permissions policy. https://groups.google.com/a/chromium.org/g/blink-dev/c/HR7tWmewbSA/m/8lAP0lZVEwAJ This CL is part of a series: (1) Remove legacy feature (2) Implement as Client Hint (3) Add/Update WPTs Bug: 1293443 Change-Id: I18516ef01236fc109ca726c946ad7c8e66aaea60 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3582420 Reviewed-by: Ali Beyad <abeyad@chromium.org> Auto-Submit: Ari Chivukula <arichiv@chromium.org> Commit-Queue: Ari Chivukula <arichiv@chromium.org> Cr-Commit-Position: refs/heads/main@{#992343}
- Loading branch information
Showing
6 changed files
with
124 additions
and
41 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
third_party/blink/web_tests/http/tests/fetch/chromium/data-saver-disabled-policy-all.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<html> | ||
<title>Tests for 'Save-Data' header when Data Saver is disabled and the policy is *.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
internals.setSaveDataEnabled(false); | ||
</script> | ||
<iframe allow="ch-save-data *;" srcdoc=" | ||
<!DOCTYPE html> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script> | ||
var CHECK_PATH = './resources/check-save-data-header.php'; | ||
var METHODS = ['GET', 'POST', 'PUT']; | ||
var REQUESTS = | ||
METHODS.map(method => new Request(CHECK_PATH, {method: method})); | ||
window.top.promise_test(t => { | ||
return Promise.all(REQUESTS.map(request => fetch(request.clone()))) | ||
.then(responses => Promise.all(responses.map(response => response.text()))) | ||
.then(texts => { | ||
for (var i = 0; i < METHODS.length; ++i) { | ||
assert_equals(texts[i], 'No Save-Data'); | ||
} | ||
}); | ||
}, 'Save-Data should not be sent when disabled if policy is *.'); | ||
</script> | ||
"></iframe> | ||
</html> |
28 changes: 28 additions & 0 deletions
28
third_party/blink/web_tests/http/tests/fetch/chromium/data-saver-disabled-policy-none.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<html> | ||
<title>Tests for 'Save-Data' header when Data Saver is disabled and the policy is 'none'.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
internals.setSaveDataEnabled(false); | ||
</script> | ||
<iframe allow="ch-save-data 'none';" srcdoc=" | ||
<!DOCTYPE html> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script> | ||
var CHECK_PATH = './resources/check-save-data-header.php'; | ||
var METHODS = ['GET', 'POST', 'PUT']; | ||
var REQUESTS = | ||
METHODS.map(method => new Request(CHECK_PATH, {method: method})); | ||
window.top.promise_test(t => { | ||
return Promise.all(REQUESTS.map(request => fetch(request.clone()))) | ||
.then(responses => Promise.all(responses.map(response => response.text()))) | ||
.then(texts => { | ||
for (var i = 0; i < METHODS.length; ++i) { | ||
assert_equals(texts[i], 'No Save-Data'); | ||
} | ||
}); | ||
}, 'Save-Data should not be sent when disabled if policy is none.'); | ||
</script> | ||
"></iframe> | ||
</html> |
26 changes: 6 additions & 20 deletions
26
...http/tests/fetch/chromium/data-saver.html → ...s/fetch/chromium/data-saver-disabled.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,28 @@ | ||
<html> | ||
<title>Tests for 'Save-Data' header.</title> | ||
<title>Tests for 'Save-Data' header when Data Saver is disabled.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> internals.setSaveDataEnabled(false); </script> | ||
|
||
<script> | ||
internals.setSaveDataEnabled(false); | ||
</script> | ||
<iframe srcdoc=" | ||
<!DOCTYPE html> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script> | ||
var CHECK_PATH = './resources/check-save-data-header.php'; | ||
var METHODS = ['GET', 'POST', 'PUT']; | ||
var REQUESTS = | ||
METHODS.map(method => new Request(CHECK_PATH, {method: method})); | ||
internals.setSaveDataEnabled(false); | ||
window.top.promise_test(t => { | ||
internals.setSaveDataEnabled(false); | ||
return Promise.all(REQUESTS.map(request => fetch(request.clone()))) | ||
.then(responses => Promise.all(responses.map(response => response.text()))) | ||
.then(texts => { | ||
for (var i = 0; i < METHODS.length; ++i) { | ||
assert_equals( | ||
texts[i], 'No Save-Data', | ||
'Save-Data header should not be sent when disabled. method: ' + | ||
METHODS[i]); | ||
assert_equals(texts[i], 'No Save-Data'); | ||
} | ||
}); | ||
}, 'fetch() from document with Data-Saver disabled.'); | ||
// Tests for dedicated workers and shared workers are implemented as browser | ||
// tests because they are requested from the browser process, and | ||
// internals.setSaveDataEnable() doesn't work in those cases. | ||
}, 'Save-Data should not be sent when disabled.'); | ||
</script> | ||
"></iframe> | ||
|
||
</html> |
28 changes: 28 additions & 0 deletions
28
third_party/blink/web_tests/http/tests/fetch/chromium/data-saver-enabled-policy-all.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<html> | ||
<title>Tests for 'Save-Data' header when Data Saver is enabled and the policy is *.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
internals.setSaveDataEnabled(true); | ||
</script> | ||
<iframe allow="ch-save-data *;" srcdoc=" | ||
<!DOCTYPE html> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script> | ||
var CHECK_PATH = './resources/check-save-data-header.php'; | ||
var METHODS = ['GET', 'POST', 'PUT']; | ||
var REQUESTS = | ||
METHODS.map(method => new Request(CHECK_PATH, {method: method})); | ||
window.top.promise_test(t => { | ||
return Promise.all(REQUESTS.map(request => fetch(request.clone()))) | ||
.then(responses => Promise.all(responses.map(response => response.text()))) | ||
.then(texts => { | ||
for (var i = 0; i < METHODS.length; ++i) { | ||
assert_equals(texts[i], 'Save-Data: on'); | ||
} | ||
}); | ||
}, 'Save-Data should be sent when enabled if policy is *.'); | ||
</script> | ||
"></iframe> | ||
</html> |
28 changes: 28 additions & 0 deletions
28
third_party/blink/web_tests/http/tests/fetch/chromium/data-saver-enabled-policy-none.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<html> | ||
<title>Tests for 'Save-Data' header when Data Saver is enabled and the policy is 'none'.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
internals.setSaveDataEnabled(true); | ||
</script> | ||
<iframe allow="ch-save-data 'none';" srcdoc=" | ||
<!DOCTYPE html> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script> | ||
var CHECK_PATH = './resources/check-save-data-header.php'; | ||
var METHODS = ['GET', 'POST', 'PUT']; | ||
var REQUESTS = | ||
METHODS.map(method => new Request(CHECK_PATH, {method: method})); | ||
window.top.promise_test(t => { | ||
return Promise.all(REQUESTS.map(request => fetch(request.clone()))) | ||
.then(responses => Promise.all(responses.map(response => response.text()))) | ||
.then(texts => { | ||
for (var i = 0; i < METHODS.length; ++i) { | ||
assert_equals(texts[i], 'No Save-Data'); | ||
} | ||
}); | ||
}, 'Save-Data should not be sent when enabled if policy is none.'); | ||
</script> | ||
"></iframe> | ||
</html> |
27 changes: 6 additions & 21 deletions
27
third_party/blink/web_tests/http/tests/fetch/chromium/data-saver-enabled.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,28 @@ | ||
<html> | ||
<title>Tests for 'Save-Data' header.</title> | ||
<title>Tests for 'Save-Data' header when Data Saver is enabled.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<!-- Enable save data header and the JavaScript attribute --> | ||
<script> internals.setSaveDataEnabled(true); </script> | ||
|
||
<script> | ||
internals.setSaveDataEnabled(true); | ||
</script> | ||
<iframe srcdoc=" | ||
<!DOCTYPE html> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script> | ||
internals.setSaveDataEnabled(true); | ||
var CHECK_PATH = './resources/check-save-data-header.php'; | ||
var METHODS = ['GET', 'POST', 'PUT']; | ||
var REQUESTS = | ||
METHODS.map(method => new Request(CHECK_PATH, {method: method})); | ||
window.top.promise_test(t => { | ||
internals.setSaveDataEnabled(true); | ||
return Promise.all(REQUESTS.map(request => fetch(request.clone()))) | ||
.then(responses => Promise.all(responses.map(response => response.text()))) | ||
.then(texts => { | ||
for (var i = 0; i < METHODS.length; ++i) { | ||
assert_equals( | ||
texts[i], 'Save-Data: on', | ||
'Save-Data header should be sent when disabled. method: ' + | ||
METHODS[i]); | ||
assert_equals(texts[i], 'Save-Data: on'); | ||
} | ||
}); | ||
}, 'fetch() from document with Data-Saver enabled.'); | ||
// Tests for dedicated workers and shared workers are implemented as browser | ||
// tests because they are requested from the browser process, and | ||
// internals.setSaveDataEnable() doesn't work in those cases. | ||
}, 'Save-Data should be sent when enabled.'); | ||
</script> | ||
"></iframe> | ||
|
||
</html> |