| Index: third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html
|
| index da43aef0a1aa5b74033e428ed43a6f188eb303dc..7622777cb22bc17419105a601acd8018002a32a3 100644
|
| --- a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html
|
| @@ -4,23 +4,92 @@
|
| <script src="../resources/testharnessreport.js"></script>
|
| <script src="/serviceworker/resources/interfaces.js"></script>
|
| <script>
|
| +var c = new PasswordCredential({
|
| + id: 'id',
|
| + password: 'pencil',
|
| + name: 'name',
|
| + iconURL: 'https://example.com/icon.png'
|
| +});
|
| +
|
| +promise_test(_ => {
|
| + var r = new Request('/', { credentials: c, method: 'POST' });
|
| + var clone = r.clone();
|
| + assert_equals(r.credentials, "password");
|
| + assert_equals(clone.credentials, "password");
|
| + return Promise.all([
|
| + r.text().then(t => assert_equals(t, "")),
|
| + clone.text().then(t => assert_equals(t, ""))
|
| + ]);
|
| +}, "Creating/cloning a 'Request' does not expose the credential.");
|
| +
|
| +promise_test(_ => {
|
| + assert_throws(new TypeError(), _ => new Request("https://cross-origin.example.test/", { credentials: c, method: 'POST' }));
|
| + assert_throws(new TypeError(), _ => new Request("/", { credentials: c, method: 'GET' }));
|
| + assert_throws(new TypeError(), _ => new Request("/", { credentials: c, method: 'HEAD' }));
|
| + assert_throws(new TypeError(), _ => new Request("/", { credentials: 'password', method: 'POST' }));
|
| + assert_throws(new TypeError(), _ => new Request("/", { credentials: 'password', method: 'GET' }));
|
| + assert_throws(new TypeError(), _ => new Request("/", { credentials: 'password', body: "Body", method: 'GET' }));
|
| +}, "Creating a 'Request' throws in various ways.");
|
| +
|
| promise_test(function() {
|
| - var credential = new PasswordCredential({
|
| - id: 'id',
|
| - password: 'pencil',
|
| - name: 'name',
|
| - iconURL: 'https://example.com/icon.png'
|
| - });
|
| + return fetch("./resources/echo-post.php", { credentials: c, method: "POST" })
|
| + .then(resp => resp.json())
|
| + .then(j => {
|
| + assert_equals(j.username, 'id');
|
| + assert_equals(j.password, 'pencil');
|
| + });
|
| +}, "Simple Fetch");
|
|
|
| - return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
|
| - .then(function (r) {
|
| - return r.json();
|
| +promise_test(function() {
|
| + var r1 = new Request('./resources/echo-post.php', { credentials: c, method: "POST" });
|
| + var r2 = r1.clone();
|
| + return fetch(r1)
|
| + .then(resp => resp.json())
|
| + .then(j => {
|
| + assert_equals(j.username, 'id');
|
| + assert_equals(j.password, 'pencil');
|
| })
|
| - .then(function (j) {
|
| + .then(_ => fetch(r2))
|
| + .then(resp => resp.json())
|
| + .then(j => {
|
| assert_equals(j.username, 'id');
|
| assert_equals(j.password, 'pencil');
|
| });
|
| -}, "Simple Fetch");
|
| +}, "Fetch with cloned Request");
|
| +
|
| +promise_test(function() {
|
| + var r1 = new Request('./resources/echo-post.php', { credentials: c, method: "POST" });
|
| + var r2 = new Request(r1);
|
| + return fetch(r1)
|
| + .then(resp => resp.json())
|
| + .then(j => {
|
| + assert_equals(j.username, 'id');
|
| + assert_equals(j.password, 'pencil');
|
| + })
|
| + .then(_ => fetch(r2))
|
| + .then(resp => resp.json())
|
| + .then(j => {
|
| + assert_equals(j.username, 'id');
|
| + assert_equals(j.password, 'pencil');
|
| + });
|
| +}, "Fetch with copied Request");
|
| +
|
| +promise_test(function() {
|
| + var r1 = new Request('./resources/echo-post.php', { credentials: c, method: "POST" });
|
| + var r2 = new Request(r1, { credentials: 'same-origin' });
|
| + return fetch(r1)
|
| + .then(resp => resp.json())
|
| + .then(j => {
|
| + assert_equals(j.username, 'id');
|
| + assert_equals(j.password, 'pencil');
|
| + })
|
| + .then(_ => fetch(r2))
|
| + .then(resp => resp.json())
|
| + .then(j => {
|
| + assert_equals(j.username, undefined);
|
| + assert_equals(j.password, undefined);
|
| + });
|
| +}, "Fetch with overridden 'credentials'");
|
|
|
| promise_test(function() {
|
| var credential = new PasswordCredential({
|
| @@ -33,7 +102,7 @@ promise_test(function() {
|
| credential.idName = "notUsername";
|
| credential.passwordName = "notPassword";
|
|
|
| - return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
|
| + return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
|
| .then(function (r) {
|
| return r.json()
|
| })
|
| @@ -56,7 +125,7 @@ promise_test(function() {
|
| var fd = new FormData();
|
| credential.additionalData = fd;
|
|
|
| - return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
|
| + return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
|
| .then(function (r) {
|
| return r.json();
|
| })
|
| @@ -79,7 +148,7 @@ promise_test(function() {
|
| fd.append("csrf", "[randomness]");
|
| credential.additionalData = fd;
|
|
|
| - return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
|
| + return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
|
| .then(function (r) {
|
| return r.json();
|
| })
|
| @@ -106,7 +175,7 @@ promise_test(function() {
|
|
|
| // Use post-echo.cgi since PHP doesn't give us the raw data of a POST's
|
| // body if it's multipart/form-data.
|
| - return fetch("/xmlhttprequest/resources/post-echo.cgi", { body: credential, method: "POST" })
|
| + return fetch("/xmlhttprequest/resources/post-echo.cgi", { credentials: credential, method: "POST" })
|
| .then(function (r) {
|
| return r.text();
|
| })
|
| @@ -133,7 +202,7 @@ promise_test(function() {
|
| var params = new URLSearchParams();
|
| credential.additionalData = params;
|
|
|
| - return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
|
| + return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
|
| .then(function (r) {
|
| return r.json();
|
| })
|
| @@ -156,7 +225,7 @@ promise_test(function() {
|
| params.append("csrf", "[randomness]");
|
| credential.additionalData = params;
|
|
|
| - return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
|
| + return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
|
| .then(function (r) {
|
| return r.json();
|
| })
|
| @@ -181,7 +250,7 @@ promise_test(function() {
|
| params.append("password", "bar");
|
| credential.additionalData = params;
|
|
|
| - return fetch("./resources/echo-raw-post.php", { body: credential, method: "POST" })
|
| + return fetch("./resources/echo-raw-post.php", { credentials: credential, method: "POST" })
|
| .then(function (r) {
|
| return r.text();
|
| })
|
| @@ -204,7 +273,7 @@ promise_test(function() {
|
| params.append("a", "3");
|
| credential.additionalData = params;
|
|
|
| - return fetch("./resources/echo-raw-post.php", { body: credential, method: "POST" })
|
| + return fetch("./resources/echo-raw-post.php", { credentials: credential, method: "POST" })
|
| .then(function (r) {
|
| return r.text();
|
| })
|
|
|