Chromium Code Reviews| 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..6bb96f10941dd2ffc5fe2d7928aa85d1ac51e7d6 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html |
| +++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html |
| @@ -4,15 +4,30 @@ |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="/serviceworker/resources/interfaces.js"></script> |
| <script> |
| -promise_test(function() { |
| - var credential = new PasswordCredential({ |
| - id: 'id', |
| - password: 'pencil', |
| - name: 'name', |
| - iconURL: 'https://example.com/icon.png' |
| - }); |
| +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' }); |
| + assert_equals(r.credentials, "password"); |
| + r.text().then(t => assert_equals(t, "")); |
| +}, "Creating 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."); |
| - return fetch("./resources/echo-post.php", { body: credential, method: "POST" }) |
| +promise_test(function() { |
| + return fetch("./resources/echo-post.php", { credentials: c, method: "POST" }) |
| .then(function (r) { |
| return r.json(); |
| }) |
| @@ -22,6 +37,10 @@ promise_test(function() { |
| }); |
| }, "Simple Fetch"); |
|
horo
2016/04/04 05:26:00
Please test req.clone().
var c = new PasswordCred
Mike West
2016/04/04 08:04:20
Done, thanks!
|
| +/* |
| +OLD TESTS |
| +*/ |
| + |
| promise_test(function() { |
| var credential = new PasswordCredential({ |
| id: 'id', |
| @@ -33,7 +52,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 +75,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 +98,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 +125,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 +152,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 +175,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 +200,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 +223,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(); |
| }) |